Where does the diffrence beetween lsqcurvefit and data come from?
Mostrar comentarios más antiguos
Hello,
I am using lsqcurvefit to determine the best fitting circle (in terms of the center point) with known tangent point and radius to a certain number of points. The code works fine but as shown in the screenshot below, one can see that there is a gap beetween the data and the fitted values.
Is the error located in the code or in the function?
Problem:

Code:
load('data-ask.mat')
% Gleichung 1: Tangentengleichung mit wt als Tangentenpunkt und bekanntem Radius
fun =@(x1,xdata1)((x1(1).^2-x1(1).*gp(1)-x1(1).*xdata1+x1(2).^2-x1(2).*gp(2)+gp(1).*xdata1-gr.^2).*((x1(2)-gp(2)).^-1));
u = [mean(xdata1) mean(ydata1)+gr];
options=optimoptions(@lsqcurvefit,'StepTolerance',1e-32);
lb=[0 min(ydata1)];
ub=[inf gp(2)+gr];
x1 = lsqcurvefit(fun,u,xdata1,ydata1,lb,ub,options);
%figure
figure()
h(1)=plotCircle(x1(1,1),x1(1,2),gr);
h(1).Marker='*'
h(1).Color='black';
hold on;axis equal; grid on
s(2)=scatter(xdata1,ydata1,'red','s');
xlim([min(xdata1) max(xdata1)])
ylim([min(ydata1) max(ydata1)])
l=legend({'Circle-Fit' 'Data'})
l.Location='northoutside'
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Simulation, Tuning, and Visualization en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!