How can I generate a plane to use with the SLICE command which is appropriately sized in MATLAB 7.8 (R2009a)?

조회 수: 5 (최근 30일)
I am using the SLICE command to slice my data with a plane at a particular angle. I create a plane and then rotate it (with the ROTATE command) appropriately. However, the resulting plane is too small and I cannot see the volumetric data on the slice.
[x,y,z] = meshgrid(0:0.05:4.5 ,0:0.1:2.3,1:1:3000);
v = x.*exp(-x.^2-y.^2-z/100.^2);
xmin = min(x(:)); ymin = min(y(:));
xmax = max(x(:)); ymax = max(y(:));
hslice = surf(linspace(xmin,xmax,100),...
linspace(ymin,ymax,100),...
zeros(100));
rotate(hslice,[1,0,0],90)
rotate(hslice,[0,0,1],45)
xd = get(hslice,'XData');
yd = get(hslice,'YData');
zd=get(hslice,'ZData');
delete(hslice)
h = slice(x,y,z,v,xd,yd,zd);

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 11월 10일
To avoid issues with the slicing surface's XData, YData and ZData not having a wide enough range for your volumetric data, generate XData, YData and ZData for the slicing surface manually.
For example, if you would like to slice volumetric data with a plane, start by writing an equation for the plane. A plane that is perpendicular to the XY plane and is rotated 45 degrees around the Z axes has a normal vector n=(-1 1 0). The plane is defined by the equation
dot(n,X-p)=0
where X=(x,y,z) is the point that lies on the plane and p=(px,py,pz) is the point that the plane passes through. For the given n=(-1,1,0) and letting the plane passes through the origin (p=(0,0,0)), the equation becomes:
-x+y=0 => y=x
To generate the data for the surface of this plane, create 2D arrays for X and Z (with a particular range) using MESHGRID, then use X and Z to calculate Y (although, as shown above, only X is necessary to calculate Y in this case).
% define the surface of the plane
[xg, zg] = meshgrid(linspace(0, 4.5), linspace(1, 3000));
yg = xg;
% define volumetric data
[x,y,z] = meshgrid(0:0.05:4.5 ,0:0.1:2.3,1:1:3000);
v = x.*exp(-x.^2-y.^2-z/100.^2);
% generate the sliced data
figure
h = slice(x,y,z,v,xg,yg,zg);
set(h,'FaceColor','interp',...
'EdgeColor','none',...
'DiffuseStrength',.8)
axis tight
axis([0 4.5 0. 2.3 1 3000])

추가 답변 (0개)

카테고리

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

제품


릴리스

R2009a

Community Treasure Hunt

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

Start Hunting!

Translated by