lsqnonlin -not enough input arguments-

14 ビュー (過去 30 日間)
noemi91d
noemi91d 2016 年 5 月 4 日
編集済み: Matt J 2016 年 5 月 4 日
Hi all!
I need some help with lsqnonlin. The function is:
function [y] = FUN(p,t)
k1 = p(1);
k2 = p(2);
y=(exp(-k1*t)-exp(-k2*t))*((k1*k2)/(k2-k1));
And:
[p_stima] = lsqnonlin(@FUN,[0.4 0.5],[]);
The error is:
Not enough input arguments.
Error in FUN (line 4)
y=(exp(-k1*t)-exp(-k2*t))*((k1*k2)/(k2-k1));
Error in lsqnonlin (line 196)
initVals.F = feval(funfcn{3},xCurrent,varargin{:});
Error in plotHistFit (line 88)
[p_stima] = lsqnonlin(@FUN,[0.4 0.5],[]);
Caused by:
Failure in initial objective function evaluation. LSQNONLIN cannot continue
Thank you in advance.
Best regards

回答 (1 件)

Torsten
Torsten 2016 年 5 月 4 日
Your FUN function must only have one argument, namely p.
Best wishes
Torsten.
  1 件のコメント
Matt J
Matt J 2016 年 5 月 4 日
編集済み: Matt J 2016 年 5 月 4 日
Therefore, the following modification could solve the issue,
t=???;
[p_stima] = lsqnonlin(@(p) FUN(p,t) , [0.4 0.5],[]);

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by