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.
- b
- Fields of new struct.
- c (optional)
- Dimension
Outputs
- R
- Resulting struct.
Examples
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
]
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
]