2010-07-13 6 views
0

이것은 수업 과제입니다. 나는 누군가가 나를 도울 수 있기를 희망하는 코드를 작성했다. matlab을 사용하는 타원체

alt text http://i32.tinypic.com/2gw9so3.jpg

내가

% --- 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 

outupt 이미지

당신이 생각하십니까 ... (너무 커서) 아래 링크

http://i26.tinypic.com/6ye1j7.jpg 왼쪽은 파트 A, 그리고 오른쪽 이미지는 타원체를 사용하고를 클릭하십시오 그들이 동일하니?

고맙습니다.

답변

1

네, 그것들은 거의 같습니다.

당신은 첫 번째 타원을 그려 즉 한 후, 같은 축에 모두 타원체를 플로팅하여 테스트 할 수 있습니다, 당신은

[x, y, z] = ellipsoid(0,0,0,2.0,4.0,sqrt(2),20); 
sh = surfl(x, y, z); %# capture the handle, i.e. 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) 

는 이제 (플롯을 회전 circlular 화살표 버튼을 클릭하여 실행 플롯을 드래그하면 두 타원체가 매우 잘 일치 함을 알 수 있습니다. 두 번째 것이 첫 번째 것보다 크면 두 사이에 공백이 생깁니다. 두 번째 것이 첫 번째 것보다 작 으면 첫 번째, 불투명 한 것만 볼 수 있습니다.

관련 문제