isfield

Returns true if x is a struct and contains the field 'field'.

Syntax

isfield(x, field)

Inputs

x
Any valid input.
Type: double | integer | char | string | logical | struct | cell
Dimension: scalar | string | vector | matrix
field
Name of field.
Type: char | string
Dimension: string

Outputs

R
Logical equivalent true/false.

Example

Simple isfield example.

s.a=5;
s.b='test';
isfield(s,'a')
isfield(s,'b')
isfield(s,'c')
R = 1
R = 1
R = 0