I have a question about using the lsqnonlin
function.
In my case I have two functions:
f_1=@(t,x)sin(t+x.^2);
f_2=@(t,x)cos(x.^2)+3.*t.^2;
f = {f_1, f_2};
I want to find the values of the arguments t
and x
which would result in the least square error, defined as: f_1(t,x)^2+f_2(t,x)^2
. In other words, argmin for LSE.
My code is as follow with initial guess [1,2]
:
lsqnonlin(f,[1,2])
And I'm getting the error:
Error in lsqnonlin (line 196) initVals.F = feval(funfcn{3},xCurrent,varargin{:}); Caused by: Failure in initial objective function evaluation. LSQNONLIN cannot continue.
lsqnonlin
can be used for vector function and vector input according to the documentation. I wonder how to prepare corresponding codes for it. Could anyone suggest the solution?