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

4 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2018-2-5
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 个评论
Jett  Marcos
Jett Marcos 2018-2-6
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?
Walter Roberson
Walter Roberson 2018-2-6
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 个)

类别

Help CenterFile Exchange 中查找有关 Polar Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by