custom reshaping of multidimensional arrays

1 次查看(过去 30 天)
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

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by