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

2 ビュー (過去 30 日間)
Jose Andrés
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.
Please, could you help me?
Thank you so much.

採用された回答

Matz Johansson Bergström
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
Roger Stafford 2015 年 1 月 23 日
Use matlab's 'squeeze' function to eliminate the singleton dimension(s).

Jose Andrés
Jose Andrés 2015 年 3 月 31 日
Thank you both of you!

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by