orderfields
Reorder fields of a structure.
Syntax
Section titled “Syntax”s = orderfields(s)s = orderfields(s1, s2)s = orderfields(s, order)Description
Section titled “Description”Returns s with its fields reordered. With one argument, sorts alphabetically. With a second order argument (a cell array of field names or a permutation vector), uses the specified order. With a struct s2 argument, matches s2’s field order.
Examples
Section titled “Examples”s.b = 1; s.a = 2; s.c = 3;orderfields(s) % fields now a, b, corderfields(s, {'c', 'a', 'b'})See also
Section titled “See also”fieldnames— List of field names in a structure.struct— Create a structure with named fields.