# isfield

Determine if input is structure array field

## Syntax

``TF = isfield(S,field)``

## Description

example

````TF = isfield(S,field)` returns `1` if `field` is the name of a field of the structure array `S`. Otherwise, it returns `0`.If `field` is an array that contains multiple names and `S` is a structure array, then `TF` is a logical array that has the same size.If `S` is not a structure array, then `isfield` returns `0`.```

## Examples

collapse all

Create a structure.

```S.x = linspace(0,2*pi); S.y = sin(S.x); S.title = 'y = sin(x)'```
```S = struct with fields: x: [0 0.0635 0.1269 0.1904 0.2539 0.3173 0.3808 0.4443 0.5077 ... ] y: [0 0.0634 0.1266 0.1893 0.2511 0.3120 0.3717 0.4298 0.4862 ... ] title: 'y = sin(x)' ```

Determine if `'title'` is the name of a field of `S`.

`TF = isfield(S,'title')`
```TF = logical 1 ```

You can test multiple names in one call to the `isfield` function by specifying them in a cell array or string array.

```field = {'x','y','z','title','error'}; TF = isfield(S,field)```
```TF = 1x5 logical array 1 1 0 1 0 ```

## Input Arguments

collapse all

Structure array.

Potential field names, specified as a character vector, cell array of character vectors, or string array.

## Tips

• If the input argument `S` is an object, then `isfield` always returns `0`, even when `field` is the name of a property.

To determine if a name is the name of a property of an object, use the `isprop` function.