How do I reorder a 3D matrix in a specific way?

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

Answers (1)

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);

Products

Release

R2017b

Asked:

on 10 Apr 2019

Answered:

on 10 Apr 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!