I need to draw this ellipse on Matlab and i can't. My problem seems to be with the plus-minus symbol.
I don't know how to set my axis to get my ellipse right in the middle of my graph !?
It need to be in :
Y = (0:10)
X = (0:8)
This is what i've done so far :
x=0:0.001:8;
y= (((5*(4+-sqrt(8*x-x.^2)))/4));
plot(x,y);
grid on;
I'm using Matlab R2013a
From a student who need your help please !!!!!!
PS : sorry for the silly mistakes, i'm not an anglophone !!

1 Kommentar

per isakson
per isakson am 15 Feb. 2014
Bearbeitet: per isakson am 15 Feb. 2014
Your code produces half an ellipse.
Matlab doesn't interpret +-sqrt the way you intend.
You can make it two cases and finally concatenate them.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Roger Stafford
Roger Stafford am 15 Feb. 2014

3 Stimmen

It's easiest to generate an ellipse parametrically. I deduce from your equation for y that the ellipse's equation is:
(x-4)^2/4^2 + (y-5)^2/5^2 = 1
This can be represented parametrically using the parameter t by:
t = linspace(0,2*pi);
x = 4 + 4*cos(t);
y = 5 + 5*sin(t);
plot(x,y)
axis equal

1 Kommentar

Image Analyst
Image Analyst am 16 Feb. 2014
Mathieu, see the FAQ : http://matlab.wikia.com/wiki/FAQ#How_do_I_create_an_ellipse.3F (essentially the same as Roger's code, but there's other good stuff in there that you may like to see and you may benefit from).

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Mathieu Bouchard
Mathieu Bouchard am 16 Feb. 2014

0 Stimmen

Thank you Roger Stafford !!!!
This is exactly what I needed !
Isakson : that was my problem but i'm new on matlab and I don't know all the function of it and how to dot it !

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by