필터 지우기
필터 지우기

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 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