To turn a row in a timetable into a column in MATLAB, you can use transpose and indexing, as well as cell arrays if you want to preserve the variable names. Here is an example:
main.m648 chars14 lines
In this example, timetable1
is a 3-by-3 timetable with row names and variable names. columnData
is the transposed version of timetable1
. To access the desired row, you can use indexing with Var1
, which corresponds to row 1 after transposing. The result desiredRow
is a column vector.
Alternatively, if you want to preserve the variable names, you can convert columnData
to a cell array using table2cell
, and then access the desired column using {}
indexing. The result desiredRowCell
is also a column vector, but with a cell array data type.
gistlibby LogSnag