struct

Creates one or more structs with the specified fields and value(s) .

Syntax

R = struct(x1,y1,x2,y2,.....)

Inputs

x1
Field name for the resultant struct.
Type: char | string
Dimension: string
y1
Value(s) of x1. If the value in not a single element, then it must be a cell containing the individual values. All value elements (y1, y2, ...) must have the same dimension.
Type: double | integer | char | string | logical | struct | cell
Dimension: scalar | vector | matrix

Outputs

R
Resultant struct array.

Examples

Single struct example:
R = struct('foo', 1)
R = struct [
foo: 1
]
Struct array example:
R = struct('foo', {1,2,3}, 'bar', {'a','b','c'})
R = struct [
Struct array of size 1 x 3 with fields:
bar
foo
]