cell2struct

Converts the cell a to a struct. The number of fields b must match number of dimensions c.

Syntax

cell2struct(a,b,c)

Inputs

a
Cell to be converted.
Type: double | integer | char | string | logical | struct | cell
Dimension: scalar | vector | matrix
b
Fields of new struct.
Type: char | string
Dimension: scalar | vector | matrix
c (optional)
Dimension
Type: integer
Dimension: scalar

Outputs

R
Resulting struct.

Examples

Without dimension:
b = {[1,2,3], 4; 'hello', 2+i};
R = cell2struct(b, {'a','b'}); % split by columnns
R1 = R(1)
R2 = R(2)
R1 = struct [
a: [Matrix] 1 x 3
1  2  3
b: hello
]
R2 = struct [
a: 4
b: 2 + 1i
]
With dimension:
b = {[1,2,3], 4; 'hello', 2+i};
R = cell2struct(b, {'a','b'}, 2); % split by rows
R1 = R(1)
R2 = R(2)
R1 = struct [
a: [Matrix] 1 x 3
1  2  3
b: 4
]
R2 = struct [
a: hello
b: 2 + 1i
]