This is a class assignment. I had written some codes which I hope someone can help me.
This is the code that I have
% --- 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
The second way to do it is using ellipsoid comment which is the second part of this problem.
[x, y, z] = ellipsoid(0,0,0,2.0,4.0,sqrt(2),20);
surfl(x, y, z)
colormap copper
axis equal
The outupt image please click on the link below (too big)
http://i26.tinypic.com/6ye1j7.jpg The left side is Part a, and right image is using ellipsoid...
Do you think they are the same?
Thank you