【发布时间】:2019-08-02 07:03:57
【问题描述】:
这是一个课堂作业。我写了一些代码,希望有人能帮助我。
这是我的代码
% --- This is optional to verify whether my parametrization is consistent with the
% --- original equation
% syms x y z p t
% 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);
[s t]=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);
[s t]=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
输出图片请点击下方链接(太大)
http://i26.tinypic.com/6ye1j7.jpg 左边是Part a,右边是使用椭球...
你认为它们是一样的吗?
谢谢
【问题讨论】:
标签: matlab