How do I plot a 3D function characterized by 2 equations?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jett Marcos
am 5 Feb. 2018
Kommentiert: Walter Roberson
am 6 Feb. 2018
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 Kommentar
Walter Roberson
am 5 Feb. 2018
You want the intersection of the two functions?
You used arctan(Y/X). Do you want quandrant adjustment, atan2(Y, X) ?
Akzeptierte Antwort
Walter Roberson
am 5 Feb. 2018
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 Kommentare
Walter Roberson
am 6 Feb. 2018
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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Polar Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!