table2array
Converts a table to a single homogeneous array.
Category: Language Fundamentals > Data Types
Syntax
A = table2array(T)
Concatenates the variables of T horizontally.
Description
The result has the class of the combined data, so a table of doubles gives a double matrix. Mixing types follows the rules of concatenation, and variables that cannot be combined (for instance a numeric column with a cell column) cause an error. For mixed content, use table2cell.
It is equivalent to the brace syntax T{:,:}.
Input arguments
T- Table whose variables can be concatenated: for example all numeric.
Output arguments
A- Array with the same number of rows as
Tand one column for each variable column.
Example
Table to matrix
T = table([1;2], [3;4]);
A = table2array(T)
class(A)
Output
A = 2×2
1 3
2 4
ans = 'double'