Least Squares Circles The parametric equations for a circle
Least Squares Circles The parametric equations for a circle with center (3,1) and radius 2 are x = 3 + 2 cos t y = 1 + 2 sin t Set t = 0: .5: 6 and use MATLAB to generate vectors of x and y coordinates for the corresponding points on the circle. Next, add some noise to your points by setting x = x +0.1 + rand (1. 13) and y = y + 0.1 * rand(1, 13) Use MATLAB to determine the center c and radius r of the circle that gives the best least squares fit to the points. Set t1 = 0:0.1:6.3 x1 = c(l) + r*cos(t1) y = c(2) + r * sin(t1) and use the command plot (x1, y1, x. y. \'x\') to plot the circle and the data points.
Solution
clc;
t=0:5:6;
x=3+2*cost;
y=1+2*sint;
plot(x,y);
grid on;
x\'=x+0.1*rand(1,13);
y\'=y+0.1*rand(1,13);
plot(x\',y\',\'r\');
grid on;
t1=0:0.1:6.3;
x1=c(1)+r*cos(t1);
y1=c(2)+r*sin(t2);
plot(x1,y1,x,y,\'x\',\'g\');
grid on;
x1label(\'x1-axis\');
y1label(\'y1-axis\');
