weightedFitCircle Fits a circle to a list of datapoints X, Y, and weights W using fminsearch with specifiable options. Initial parameters are obtained using SVD (SVD approach inspired by https://people.cas.uab.edu/~mosya/cl/TaubinSVD.m).
Returns
CXCYout: XY of circle center
Rout: Radius of circle
RMS: Orthogonal, weighted, root mean squared error
exitFlag: Exit condition of fit
Example code showing that fitting is fast and accurate:
X = 1./rand(1, 6); Y = 1./rand(1, 6); W = rand(1, 6);
tic
[CXCYout, Rout, RMSE] = ...
weightedFitCircle(X, Y, W, optimset('Display', 'Iter'));
toc
disp(['(X,Y,R) = ', num2str([CXCYout, Rout])])
disp(['RMSE = ', num2str(RMSE)])
plot(CXCYout(1) + Rout*cos(0:0.00001:2.001*pi), ...
CXCYout(2) + Rout*sin(0:0.00001:2.001*pi), '--k')
hold on
scatter(X, Y, W/max(W)*75, 'r')
axis equal
引用格式
James Akula (2024). Fit Circle to Weighted (x,y,w) Data (https://www.mathworks.com/matlabcentral/fileexchange/111560-fit-circle-to-weighted-x-y-w-data), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
创建方式
R2021b
兼容任何版本
平台兼容性
Windows macOS Linux标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0 |