Points on a circle
Show older comments
Hello everyone!
how can i get a random point on the min and max circles on these:
format short
A = load('C:\Users\Stefan\Desktop\MatiValjasMatLAb/vruut.txt')
nurgad=A(:,1)
kaugused=A(:,2)
%polarplot(nurgad,kaugused,'o')
%Joonise järgi võiks lähendada ringjoonega
%Arvandmete järgi võiks ka eeldada, et saab lähendada ringjoonega
%sest raadiused ei kõigu palju.
%joonised
x = kaugused.*cos(nurgad); y = kaugused.*sin(nurgad);
plot(x,y,'.')
axis equal
hold on
c = [x y ones(length(x),1)]\-(x.^2+y.^2); %vähim ruutude meetod
xhat = -c(1)/2;
yhat = -c(2)/2;
raadius = sqrt(xhat^2+yhat^2-c(3));
plot(raadius*cos(nurgad)+xhat,raadius*sin(nurgad)+yhat,...
'g','linewidth',1) %parim ring(best fit circle)
hold on
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
raadius
kesk=[xhat, yhat]
plot(xhat,yhat,'O')
hold on
B=max(kaugused);
C=min(kaugused);
theta=0:0.01:2*pi;
xmax=B*cos(theta)+xhat;
ymax=B*sin(theta)+yhat;
plot(xmax,ymax)
hold on
hold on
xmin=C*cos(theta)+xhat;
ymin=C*sin(theta)+yhat;
plot(xmin,ymin)
hold on
hold off
The plot looks like this :

Accepted Answer
More Answers (0)
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!