Skip to content

cell2struct

Convert a cell array to a structure with named fields.

s = cell2struct(C, fields, dim)

Creates a structure (or struct array) by treating slices of C along dimension dim as field values. fields is a cell array of field-name strings whose length matches size(C, dim).

cell2struct({1; 'foo'; [3 4]}, {'a', 'b', 'c'}, 1)
% struct with fields a=1, b='foo', c=[3 4]
  • struct2cell — Convert a structure to a cell array.
  • struct — Create a structure with named fields.
  • cell — Information about formatting, location, or contents of a cell.