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 commentaire

per isakson
per isakson le 15 Fév 2014
Modifié(e) : per isakson le 15 Fév 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.

Connectez-vous pour commenter.

 Réponse acceptée

Roger Stafford
Roger Stafford le 15 Fév 2014
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 commentaire

Image Analyst
Image Analyst le 16 Fév 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).

Connectez-vous pour commenter.

Plus de réponses (1)

Mathieu Bouchard
Mathieu Bouchard le 16 Fév 2014

0 votes

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 !

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by