slice: plot complete slices

조회 수: 1 (최근 30일)
Christoph
Christoph 2017년 8월 16일
댓글: Christoph 2017년 8월 16일
Hi there! I want to use the slice function to plot slices of a volume:
testVol = cat(3,magic(5),magic(5)+3,magic(5)+6);
figure; slice(testVol,[],[],1:3)
Now the result isn't 3 planes of 5 x 5, but instead 3 planes of 4 x 4:
I have tried specifying the coordinates for X, Y and Z like so:
[X,Y,Z] = meshgrid(1:5,1:5,1:3);
figure; slice(X,Y,Z,testVol,[],[],1:3)
But it seems I am not understanding what these coordinates mean. I thought they'd sample the volume at the requested points, but obviously that is not what is happening.
Any help would be much appreciated!
EDIT: I found that this is a problem of surface. So plotting a 2x2 matrix using surface like so:
surface([1 2; 1 2],[1 1; 2 2],[1 1; 1 1],[1 2; 3 1000])
... only gives you back a 1x1 tile, which is entry (1,1), so the top left one (1 in this case). Would still be very happy if someone could show me how to view a 2x2 matrix in surface as a 2x2 matrix!
  댓글 수: 1
Christoph
Christoph 2017년 8월 16일
Ok, I found a dirty fix: Simply padding the volume with NaNs or whatever you feel like putting there in an extra column and extra row (end+1) does the job.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by