Create a Matrix from different ccella array.
古いコメントを表示
I have a cell array "data" 1x3 cell, each cell having different number of elements with 4 columns. for example data= [13252*4 double];[1516*4] double;[1244*4]double.
Now, I need a matrix which has maximum number of columns equal to 12 (sum of single columns) and rows equal to the maximum number of columns of all the cells. and I want to insert Nan when there is not value.
Thank you so much!!!
採用された回答
その他の回答 (1 件)
madhan ravi
2020 年 7 月 24 日
編集済み: madhan ravi
2020 年 7 月 24 日
m = cellfun(@size, data, 'un', 0);
M = max(cat(1, m{:}));
Data = cellfun(@(x) [x; nan(M(1) - size(x, 1), M(2))], data, 'un', 0)
9 件のコメント
Fredic
2020 年 7 月 24 日
madhan ravi
2020 年 7 月 24 日
13252 Is the maximum value
Fredic
2020 年 7 月 24 日
Fredic
2020 年 7 月 24 日
madhan ravi
2020 年 7 月 24 日
編集済み: madhan ravi
2020 年 7 月 24 日
My answer gives you the desired result. You have some problems in copying.
Fredic
2020 年 7 月 24 日
madhan ravi
2020 年 7 月 24 日
You just wanted to use loop, ain’t it?
Fredic
2020 年 7 月 24 日
madhan ravi
2020 年 7 月 24 日
Lol
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
