How to explicit a cell array into a table
1 回表示 (過去 30 日間)
古いコメントを表示
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1034525/image.png)
Verification column is a cell array like below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1034530/image.png)
and I'd like to explicit in the table the (i,j) cells which are like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1034535/image.png)
Which is the best way to do it?
Thank you so much in advance!!!
回答 (1 件)
Walter Roberson
2022 年 6 月 19 日
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 件のコメント
Walter Roberson
2022 年 6 月 23 日
T.Verification = cellfun(@(C) [C, strings(1,maxveln-length(C))].', T.Verification, 'uniform', 0);
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!