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.

 采纳的回答

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 个评论

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

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Graphics Objects 的更多信息

产品

版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by