Syntax
X=cell2cellarray(A)
Input Parameter
Output Parameter
Examples
S=SGbearing
cell2cellarray({S,S,{S;S}})
Copyright 2020-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 algorithm is designed to flatten a hierarchical cell array into a single-level cell array. It is part of the SolidGeometry library and was introduced in version 5.0.
Input Parameters
- A: A hierarchical cell array that may contain nested cells.
Output Results
- X: A single-level cell array containing all elements from the hierarchical cell array.
Algorithm Steps
- Initialize an empty cell array
X
.
- Check if
A
is not a cell array using ~iscell(A)
:
- If
A
is not a cell, append A
to X
.
- If
A
is a cell array, iterate over each element of A
using a for loop:
- For each element
A{i}
, recursively call cell2cellarray
to flatten it.
- Append the result
Y
to X
.
- Return the flattened cell array
X
.
Example
Given a cell array S=SGbearing
, calling cell2cellarray({S,S,{S;S}})
will return a single-level cell array containing all elements of the nested structure.
Algorithm explaination created using ChatGPT on 2025-08-18 22:28. (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