How to create 3D array out of multiple 2D arrays of different dimensions?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Bjorn Gustavsson
il 8 Gen 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 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!