[TOC]

isfield

Determine if a structure array contains a given field

Usage

isfield(S, field)

Difference with MATLAB

MATLABSIMO
field can be a cell array, so that it allows checking multiple field names.Cell array not supported.
field can be a stringString not supported. Use character vector instead.

Examples

Input
structure.field = 3
isfield(structure, 'field')
isfield(structure, 'not_a_field')
Output
structure =
 struct with fields:
 field: [3.0000]

ans = 
1

ans = 
0
Input
s.ss = struct('field', 1)
isfield(s, 'ss')
isfield(s.ss, 'field')
Output
s =
 struct with fields:
 ss: Struct [1 x 1]

ans = 
1

ans = 
1