| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
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 field names for obj. If obj is a MATLAB object, then return value names contains the names of the fields in that object. If obj is an object of the Java programming language, then names contains the names of the public fields. MATLAB objects may override fieldnames and define their own behavior.
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 COM or Java object. Note that fieldnames does not support the –full option for MATLAB objects.
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 i is an object of Java class java.awt.Integer, the command fieldnames(i) lists the properties of i.
i = java.lang.Integer(0); fieldnames(i)
MATLAB displays:
ans =
'MIN_VALUE'
'MAX_VALUE'
'TYPE'
'SIZE'setfield, getfield, isfield, orderfields, rmfield, dynamic field names
![]() | fgets (serial) | figure | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |