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.

 Accepted Answer

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 Comments

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).

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Objects in Help Center and File Exchange

Products

Release

R2021b

Asked:

on 5 Apr 2022

Commented:

on 7 Apr 2022

Community Treasure Hunt

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

Start Hunting!