Syntax
stra=cell2strarr(ccc,[joinch])
Input Parameter
ccc : | | cell list of string lines |
joinch : | | if a joint char is used the string array has only one column |
Output Parameter
Examples
yyy={["c" "table" "space" "b" "a"];["c" "table" "space" ]}
cell2strarr(yyy) % 2 x 5 array
cell2strarr(yyy," ") % 2 x 1 array
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, cell2strarr
, converts a cell list of string lines into a string array. It is part of the SolidGeometry library and was introduced in version 5.4.
Input Parameters
- ccc: A cell list containing string lines. Each element of the cell list is expected to be a string or an array of strings.
- joinch: An optional parameter. If provided, it is used as a joint character to concatenate strings, resulting in a string array with only one column.
Output
- stra: The resulting string array. Its structure depends on whether
joinch
is provided.
Algorithm Steps
- Retrieve the
joinch
parameter using getfuncparams
. If not provided, default to an empty string.
- Determine the number of lines,
nl
, in the input cell list ccc
.
- Initialize an empty array
ni
to store the number of elements in each line.
- Iterate over each line in
ccc
:
- Convert each line to a string using
cell2strlines
and split it by ', ' to get individual elements.
- Store the number of elements in
ni
.
- Check if
joinch
is empty:
- If empty, initialize
stra
as a 2D string array with dimensions nl
by max(ni)
.
- For each line, split it into elements and assign them to the corresponding row in
stra
.
- If
joinch
is not empty:
- Initialize
stra
as a 1D string array with nl
elements.
- For each line, split it into elements, join them using
joinch
, and assign the result to stra
.
Example Usage
Given a cell array yyy
:
yyy = {["c" "table" "space" "b" "a"]; ["c" "table" "space"]};
cell2strarr(yyy)
results in a 2 x 5 array.
cell2strarr(yyy, " ")
results in a 2 x 1 array.
Algorithm explaination created using ChatGPT on 2025-08-19 07:16. (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