how to plot 2 ellipses in one figure using matlabs function plot having been provided with the equations for both?

I have been given the task to plot 2 ellipses in one figure using matlabs function plot
The equations are as follows:
(1.) (x+y+2)^2 + (x+3)^2 =5
(2.) 2(x+3)^2 + (y/3)^2 = 4
Any help or pointers on how I could achieve the solution would be greatly appreciated.

 Réponse acceptée

Much easier to use fimplicit().
eq1=@(x,y)(x+y+2).^2 + (x+3).^2-5;
eq2=@(x,y)2*(x+3).^2 + (y/3).^2-4;
fimplicit(eq1,[-6,0,-6,6])
hold on;
fimplicit(eq2,[-6,0,-6,6])

4 commentaires

thank you for answering but i have to know how to do it using plot and only plot
x=linspace(-5.236065,-0.7639321,1000);%solve for x-range first equation
yy=(- 4 - 6*x - x.^2).^(1/2) - x - 2;%first equation solved for y (upper half)
yyy=- x - (- 4 - 6*x - x.^2).^(1/2) - 2;%first equation solved for y (lower half)
plot(x,yy,'b',x,yyy,'b');%plots first ellipse
hold on;
x=linspace(-4.4142135623,-1.58578644,1000);%solve for x-range second equation
yy=-3*2^(1/2)*(- 7 - 6*x - x.^2).^(1/2);%second equation solved for y (upper half)
yyy=3*2^(1/2)*(- 7 - 6*x - x.^2).^(1/2);%second equation solved for y (lower half)
plot(x,yy,'r',x,yyy,'r');%plots second ellipse
I cant thank you enough for answering again. Would you be able to explain the steps that you need to take to get to this answer so I can understand? Once again thank you.
See above explanation. Need to determine the ranges for x (square root must not go immaginary). Then solve each equation for y (two pieces, upper and lower parts).

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Produits

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by