Switch elements of the 2nd and 3d dimension in 3D matrix
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Consider a 3D array of dimensions i X j X k in the form:

Which is formed by repeating the i X j matrix for k times. I would like to switch the elements without using a loop to have a new iXkXj matrix of the form:

0 Kommentare
Akzeptierte Antwort
michio
am 11 Sep. 2016
Have you tried permute function? http://www.mathworks.com/help/matlab/ref/permute.html I am guessing
B = permute(A,[1,3,2])
would do the job, where A is your original 3D matrix.
1 Kommentar
Philippa
am 6 Dez. 2024
B = permute(A, [3,2,1]) according to the image result you shared.
but
B = permute(A,[1,3,2]) according to what you need for a i x k x j matrix
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices 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!