What is wrong with my lsqcurvefit script here?

1 次查看(过去 30 天)
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

回答(1 个)

Walter Roberson
Walter Roberson 2017-6-4
[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)

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by