Fit-Curve through certain start point
Mostrar comentarios más antiguos
How can I define a fit function out of an array, that goes through a defined start point and end point? Also, if there is a point out of zeros, it should not be considered. I tried it with the fit function and chose the "NonLinearLeastSquares" Method.
data = [0 1 2 3 4 5 6 0 8 9 ; 3 5 4 6 8 6 5 0 5 2]
xdata = data(1,:);
ydata = data(2,:);
start = [xdata(1) ydata(1)];
exclude = [0 0]
options = fitoptions('Method','NonlinearLeastSquares','Startpoint',start,'Exclude',exclude)
fit_xy = fit(xdata',ydata','poly5',options);
ydata_fitted = feval(fit_xy,xdata);
figure
plot(xdata,ydata,'-ob');
hold on
plot(xdata,ydata_fitted,'-or');
plot(fit_xy);
Thanks a lot!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Linear and Nonlinear Regression en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!