plot two implicit functions in one figure
Mostrar comentarios más antiguos
How can i plot these two functions into the same figure, ive tried to read the tips but I cannot do it. And also i have to find the intersection after ive plotted them.
(2*x.^2)+(2*y.^2)-5) and x*y-1
Respuestas (1)
Show what you have tried. If nothing, why not? First, apparently you know what an implicit function is. So have you tried using fimplicit? Next, a piece you are missing is the hold command.
help hold
But then you need to solve for the intersection. Would not solve do that? Or fsolve, if you want a numerical solution that does not rely on symbolic tools?
4 comentarios
Lova
el 8 de Dic. de 2022
Lova
el 8 de Dic. de 2022
fimplicit(@(x,y)(2*x.^2)+(2*y.^2)-5)
hold on
fimplicit(@(x,y)x.*y-1)
John D'Errico
el 8 de Dic. de 2022
Editada: John D'Errico
el 8 de Dic. de 2022
Ok then good. So you did not need to use linspace at all.
fimplicit was all you need, sandwiched between two calls to fimplicit.
fimplicit(@(x,y) 2*x.^2 + 2*y.^2 - 5) % this is the equation of a circle
hold on
fimplicit( @(x,y) x.*y - 1) % the equation of a hyperbola
axis equal
The axis equal command insures the x and y axes have the same spacing. Otherwise, the circle will look like an ellipse.
But now you need to solve for the solutions. You can use solve or fsolve. But remember that solve will require you make the variables symbolic. And fsolve will force you to convert it into a function with one vector argument. For example, to use fsolve, you might write this piece as:
f1 = @(xy) 2*xy(1).^2 + 2*xy(2).^2 - 5
But finally, then you need to remember that fsolve will find only one solution at a time, wheras solve should find all 4 solutions.
Categorías
Más información sobre Line Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


