This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

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.


Convert structure to cell array


c = struct2cell(s)


c = struct2cell(s) converts the m-by-n structure s (with p fields) into a p-by-m-by-n cell array c.

If structure s is multidimensional, cell array c has size [p size(s)].


The commands

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

create the structure

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

Converting the structure to a cell array,

c = struct2cell(s)

c = 


  • Use fieldnames to obtain structure field names in the same order as struct2cell returns structure values.

Extended Capabilities

Introduced before R2006a

Was this topic helpful?