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 Center および File ExchangeVolume Visualization についてさらに検索

製品


リリース

R2009a

Community Treasure Hunt

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

Start Hunting!

Translated by