MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   使用Matlab的椭球 (https://www.labfans.com/bbs/showthread.php?t=23684)

poster 2019-12-10 20:41

使用Matlab的椭球
 
这是一个课堂作业。我写了一些代码,希望有人能帮助我。

[URL="https://i.stack.imgur.com/T2uNe.png"][IMG]https://i.stack.imgur.com/T2uNe.png[/IMG][/URL]

这是我的代码

% --- This is optional to verify whether my parametrization is consistent with the % --- original equation % syms xyzpt % ellipsoid=[2*sin(p)*cos(t),4*sin(t)*sin(p),sqrt(2)*cos(p)] % simplify(subs((x^2/4)+(y^2/16)+(z^2/2),[x,y,z],ellipsoid)) % --- END t=linspace(-2,2*pi,20); s=linspace(0,pi/2,20); [st]=meshgrid(s,t); x=2*cos(t).*sin(s); y=4.*sin(s).*sin(t); z=sqrt(2).*cos(s); surf(x,y,z); grid on; xlabel('x');ylabel('y');zlabel('z'); axis equal hold on; % I think this is how we draw the lower half of the ellipsoid using -sqrt(2) t=linspace(-2,2*pi,20); s=linspace(0,pi/2,20); [st]=meshgrid(s,t); x=-2.*cos(t).*sin(s); y=-4.*sin(s).*sin(t); z=-sqrt(2).*cos(s); surf(x,y,z) axis equal 第二种方法是使用椭球注释,这是此问题的第二部分。

[x, y, z] = ellipsoid(0,0,0,2.0,4.0,sqrt(2),20); surfl(x, y, z) colormap copper axis equal 输出图像,请点击下面的链接(太大)

[URL]http://i26.tinypic.com/6ye1j7.jpg[/URL]左边是a部分,右边是椭圆形...

你认为他们是一样的吗?

谢谢



[B]回答:[/B]

是的,它们几乎相同。

您可以通过在同一轴上绘制两个椭圆体来测试它,即在绘制第一个椭圆体之后,运行

[x, y, z] = ellipsoid(0,0,0,2.0,4.0,sqrt(2),20); sh = surfl(x, y, z); %# capture the handle, ie the unique identifier, of the surface %# set color to gray, make mostly transparent set(sh,'FaceColor',[0.5,0.5,0.5],'FaceAlpha',0.5) 现在,您可以旋转绘图(单击带有圆形箭头的按钮,然后拖动绘图),您会看到两个椭圆形重合得很好。如果第二个大于第一个,则您会在两者之间看到一个空格;如果第二个小于第一个,则只会看到第一个不透明的。



[url=https://stackoverflow.com/questions/3233362]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 01:02

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.