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.

Order fields of structure array

`S = orderfields(S1)`

`S = orderfields(S1,S2)`

`S = orderfields(S1,C)`

`S = orderfields(S1,P)`

`[S,Pout] = orderfields(___)`

matches the order specified by the permutation vector `S`

= orderfields(`S1`

,`P`

)`P`

.

If `S1`

has `n`

fields, then the elements of
`P`

are the integers from `1`

through
`n`

, arranged in any order. For example, if `S1`

has
three fields and `P`

is `[3 1 2]`

, then the third field of
`S1`

is the first field of the output `S`

. This syntax
is useful for ordering multiple structure arrays in the same way.

The

`orderfields`

function only orders top-level fields. It is not recursive.

`cell2struct`

| `fieldnames`

| `getfield`

| `isfield`

| `rmfield`

| `setfield`

| `struct`

| `struct2cell`