Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

struct2cell

Convert structure to cell array

Syntax

c = struct2cell(s)

Description

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)].

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'

More About

collapse all

Tips

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

Introduced before R2006a

Was this topic helpful?