tabulate cell2table

14 visualizzazioni (ultimi 30 giorni)
NA
NA il 25 Ott 2020
Commentato: NA il 26 Ott 2020
I have a ‘group_belong’ like this:
The group_belong{2} is:
The group_belong{4} is:
I use the below code to remove empty cell and put the remain one vertically.
group_belong = group_belong(~cellfun('isempty',group_belong));
group_belong = vertcat(group_belong{:});
Then, I convert this cell array to table and put the variable name.
T = cell2table(group_belong,'VariableNames',{'A' 'B' 'C' 'D' 'E' 'I' 'R' 'T'});
But I got this result:
I do not know how to fix column 3 to this:

Risposta accettata

Walter Roberson
Walter Roberson il 25 Ott 2020
Your C variable in your table is probably already stored the way you want. It is the variable browser that is displaying separate columns, but T.C would be a 3 x 3 array [1 2 5;2 4 5; 2 4 5]
It is possible to get the kind of display you ask for out of the variable browser: it would show up like that if each row of T.C were a cell array. cell2table() does not create those kinds of entries automatically if all of the rows are the same size (like your column 3) but does if the rows are not all the same size (like your column 8).
I could suggest various ways to deliberately cause cells the same size to be stored as cells, but it strikes me that the easiest way might be to add an empty cell row onto the bottom of the input data, create the table, and then remove the last row.
  3 Commenti
Walter Roberson
Walter Roberson il 26 Ott 2020
If you know ahead of time which variables you want to become cells then when you do
group_belong(end,:) = {[]};
instead do
group_belong(end,[those column numbers]) = {[]};
NA
NA il 26 Ott 2020
Thank you.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by