Reputation: 63
For example, I have defined the following function handles:
F = @(x, y, z)[x+y+z; x*y*z];
funcc = @(x, y)F(x, y, 0);
The call
res = fsolve(funcc, [10; 10]);
Leads to an error:
Error using @(x,y)F(x,y,0)
Not enough input arguments.
Error in fsolve (line 219)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
How can I fix it?
Upvotes: 1
Views: 56
Reputation: 18484
Please re-read the requirements for the objective function in the documentation. The function must take a a single vector input and return a vector. You're trying to pass two scalars. Instead:
F = @(x, y, z)[x+y+z; x*y*z];
funcc = @(x)F(x(1), x(2), 0);
The input to the objective function should match your initial guess, x0
([10; 10]
).
Upvotes: 3