Nonlinear Least Squares implementation
조회 수: 3 (최근 30일)
이전 댓글 표시
Dear all,
I believe my problem is trivial but I do not know I to make it work. I would appreciate someone's help about it. If I define my function myLS like this
function G = myLS(x)
F = [10 30 30];
S0 = 32.2337;
r = 0;
w = 0;
t = [1 5 10];
Q0 = [0.9917 0.8226 0.8081];
fun1 = myequity(x(1), F, t, r, w, x(2)) - S0;
fun2 = myQ(x(1), F, t, r, w, x(2)) - Q0;
G = [fun1 fun2];
end
And then I use the non linear least square
[x,resnorm,res,eflag,output1] = lsqnonlin(@myLS,x0)
The programme finds correctly the values of x which solve the problem. However, I would like to have something like
function G = myLS(F, S0, r, w, t, Q0, x)
fun1 = myequity(x(1), F, t, r, w, x(2)) - S0;
fun2 = myQ(x(1), F, t, r, w, x(2)) - Q0;
G = [fun1 fun2];
end
and solve the same non linear least square problem. It does not work however and the following error appears
Not enough input arguments.
Error in myLS (line 5)
fun1 = myequity(x(1), F, t, r, w, x(2)) - S0;
Error in lsqnonlin (line 205)
initVals.F = feval(funfcn{3},xCurrent,varargin{:});
Caused by:
Failure in initial objective function evaluation. LSQNONLIN cannot continue.
What am I doing wrong?
Thank you very much for your help.
Best,
Federico
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!