Path: news.mathworks.com!not-for-mail From: "Sadik " <sadik.hava@gmail.com> Newsgroups: comp.soft-sys.matlab Subject: Re: Plot ellipse Date: Tue, 13 Jan 2009 18:11:01 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 29 Message-ID: <gkilfl$1rn$1@fred.mathworks.com> References: <gkidke$9f9$1@fred.mathworks.com> Reply-To: "Sadik " <sadik.hava@gmail.com> NNTP-Posting-Host: webapp-02-blr.mathworks.com Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1231870261 1911 172.30.248.37 (13 Jan 2009 18:11:01 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Tue, 13 Jan 2009 18:11:01 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1666517 Xref: news.mathworks.com comp.soft-sys.matlab:511264 "Glyn Hudson" <g.d.hudson@warwick.ac.uk> wrote in message <gkidke$9f9$1@fred.mathworks.com>... > Hi everyone, > > I'm trying to plot an ellipse in 2D given co-ordinates of the two foci and the distance between a point on the ellipse and the foci. What do you think is the best way to approach this? > > Glyn. I will make a correction [simplification, explanation, appendix] to my previous reply. You don't need to write x as a function of y to determine its range. Once you write y as a function of x and the other constants x0, y0, a and b, then you will see that y = y0 +/- b* sqrt(1-(x-x0)^2/a^2) ......................... (*) Since we don't want any complex value for y, we would require the term in the square root be non-negative. For which range of x is it non-negative? x0-sqrt(a) <= x <= x0+sqrt(a) So you have your xmin = x0-sqrt(a) and xmax x0 + sqrt(a) . The rest is the same as before. After you have your vector of values for x, you substitute it in (*) above, once for y0 + ... to get the vector yUpper, and once for y0 - ... to get the vector yLower. Then, as you already know, plot(x,yUpper) hold on plot(x,yLower) Of course, all these describe the case when the major [or minor] axis is parallel to the x-axis. In the oblique case, however, you can follow the similar "we don't want complex" approach. Hope this helps.