fieldnames
Return structure field names or public classdef property names.
📝Syntax
names = fieldnames(st)
names = fieldnames(obj)
names = fieldnames(objArray)
📥Input Arguments
Parameter Description
st a structure
obj a classdef object or handle object
objArray a classdef object array or handle array
📤Output Arguments
Parameter Description
names a cell of strings
📄Description

fieldnames(st) returns a cell of strings with the field names of the input structure.

For classdef objects, fieldnames(obj) returns the same public property names as properties(obj).

For classdef object arrays, the returned names are the public properties of the array element class.

💡Examples
List public property names of a classdef object array.
clear classes
d = [tempdir(), 'nelson_help_fieldnames/'];
mkdir(d);
filewrite([d, '/NelsonHelpFieldPoint.m'], ["classdef NelsonHelpFieldPoint"; "  properties"; "    X = 0"; "    Y = 0"; "  end"; "end"]);
addpath(d);
a = NelsonHelpFieldPoint();
b = NelsonHelpFieldPoint();
names = fieldnames([a, b])
🔗See Also
getfieldpropertiesclassdef
🕔Version History
Version Description
1.0.0 initial version
2.0.0 classdef object support added
Edit this page on GitHub