tabulate cell2table

6 vues (au cours des 30 derniers jours)
NA
NA le 25 Oct 2020
Commenté : NA le 26 Oct 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:

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Oct 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 commentaires
Walter Roberson
Walter Roberson le 26 Oct 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 le 26 Oct 2020
Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by