Copy data from cell array to table

53 次查看(过去 30 天)
I am having a 1x12 cell array, that contains different data:
1×12 cell array
Columns 1 through 7
{18977×1 string} {18977×1 string} {18977×1 string} {18977×1 double} {18977×1 double} {18977×1 double} {18977×1 double}
Columns 8 through 12
{18977×1 double} {18977×1 double} {18977×1 double} {18977×1 double} {18977×1 string}
I want to convert it into a table so that I can select complete rows or plot a column. But the command
t = array2table(dataArray);
t2 = cell2table(dataArray);
still leave me with a 1x12 table instead ot the wanted 18977x12 table. What am I doing wrong ?

采纳的回答

Adam Danz
Adam Danz 2019-2-19
编辑:Adam Danz 2019-2-24
Here are some fake data that look similar to yours.
A = {string(rand(18977,1)), rand(18977,1), rand(18977,1), rand(18977,1)};
And here's how to put those data into a table (assuming all elements of the cell array have the same number of rows).
table(A{:}) %use the 'VariableNames' option to add headers
If vectors are not of equal length, use padarray().

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by