How do I plot a 3D function characterized by 2 equations?

So far, I've been plotting 3d functions like so:
[X,Y]=meshgrid(-3:0.5:3,-3:0.5:3);
Z=2-X-Y;
surf(X,Y,Z)
but that is for functions that can be characterized by a single equation.
However, if I want to plot a 3d function characterized by a system of two equations, such as
Z=2*arctan(Y/X)
and
Z=.2*sqrt(X^2+Y^2)
How would I go about plotting the function?

댓글 수: 1

You want the intersection of the two functions?
You used arctan(Y/X). Do you want quandrant adjustment, atan2(Y, X) ?

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

 채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 5일
If you rewrite in polar coordinates, 2*arctan(Y/X) is 2*theta, and .2*sqrt(X^2+Y^2) is r/5. If you equate the two and solve for r in terms of theta, you get r = 10*theta which is easily plotted:
theta = linspace(0, 2*pi);
r = 10*theta;
[x,y] = pol2cart(theta, r);
plot(x, y)

댓글 수: 2

Doing this would only take into account one of the two equations of the system. I could change coordinate system, but I would still need to plot the system characterized by the ff: r=10*theta: z=2*theta: Going back to my original question, how do I plot the intersection of these two equations on the same 3d plot?
No, this takes into account both equations. You can proceed from here to
theta = linspace(-pi/2, pi/2);
r = 10*theta;
[x,y] = pol2cart(theta, r);
Z1a = 2 * theta;
Z2a = .2 * r;
Z1b = 2 * atan(y./x);
Z2b = .2 * sqrt(x.^2 + y.^2);
max(Z1a - Z1b) %zero to within round-off, so they are computing the same thing -- the polar form is the same as the cartesian form
max(Z2a - Z2b) %zero to within round-off, so they are computing the same thing -- the polar form is the same as the cartesian form
max(Z1a - Z2a) %zero to within round-off, so they are computing the same thing -- the intersection has been successful when calculated in polar
max(Z1b - Z2b) %zero to within round-off, so they are computing the same thing -- the intersection has been successful when calculated in cartesian
plot3(x, y, Z1a)

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Polar Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by