cell2strarr

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Artificial Intelligence
Introduced first in SolidGeometry 5.4, Creation date: 2023-12-07, Last change: 2025-09-15

converts string arrays in cell lines into a string array

Description

Flight back from Hefei to Munich

See Also: strarr2cell , stringpatternpermute

Example Illustration

 missing image of cell2strarr(ccc,joinch)

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

stra: stringarray

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

Output

Algorithm Steps

  1. Retrieve the joinch parameter using getfuncparams. If not provided, default to an empty string.
  2. Determine the number of lines, nl, in the input cell list ccc.
  3. Initialize an empty array ni to store the number of elements in each line.
  4. 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.
  5. 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.
  6. 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"]};
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