cell2array

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 2.1, Creation date: 2014-12-30, Last change: 2025-09-14

returns an nxm array from a nxk cell; m=max(size(C{:}))

Description

Simple function that may be obsolete because of cell2mat

See Also: , cellstrfind

Example Illustration

 missing image of cell2array(C)

Syntax

A=cell2array(C)

Input Parameter

C: cell array of number rows of different length

Output Parameter

A: Array with constant number of columns, NaN




Copyright 2014-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, cell2array, is designed to convert a cell array with rows of varying lengths into a 2D array with a consistent number of columns. The function is part of the SolidGeometry library and was introduced in version 2.1. It may be considered obsolete due to the existence of cell2mat.

Input Parameters

Output Results

Algorithm Steps

  1. Determine the number of rows, n, in the cell array C using size(C,1).
  2. Initialize a variable m to zero. This will store the maximum row length found in C.
  3. Iterate over each row i in C to find the maximum row length:
    • For each row C{i}, determine its length k using size(C{i},1).
    • Update m to be the maximum of its current value and k.
  4. Create an n by m array A filled with NaN using nan(n,m).
  5. Iterate over each row i in C again to populate A:
    • Determine the length k of the current row C{i}.
    • If k is greater than zero, copy the elements of C{i} into the first k columns of the i-th row of A.
Algorithm explaination created using ChatGPT on 2025-08-18 22:51. (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