Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Field of structure array

`value = getfield(S,field)`

`value = getfield(S,field1,...,fieldN)`

`value = getfield(S,idx,field1,...,fieldN)`

`value = getfield(S,idx,field1,idx1,...,fieldN,idxN)`

`value = getfield(`

returns the value in the specified field of the structure `S`

,`field`

)`S`

. For
example, if `S.a = 1`

, then `getfield(S,'a')`

returns `1`

.

As an alternative to `getfield`

, use dot notation, ```
value
= S.field
```

. Dot notation is typically more efficient.

If `S`

is nonscalar, then `getfield`

returns
the value in the first element of the array, equivalent to
`S(1).field`

.

`fieldnames`

| `isfield`

| `orderfields`

| `rmfield`

| `setfield`

| `struct`