Matrix indexing and plotting related doubt.

조회 수: 1 (최근 30일)
Anshuman S
Anshuman S 2018년 6월 13일
댓글: Anshuman S 2018년 6월 18일
I am having a 3D matrix with 20 rows (x direction) , 50 cols (y direction) and 187 points ( z direction ,3rd dimension ). I want to view the plane described by x = 3 . i.e the the z-y plane at x= 3.
I have used the syntax
disp(A(3,:,:)) ;
but it's showing the result as (:,:,35115) cols 1 through 50 etc. what I want is the 50 cols with 187 points each .
Also I want to ask that, how can I plot a single column of a 3D matrix. example A(5,4,:) this will be a set of points ( 187 points ) in the z-direction. I want to plot these points only .

답변 (1개)

per isakson
per isakson 2018년 6월 13일
It seems as if you need to use squeeze to get a 2D matrix
mat = zeros( 20, 50, 187 );
len = numel( mat );
mat = reshape( (1:len), size(mat) );
imagesc( squeeze( mat(3,:,:) ) )
disp( squeeze( mat(3,:,:) ) )
See also: Exploring Volumes with Slice Planes in the documentation
  댓글 수: 9
per isakson
per isakson 2018년 6월 16일
편집: per isakson 2018년 6월 16일
Regarding the picture
  • The x-axis is too long; the length is 187 rather than 181. Thus, I suspect the size of C used to produce the picture is not the size that you report, 22x24x181
  • You should take a second look at the code that you used. The values of the plotted variable, mat, are not those of your C. The values are created according to my original example, i.e. (1:len). The picture of my answer didn't show zeros( 20, 50, 187 ). You need to understand the code you use!
  • You didn't try imagesc( squeeze( C(15,:,:) ) ) as I proposed. Thus, I propose you do it now.
Anshuman S
Anshuman S 2018년 6월 18일
Thank you very much !

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

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by