How to create 3D array out of multiple 2D arrays of different dimensions?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Bjorn Gustavsson
am 8 Jan. 2021
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 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!