Skip to content

isfield

Test whether a structure contains a named field.

tf = isfield(s, fieldname)

Returns true if s is a structure containing a field named fieldname. With a cell array of field names, returns a logical array — one element per name.

s.x = 1;
isfield(s, 'x') % 1
isfield(s, {'x', 'y'}) % [1 0]
  • fieldnames — List of field names in a structure.
  • isstruct — Test whether the input is a structure.