isfieldDetermine if a structure array contains a given field
isfield(S, field)S is a structure array of any size.field is a vector of characters representing a field name.S contains a field named field. Otherwise, it returns a logical 0.| MATLAB | SIMO |
|---|---|
field can be a cell array, so that it allows checking multiple field names. | Cell array not supported. |
field can be a string | String not supported. Use character vector instead. |
structure.field = 3
isfield(structure, 'field')
isfield(structure, 'not_a_field')
structure =
struct with fields:
field: [3.0000]
ans =
1
ans =
0
s is a structure with the field ss, and ss is a structure with the field field.s.ss = struct('field', 1)
isfield(s, 'ss')
isfield(s.ss, 'field')
s =
struct with fields:
ss: Struct [1 x 1]
ans =
1
ans =
1