Reshape n-th dimension of an array

2 ビュー (過去 30 日間)
zdarova_koresh
zdarova_koresh 2020 年 8 月 7 日
コメント済み: zdarova_koresh 2020 年 8 月 7 日
I have an 285x51xn array. I need to reshape it in 3rd (n) dimension. Essentialy, I want to rotate all layers of 285x51 matrix 90 degrees and flip them upside down and then save as 285x51xn array.
I have written the following code but it gives an error that dimensions mismath. I feel there is a problem with indexing.
for k = 1:length(test(1, 1, :))
test(:,:,k)=rot90(test(:,:,k));
test(:,:,k)=flipud(test(:,:,k))
end
Please, correct me.

採用された回答

Bruno Luong
Bruno Luong 2020 年 8 月 7 日
編集済み: Bruno Luong 2020 年 8 月 7 日
You operation makes the array changing its size, you can't use for-loop to store the rotated page in the SAME arrray.
And btw fllipupd(rot90(...)) is simply exchange the first 2 dimensions
test = permute(test,[2 1 3]);
  1 件のコメント
zdarova_koresh
zdarova_koresh 2020 年 8 月 7 日
Brilliantly! I have not even noticed it.

サインインしてコメントする。

その他の回答 (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