Weighted curve fitting with lsqnonlin

조회 수: 20 (최근 30일)
friet
friet 2016년 2월 28일
답변: Torsten 2016년 2월 29일
I have the following code that do non-linear curve fiting. However i want to do weighted curve fitting so that it fits well when the value of x is above 45.
clear all
clc
x = [36.78 ,37.53 ,38.28 ,39.06 ,39.85 ,40.65 ,41.47 ,42.31,43.17 ,44.04 ,44.93 ,45.84 ,46.76 ,46.89 ,47.30 ,48.20 ];
y = [0.01 ,0.0152 ,0.023 ,0.035,0.0536 ,0.081 ,0.12 ,0.1891 ,0.287 ,0.438 ,0.66 ,1.01494 ,1.544 ,2.35,3.578 ,5.445 ];
f=0:0.2:3;
fun = @(params) [x - exp((params(2)-1)*f-1)/(params(2)-1)^2, log(y) - log(params(1)) - (params(2)+1)*f];
lb = [1e-10,-1+1e-10]; % Set lower bounds
ub = [inf,inf]; % Set upper bounds
params0 = [0.001,1.7]; % Set initial point.
options.Algorithm = 'levenberg-marquardt';
params = lsqnonlin(fun,params0,lb,ub,options)
figure(1)
plot(x,y,'ko',exp((params(2)-1)*f-1)/(params(2)-1)^2,params(1)*exp((params(2)+1)*f),'b-')
legend('Data','Best fit')
grid on
Can anyone give me some information how to use weighted curve fitting with lsqnonlin. Thanks

답변 (1개)

Torsten
Torsten 2016년 2월 29일

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by