Filter löschen
Filter löschen

Weighted curve fitting with lsqnonlin

15 Ansichten (letzte 30 Tage)
friet
friet am 28 Feb. 2016
Beantwortet: Torsten am 29 Feb. 2016
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

Antworten (1)

Torsten
Torsten am 29 Feb. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by