Switch elements of the 2nd and 3d dimension in 3D matrix
8 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
michio
on 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 Comment
Philippa
on 6 Dec 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
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!