Ploting a implicit equation using plot

19 ビュー (過去 30 日間)
Benjamin Midtvedt
Benjamin Midtvedt 2015 年 10 月 8 日
編集済み: John D'Errico 2015 年 10 月 8 日
Basically, I want to plot the equation:
x^2+y^2=1+4.5sin^2(xy)
Normally I would use ezplot, but I was explicitly (not implicitly) told to use the plot command. How would I go about doing this?

回答 (1 件)

John D'Errico
John D'Errico 2015 年 10 月 8 日
編集済み: John D'Errico 2015 年 10 月 8 日
If you cannot use ezplot (must use plot), then you just pick a range of values for x, then solve for y at each x. Plot the results. WTP?
help fzero
Of course, if you were feeling creative, and chose NOT to follow your directions, then you could just use contour. Generate points for the function
f(x,y) = x^2+y^2 - 1 - 4.5sin^2(xy)
then plot the zero contour.
help meshgrid
help contour
  7 件のコメント
John D'Errico
John D'Errico 2015 年 10 月 8 日
編集済み: John D'Errico 2015 年 10 月 8 日
For this specific case, possibly. However, the sin(x*y) would still be a bit messy. Then we would have
r^2 - 1 - 4.5*sin(r^2*sin(theta)*cos(theta)) = 0
So, one might choose to play with this more, but it is not even obvious that for any given value of theta, there is a unique r. In fact, ezplot suggests that for some values of theta, this might be multi-valued, with multiple values for r. (That would require some more play.)
Regardless, for the completely general case such a substitution will be of no value. And so often, when someone gives a function they claim to want to plot, the true function they actually want to plot is so much more messy. This appear to be homework, so probably not the case.
In the end, ezplot is the simple solution, in one line. meshgrid and contour, only slightly more work, doable in two lines.
Benjamin Midtvedt
Benjamin Midtvedt 2015 年 10 月 8 日
So, how would you suggest I'd move forward?
Since the equation obviously makes no distinguishment between x and y, the resulting plot has to be completely symmetrical. I could use this as a argument to simply rotate the graph to find the missing pieces. But this is very unsatisfying, probably equally difficult, and it only works in the special case.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by