Documentation

struct2cell

Convert structure to cell array

Syntax

c = struct2cell(s)

Description

c = struct2cell(s)converts them-by-nstructures(withpfields) into ap-by-m-by-ncell arrayc.

If structuresis multidimensional, cell arraychas size[p size(s)].

Examples

The commands

clear s, s.category = 'tree'; s.height = 37.4; s.name = 'birch';

create the structure

s = category: 'tree' height: 37.4000 name: 'birch'

Converting the structure to a cell array,

c = struct2cell(s) c = 'tree' [37.4000] 'birch'

Tips

  • Usefieldnamesto obtain structure field names in the same order asstruct2cellreturns structure values.

Extended Capabilities

Introduced before R2006a

Was this topic helpful?