struct2cell
Convert structure to cell array
Syntax
c = struct2cell(s)
Description
c = struct2cell(s)
converts them
-by-n
structures
(withp
fields) into ap
-by-m
-by-n
cell arrayc
.
If structures
is multidimensional, cell arrayc
has 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
Use
fieldnames
to obtain structure field names in the same order asstruct2cell
returns structure values.
Extended Capabilities
Introduced before R2006a
Was this topic helpful?