Plot ellipse from equation (no foci/axes)

35 ビュー (過去 30 日間)
Ben
Ben 2015 年 2 月 23 日
回答済み: Nicolas Flamant 2019 年 5 月 23 日
I have an equation for an ellipse: x^2+y^2-4x-8y+10-2*log(2) = 0. How an I plot this in Matlab? Everything that I've found searching only tells how to plot if you have the foci and major/minor axes. I tried putting the equation into Wolfram Alpha, which gave me two expressions for y, but apparently that results in some complex values over the range [-4,4] for x. What else can I try?

採用された回答

Andrew Newell
Andrew Newell 2015 年 2 月 23 日
編集済み: Andrew Newell 2015 年 2 月 23 日
One approach is to use ezplot:
ezplot('x^2+y^2-4*x-8*y+10-2*log(2)')
By default, this plots over the domain -2π < x < 2π, -2π < y < 2π. But you'll see that needs adjusting. Add axis limits:
ezplot('x^2+y^2-4*x-8*y+10-2*log(2)',[-2 6 0 8])
Finally, type
axis equal
and you'll see that it's actually a square.
An alternative is that you can complete the square (see, e.g., Completing the Square: Ellipse Equations), getting (x-2)^2+(y-4)^2=10+2*log(2). This is a circle with center at (2,4) and radius sqrt(10+2*log(2)) (about 3.4).

その他の回答 (2 件)

proy
proy 2016 年 8 月 18 日
Use Ellipse Calculator to find foci and major/minor axes from equation.

Nicolas Flamant
Nicolas Flamant 2019 年 5 月 23 日
I recommend to use
fimplicit
which is now preferred to
ezplot

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by