cell2mat not working
21 ビュー (過去 30 日間)
古いコメントを表示
I have got a cell(198x1) and i try to convert the cell in to a matrix but cell2mat doesen't work.
0 件のコメント
回答 (2 件)
Voss
2024 年 2 月 8 日
If the contents of the cells cannot be concatenated into a matrix, then you'll get an error telling you so.
For example:
C = {[1 2]; 3}
cell2mat(C)
Is that the error you got?
2 件のコメント
Walter Roberson
2024 年 2 月 12 日
Please show the output of
temp = cellfun(@size, YourCell(:), 'uniform', 0);
maxlen = max(cellfun(@length, temp));
sizes = cell2mat(cellfun(@(V) [V ones(1,maxlen - length(V))], temp, 'uniform', 0));
unique_sizes = unique(sizes, 'row')
Walter Roberson
2024 年 2 月 8 日
If the cell contents are not numeric, then cell2mat() might refuse. In such a case, you can try
As_Matrix = cat(1, TheCell{:});
if you want to end up with a 198 x something array.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!