What is wrong with my lsqcurvefit script here?

1 回表示 (過去 30 日間)
Vipultomar
Vipultomar 2017 年 6 月 4 日
回答済み: Walter Roberson 2017 年 6 月 4 日
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 Center および File ExchangeDownloads についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by