save a columnefrom a table in a cell array in matlab

Assuming you have a table T with a column called columnName, you can extract the column data and store it in a cell array C like this:

main.m
C = table2cell(T(:, 'columnName'));
36 chars
2 lines

This will create a cell array C with the same number of rows as T.columnName and one column.

If you want to exclude any rows with missing data, you can use the rmmissing function:

main.m
C = table2cell(rmmissing(T(:, 'columnName')));
47 chars
2 lines

This will remove any row with missing values in the columnName column before storing the data in the cell array.

related categories

gistlibby LogSnag