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
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
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 个评论
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 Center 和 File Exchange 中查找有关 Polar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!