custom reshaping of multidimensional arrays

1 回表示 (過去 30 日間)
AP
AP 2011 年 5 月 19 日
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 Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by