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.
slice: plot complete slices
1 view (last 30 days)
Show older comments
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166724/image.png)
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!
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!