How to explicit a cell array into a table
Mostra commenti meno recenti
Hi everyone!
I'm trying to create a table with some informations as below:
Dtc=transpose(DTC);
Lamp=transpose(Lamp_config);
Verification=transpose(answer);
T=table(Dtc,Lamp,Verification)

Verification column is a cell array like below:

and I'd like to explicit in the table the (i,j) cells which are like:

Which is the best way to do it?
Thank you so much in advance!!!
4 Commenti
Walter Roberson
il 16 Giu 2022
You have 8 entries for the first and second row but 5 for the third. You cannot have a different number of variables for each row. It would be possible to pad out to a common size and splitvars
Walter Roberson
il 16 Giu 2022
By the way, would it make sense to switch those columns to categorical or string()?
Pas182
il 16 Giu 2022
Pas182
il 17 Giu 2022
Risposte (1)
Walter Roberson
il 19 Giu 2022
vlens = cellfun(@length, T.Verification);
maxvlen = max(vlens);
T.Verification = cellfun(@(C) [C;strings(maxveln-length(C),1)].', T.Verification, 'uniform', 0);
T = splitvars(T);
2 Commenti
Walter Roberson
il 23 Giu 2022
T.Verification = cellfun(@(C) [C, strings(1,maxveln-length(C))].', T.Verification, 'uniform', 0);
Categorie
Scopri di più su Structures in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
