This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Field names of structure, or public fields of COM or Java object


names = fieldnames(s)
names = fieldnames(obj,'-full')


names = fieldnames(s) returns a cell array of character vectors containing the names of the fields in structure s.

names = fieldnames(obj,'-full') returns a cell array of character vectors containing the name, type, attributes, and inheritance of the properties of obj. Only supported for COM or Java® objects.


collapse all

Create a structure array and view its fields.

s(1,1).name = 'alice';
s(1,1).ID = 0;
s(2,1).name = 'gertrude';
s(2,1).ID = 1;

names = fieldnames(s)
names = 2x1 cell array
    {'ID'  }

Create a Java® object and view its public properties.

obj = java.lang.Integer(0);
names = fieldnames(obj,'-full')
names = 5x1 cell array
    {'static final int MIN_VALUE'       }
    {'static final int MAX_VALUE'       }
    {'static final java.lang.Class TYPE'}
    {'static final int SIZE'            }
    {'static final int BYTES'           }

Extended Capabilities

Introduced before R2006a

Was this topic helpful?