FUNCTION REFERENCE

struct2table

Table from a struct array or a scalar struct.

Table from a struct array or a scalar struct.

Syntax

T = struct2table(S)

Syntax

T = struct2table(S, 'VariableNames', names, 'RowNames', rows)

For a struct vector each field becomes a variable with one row per element (numeric or logical scalars of one class join into a column, other values form a cell column). For a scalar struct each field is one variable taken as it is, so all fields need the same number of rows.

Example

S = struct('a', {1, 2}, 'b', {'x', 'y'}); T = struct2table(S); T.a   % [1; 2]

Example

s.a = [1; 2]; s.b = [3; 4]; T = struct2table(s)   % 2x2 table

Differences from MATLAB: No 'AsArray' option.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.