| MATLAB Function Reference | Search  Help Desk |
| cell2struct | Examples See Also |
Cell array to structure array conversion
s = cell2struct(c,fields,dim)
s = cell2struct(c,fields,dim)
converts the cell array c into the structure s by folding the dimension dim of c into fields of s. The length of c along the specified dimension (size(c,dim)) must match the number of fields names in fields. Argument fields can be a character array or a cell array of strings.
c = {'tree',37.4,'birch'};
f = {'category','height','name'};
s = cell2struct(c,f,2)
s =
category: 'tree'
height: 37.4000
name: 'birch'
fieldnames Field names of a structure
struct2cell Structure to cell array conversion