Syntax
FN=SGfieldnames([SG])
Input Parameter
Output Parameter
FN : | | Names of fields of the different SG structs and cells |
Examples
loadweb JACO_robot.mat; A=JACO
B=SGbox
loadweb ADAM_C.mat; C=ADAM_C
FN=SGfieldnames({A,B,C})
SGaddfields({A,B,C},FN)
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 function, SGfieldnames
, is designed to collect all field names from different Solid Geometries (SG) provided as input. It processes both struct and cell array inputs to ensure that all field names are identified and returned as a unique list.
Input Parameters
- SG: This represents the Solid Geometry input, which can be a struct or a cell array of structs.
Output Results
- FN: A list of unique field names from the different SG structs and cells.
Algorithm Steps
- Initialize an empty array
FN
to store field names.
- Iterate over each input argument using a loop from 1 to
nargin
(number of input arguments).
- For each input
SGi
:
- If
SGi
is a struct, retrieve its field names using fieldnames(SGi)
and store them in FNi
.
- If
SGi
is a cell, recursively call SGfieldnames
on its contents using SGfieldnames(SGi{:})
to get field names.
- Append the field names
FNi
to the array FN
.
- After processing all inputs, use
unique(FN, 'stable')
to remove duplicate field names while preserving the order.
- Return the unique list of field names
FN
.
Algorithm explaination created using ChatGPT on 2025-08-19 07:05. (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