MATLAB Answers

How to plot a circle given its equation (with colors)

6 views (last 30 days)
I have 2 equations:
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?


Sign in to comment.

Accepted Answer

Cris LaPierre
Cris LaPierre on 20 Mar 2020
Edited: Cris LaPierre on 20 Mar 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);
You can read more about setting line properties here.

  1 Comment

Cris LaPierre
Cris LaPierre on 20 Mar 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)

Sign in to comment.

More Answers (0)

Sign in to answer this question.



Translated by