custom reshaping of multidimensional arrays

4 Ansichten (letzte 30 Tage)
AP
AP am 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

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by