I can not figure out why my circle is invisiable when I plot it (It is a regression). Am I missing something? It used to work earlier.
x = [5; 4; -1; 1];
y = [3; 5; 2; 1];
% circle's equation: x^2+y^2 = 2xc1+2yc2+c3
a = [2.*x,2.*y,ones(length(x),1)];
b = [x.^2 + y.^2];
c = a\b;
x_m = c(1)/2;
y_m = c(2)/2;
r = sqrt(x_m^2 + y_m^2 -c(3));
% plot data points
plot(x,y,'o')
hold on
% plot center
plot(x_m,y_m,'+')
% plot circle
circle(x_m,y_m,r)
hold off

2 commentaires

KSSV
KSSV le 18 Déc 2019
For that we should have a look on the function circle.
Jenny Andersen
Jenny Andersen le 18 Déc 2019
It is no function, only an expression.

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 18 Déc 2019
Modifié(e) : Walter Roberson le 18 Déc 2019

0 votes

viscircles([x_m, y_m], r)
axis equal

7 commentaires

Jenny Andersen
Jenny Andersen le 18 Déc 2019
Thanks, but it's still unvisiable as far as I can see.
x = [5; 4; -1; 1];
y = [3; 5; 2; 1];
% circle's equation: x^2+y^2 = 2xc1+2yc2+c3
a = [2.*x,2.*y,ones(length(x),1)];
b = [x.^2 + y.^2];
c = a\b;
x_m = c(1)/2;
y_m = c(2)/2;
r = sqrt(x_m^2 + y_m^2 -c(3));
% plot data points
plot(x,y,'o')
hold on
% plot center
plot(x_m,y_m,'+')
% plot circle
viscircles([x_m,y_m],r)
hold off
produces
497196.jpg
provided your graphics is working properly.
Note: if you happen to be using MacOS Catalina, then there have been some reports that only the first one or two lines drawn work and that additional graphics objects might not get drawn.
Jenny Andersen
Jenny Andersen le 18 Déc 2019
Ok, that explains it. Thank you.
Walter Roberson
Walter Roberson le 18 Déc 2019
Which explains it? Do you happen to be using Catalina ?
Jenny Andersen
Jenny Andersen le 18 Déc 2019
Modifié(e) : Jenny Andersen le 18 Déc 2019
Not Catalina but Sierra. I have however been having technical problems with matlab ever since I got it, so I just figured it had something to do with this (perhaps).
The error I get is the following:
Error in untitled14 (line 16)
viscircles([x_m,y_m],r)
Walter Roberson
Walter Roberson le 18 Déc 2019
Which MATLAB release are you using, and do you have the Image Processing Toolbox (that defines viscircles())
Walter Roberson
Walter Roberson le 18 Déc 2019
There are File Exchange contributions to draw circles, including https://www.mathworks.com/matlabcentral/fileexchange/59244-circles

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by