class2cell

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

converts an array of a class into a cell list of the same type



See Also: , arrayof , cell2class , array2cell

Example Illustration

 missing image of class2cell(objs)

Syntax

c=class2cell(objs)

Input Parameter

objs: object array of a class

Output Parameter

c: cell list of the class array

Examples


SGfigure; CPLplotasPS(CPLsample(14)); ps=PSofgca; ps=regions(ps) % array of polyshape
ps, cell2class(class2cell(ps))




Copyright 2018-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, class2cell, is designed to convert an array of objects from a specific class into a cell array where each cell contains one object from the original array. The function is part of the SolidGeometry library and was introduced in version 4.4.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize a cell array c with the same size as the input object array objs.
  2. Iterate over each element in the objs array using a for-loop.
  3. For each iteration, assign the current object from objs to the corresponding cell in c.
  4. Continue this process until all objects have been transferred to the cell array.

Example Usage

The example provided in the comments demonstrates how to use the function in conjunction with other functions from the SolidGeometry library:

SGfigure; 
CPLplotasPS(CPLsample(14)); 
ps = PSofgca; 
ps = regions(ps); % array of polyshape
ps, cell2class(class2cell(ps))

In this example, a polyshape array ps is converted to a cell array using class2cell, and then back to its original form using cell2class.

Algorithm explaination created using ChatGPT on 2025-08-18 22:39. (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