How to create 3D array out of multiple 2D arrays of different dimensions?
3 ビュー (過去 30 日間)
古いコメントを表示
I have multiple 2D arrays say 34x10, 34x13, 34x15. I want to combine these and create a 3D array of size 34x15x3 where additional elements for 34x10 and 34x13 to reach 34x15 can be zeros.
Thank you in advance
0 件のコメント
回答 (1 件)
Bjorn Gustavsson
2021 年 1 月 8 日
Something like this ought to work:
M2Dall = {m1,m2,m3,mN}; % Puting all matrices into one cell-array.
for i3 = numel(M2Dall):-1:1
M3D(1:size(M2Dall{i3},1),1:size(M2Dall{i3},2),i3) = M2Dall{i3};
end
HTH
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!