stripfields

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.5, Creation date: 2019-02-25, Last change: 2025-09-14

removes a list of fields from a struct



See Also: retainfields

Example Illustration

 missing image of stripfields(S,Fieldnames)

Syntax

S=stripfields(S,[Fieldnames])

Input Parameter

S: struct
Fieldnames: List of field names as varargin

Output Parameter

S: struct with removed fields

Examples


S.A=1; S.B=2; S.C=3; S.D=4
stripfields(S,'A','C','B')
retainfields(S,'A','C','B')




Copyright 2019-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 a MATLAB function named stripfields that removes specified fields from a given structure. It is part of the SolidGeometry library, version 4.5, and was created by Tim Lueth in 2019.

Input Parameters

Output

Algorithm Steps

  1. The function begins by determining the number of input arguments minus one, which represents the number of field names to be removed. This is stored in the variable n.
  2. The list of field names to be removed is stored in the variable L, which is derived from varargin.
  3. A loop iterates over each field name in L:
  4. The modified structure S is returned as the output.

Example

Consider a structure S with fields A, B, C, and D:

S.A = 1; S.B = 2; S.C = 3; S.D = 4;

Calling stripfields(S, 'A', 'C', 'B') will remove fields A, C, and B from S.

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