필터 지우기
필터 지우기

how do you graph z=sqrt(9-r​^2cos^2(th​eta))?

조회 수: 6 (최근 30일)
Carter Pennington
Carter Pennington 2018년 12월 5일
답변: Carlos Guerrero García 2022년 11월 30일
syms x y z;
[x,y,]=meshgrid(-10:1:10);
z = abs(sqrt(9-r.^2*cos.^2(theta)));
surf (r,theta,z);
ylim([-1,2]);
xlabel('x');
ylabel('y');
zlabel('z');
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 12월 5일
편집: Walter Roberson 2018년 12월 5일
You have not defined r or theta.
The syms is not doing anything for you there.
If you need to convert x y coordinates to polar coordinates then see cart2pol()
Carter Pennington
Carter Pennington 2018년 12월 5일
[theta,r] = cart2pol(x,y);
[theta,r]=meshgrid(-10:1:10);
z = abs(sqrt(9-r.^2*cos.^2(theta)));
surf (theta,r);
?????

댓글을 달려면 로그인하십시오.

답변 (2개)

Aoi Midori
Aoi Midori 2018년 12월 5일
편집: Aoi Midori 2018년 12월 5일
z = 3 when r = 0:
[r]=meshgrid(0:0.1:6.28);
[theta]=meshgrid(0:0.1:2*pi);
z = abs( sqrt( 9 - (r.^2 .* cos(theta').^2 ) ) );
surf (r,theta',z);
xlabel('r');
ylabel('theta');
zlabel('z');

Carlos Guerrero García
Carlos Guerrero García 2022년 11월 30일
I think that Carter Pennington was talking about the parametrized surface
x=r*cos(theta)
y=r*sin(theta)
z=sqrt(9-r^2*(cos(theta))^2)
with 0<=theta<=2pi and 0<=r<=3 (for real values of z)
In consecuence, I will plot the graph in the sentence with the followng lines:
[r,theta]=meshgrid(0:0.1:3,0:pi/60:2*pi); % In the supposed range
x=r.*cos(theta); % The classical definitons of the
y=r.*sin(theta); % polar coordinates for "x" and "y"
z=sqrt(9-r.^2.*(cos(theta)).^2); % The condition in the question
surf(x,y,z); % The graph
hold on; % and keep the focus on the figure for
surf(x,y,0.*x); % plotting the range in the XY plane
shading interp; % Optional for showing the mesh lines
axis equal % For an adequate view

태그

Community Treasure Hunt

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

Start Hunting!

Translated by