How can I get different 2D Matrices from a 3D matrix?

조회 수: 2 (최근 30일)
Jose Andrés . 2015년 1월 23일
답변: Jose Andrés . 2015년 3월 31일
Hi everyone, I have looked for someone with my same question but I haven't found nothing so specific.
I have a 3D matrix ( m x n x z ) and I want to get from that Matrix, the 2D matrices m x z and n x z. I am working with 3D medical images and I need different views of my patient, and I haven´t any problem to get the m x n matrix with this code:
for z=1:length(z)
figure;
imshow (A (:,:,z))
end
but if I do the same with the other variables, my resultant matrix is still a 3D matrix and I can't show it with the "imshow" function.
Thank you so much.

댓글을 달려면 로그인하십시오.

채택된 답변

Matz Johansson Bergström 2015년 1월 23일
편집: Matz Johansson Bergström 님. 2015년 1월 23일
The size of the A(1,:,:) will be a 1-by-n-by-z matrix, so you have to temporarily store it in a 2d matrix
tmp(:,:) = A(1,:,:);
size(tmp)

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Roger Stafford 2015년 1월 23일
Use matlab's 'squeeze' function to eliminate the singleton dimension(s).
댓글 수: 0이전 댓글 -1개 표시이전 댓글 -1개 숨기기

댓글을 달려면 로그인하십시오.

Jose Andrés 2015년 3월 31일
Thank you both of you!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by