How do I reorder a 3D matrix in a specific way?
13 views (last 30 days)
Show older comments
I have the following matrix
MeanV(:,:,1) =
1.0000 1.0000
0.8000 0.8000
0.6000 0.6000
MeanV(:,:,2) =
1.0000 5.0000
0.8000 3.0000
0.6000 2.0000
MeanV(:,:,3) =
5.0000 4.0000
3.0000 3.0000
2.0000 1.5000
However I want the matrix to be in the order:
MeanV(:,:,1) =
1.0000 5.0000
1.0000 5.0000
1.0000 4.0000
MeanV(:,:,2) =
0.8000 3.0000
0.8000 3.0000
0.8000 3.0000
MeanV(:,:,3) =
0.6000 2.0000
0.6000 2.0000
0.6000 1.5000
I have tried using the permute function, however I am unable to get the configuration I want.
Thanks
0 Comments
Answers (1)
James Tursa
on 10 Apr 2019
There's got to be a simpler way, but here goes
p = permute(MeanV,[2 1 3]);
result = reshape(cat(3,p(:,1,:),p(:,2,:),p(:,3,:)),3,2,3);
0 Comments
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!