custom reshaping of multidimensional arrays

2 vues (au cours des 30 derniers jours)
AP
AP le 19 Mai 2011
I have a multidimensional array in the form VOLD(X,Y,TIME,Z,VAR) such as VOLD(128,128,25,17,4). How can I reshape the array in the most efficient and MATLAB-friendly way so that it is in the form VNEW(X,Y,Z,VAR,TIME) such as VNEW(128,128,17,4,25)?
There should be a better way than:
VNEW=zeros(128,128,17,4,25);
for i=1:25
for j=1:17
VNEW(:,:,j,1,i)=VOLD(:,:,i,j,1);
VNEW(:,:,j,2,i)=VOLD(:,:,i,j,2);
VNEW(:,:,j,3,i)=VOLD(:,:,i,j,3);
VNEW(:,:,j,4,i)=VOLD(:,:,i,j,4);
end
end
Thank you, Ahmad

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 19 Mai 2011
so?
VNEW = permute(VOLD,[1 2 4 5 3]);

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by