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

4 ビュー (過去 30 日間)
Jett  Marcos
Jett Marcos 2018 年 2 月 5 日
コメント済み: Walter Roberson 2018 年 2 月 6 日
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 Center および File ExchangePolar Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by