| MATLAB Function Reference | ![]() |
www.kxcad.net Home > CAE Software Index > MATLAB Index >
Field names of structure, or public fields of object
names = fieldnames(s)
names = fieldnames(obj)
names = fieldnames(obj, '-full')
names = fieldnames(s) returns a cell array of strings containing the structure field names associated with the structure s.
names = fieldnames(obj) returns a cell array of strings containing the names of the public data fields associated with obj, which is a MATLAB, COM, or Java object.
names = fieldnames(obj, '-full') returns a cell array of strings containing the name, type, attributes, and inheritance of each field associated with obj, which is a MATLAB, COM, or Java object.
Given the structure
mystr(1,1).name = 'alice'; mystr(1,1).ID = 0; mystr(2,1).name = 'gertrude'; mystr(2,1).ID = 1
the command n = fieldnames(mystr) yields
n =
'name'
'ID'In another example, if f is an object of Java class java.awt.Frame, the command fieldnames(f) lists the properties of f.
f = java.awt.Frame;
fieldnames(f)
ans =
'WIDTH'
'HEIGHT'
'PROPERTIES'
'SOMEBITS'
'FRAMEBITS'
'ALLBITS'
.
.setfield, getfield, isfield, orderfields, rmfield, Using Dynamic Field Names
| fgets (serial) | figure | ![]() |
© 1984-2007 The MathWorks, Inc. Terms of Use Patents Trademarks Acknowledgments