SGaddfields

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 5.0, Creation date: 2020-09-06, Last change: 2025-09-14

adds field of a field name list to all elements of a solid geometry



See Also: SGaddfields , SGfieldnames , SGcell2array

Example Illustration

 missing image of SGaddfields(SG,FNN)

Syntax

SGN=SGaddfields(SG,FNN)

Input Parameter

SG: Solid Geometry
FNN: cell list of all field names similar to fieldnames

Output Parameter

SGN: New solid with all elements have the

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, SGaddfields, is designed to add fields to elements of a solid geometry structure. It takes two input parameters:

The output is:

The algorithm works as follows:

  1. Check if SG is a cell array. If true, iterate over each element in SG and recursively call SGaddfields for each element, storing the result in SGN.
  2. If SG is a structure, determine the number of elements n in SG.
  3. If n is greater than 1, iterate over each element and recursively call SGaddfields for each element, storing the result in SGN.
  4. If n is 1, perform the following steps:
  5. If SG is neither a cell array nor a structure, display the variable information using whos and issue a warning indicating the input is unclear.

This function is part of the SG-Library and was introduced in SolidGeometry 5.0. It is useful for ensuring that all elements of a solid geometry have a consistent set of fields, which can be important for subsequent processing or analysis.

Algorithm explaination created using ChatGPT on 2025-08-19 00:31. (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