What is wrong with my lsqcurvefit script here?

2 visualizzazioni (ultimi 30 giorni)
Vipultomar
Vipultomar il 4 Giu 2017
Risposto: Walter Roberson il 4 Giu 2017
I have Xdata and Ydata as input data points. And I need to do non-linear regression. Here's what I am doing.
K=2; V=0.3;
X0=[K,V];
options = optimset('DiffMinChange',[0.000001],'disp','iter','Algorithm',[],'MaxIter',100000,'MaxFunEvals',[10000]);%simple max eval fun 100000
options = optimset(options, 'TolX', 1e-14);
[fitted_param] = lsqcurvefit(@(fitted_param,XDATA) ((1+(XDATA*K)).*exp(V*XDATA)),X0,XDATA,YDATA,[],[],options)
It stops at one step and give the same values of parameters as I provide as input.
Thanks

Risposte (1)

Walter Roberson
Walter Roberson il 4 Giu 2017
[fitted_param] = lsqcurvefit(@(fitted_param,XDATA) ((1+(XDATA*K)).*exp(V*XDATA)),X0,XDATA,YDATA,[],[],options)
Your target function @(fitted_param,XDATA) ((1+(XDATA*K)).*exp(V*XDATA)) ignores the first parameter, returning the same output no matter what model parameters are suggested in its first input. lsqcurvefit determines that the output is not changing with the input model parameters and so figures the the initial model parameters X0 are as good as any other possibilities.
I suspect you are looking for something like
[fitted_param] = lsqcurvefit(@(KV,XDATA) ((1+(XDATA*KV(1))).*exp(KV(2)*XDATA)), X0, XDATA, YDATA, [], [], options)

Categorie

Scopri di più su Systems of Nonlinear Equations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by