📄 try_circ_fit.m
字号:
% 在半径为R的圆上取20个点,在圆上
% 加白噪声,使这些点围绕圆出现一定
% 偏离,拟合这些点,生成一个圆,和
% 原来的标准圆对比
% 圆心分别为
%(0,0)及(xc,yc)
%
% Create data for a circle + noise
th = linspace(0,2*pi,30)';
R=1.1111111;
sigma = R/10;
x = R*cos(th)+randn(size(th))*sigma;
y = R*sin(th)+randn(size(th))*sigma;
plot(x,y,'o'), title(' measured points')
pause(1)
[xc,yc,Re,a] = circfit(x,y); % 由以上数据拟合圆
xe = Re*cos(th)+xc; ye = Re*sin(th)+yc; % 拟合后圆上的点
plot(x,y,'o',xe,ye,'-.',R*cos(th),R*sin(th)),
title(' measured fitted and true circles')
legend('measured','fitted','true')
text(xc-0.9*R,yc,sprintf('center (%g , %g ); R=%g',xc,yc,Re))
xlabel x, ylabel y
axis equal
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -