How to plot a circle given its equation (with colors)
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Wilson Zheng
el 20 de Mzo. de 2020
Comentada: Cris LaPierre
el 20 de Mzo. de 2020
I have 2 equations:
x^2+y^2=1/2
(x-1)^2+y^2=1
How can I quickly and easily plot both equations in the same graph, but with different colors. ezplot works and is super simple, but I can't find a way to change the colors. plot and fplot seems to be struggling with the "=" sign. What's the quickest way to do this?
0 comentarios
Respuesta aceptada
Cris LaPierre
el 20 de Mzo. de 2020
Editada: Cris LaPierre
el 20 de Mzo. de 2020
You could rearrange the equations to be in the form "y=..." and then use fplot on that.
y=@(x) sqrt(1/2 - x.^2);
fplot(y,'--or')
1 comentario
Cris LaPierre
el 20 de Mzo. de 2020
Of course, the challenge is to get a circle, you need the positive and negative results. You could do this symbolically
syms x y
eqn = x.^2 + y.^2 == 1/2
s = solve(eqn,x)
fplot(s,[-1,1])
Más respuestas (0)
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!