Skip to content

fieldnames

List of field names in a structure.

names = fieldnames(s)
names = fieldnames(s, full)

Returns a cell array of field-name strings for the structure s. With full = true, includes inherited fields when s is an object instance.

s.a = 1; s.b = 'foo';
fieldnames(s) % {'a'; 'b'}
  • struct — Create a structure with named fields.
  • isfield — Test whether a structure contains a named field.
  • getfield — Get the value of a structure field by name.