Syntax
chr=strarr2char(strarr)
Input Parameter
Output Parameter
chr : | | char chain that containts a string array |
Examples
x=[ "START" "move a from b to table" "move b from c to a" "move c from table to b" "FINISH"]
y=strarr2char(x)
u=char2strarr(y)
Copyright 2023-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, strarr2char
, is designed to convert a single row or single column string array into a character chain. It is part of the SolidGeometry library and was introduced in version 5.4. The function is authored by Tim Lueth and is part of the VLFL-Lib, dated December 13, 2023.
Input Parameters
- strarr: A string array that can be either a single row or a single column.
- varargin: Optional parameters, where the first optional parameter is expected to be a separator.
Output Results
- chr: A character chain that contains the elements of the string array, formatted according to the specified separator.
Algorithm Steps
- The function begins by determining the separator to use. It calls
getfuncparams
with the first optional parameter from varargin
, defaulting to a double quote ("
) if no separator is provided.
- A
switch
statement is used to handle different separator cases:
- Case '"': If the separator is a double quote, the function joins the elements of
strarr
with " "
(a space enclosed in double quotes) and formats them into a character string with each element enclosed in double quotes.
- Case ',': If the separator is a comma, the function joins the elements of
strarr
with a comma followed by a space (", "
) and formats them into a character string.
- Otherwise: If an unknown separator is provided, the function throws an error indicating the unknown separator.
Example Usage
Consider the following example:
x = [ "START" "move a from b to table" "move b from c to a" "move c from table to b" "FINISH" ];
y = strarr2char(x);
u = char2strarr(y);
In this example, x
is a string array. The function strarr2char
converts it into a character chain y
, and then char2strarr
can be used to convert it back to a string array u
.
Algorithm explaination created using ChatGPT on 2025-08-19 00:02. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21