What is wrong with my lsqcurvefit script here?

1 vue (au cours des 30 derniers jours)
Vipultomar
Vipultomar le 4 Juin 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

Réponses (1)

Walter Roberson
Walter Roberson le 4 Juin 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)

Catégories

En savoir plus sur Downloads dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by