fsolve 不适用于参数化函数句柄

fsolve doesn't work with parametrized function handles

例如,我定义了以下函数句柄:

F = @(x, y, z)[x+y+z; x*y*z];  
funcc = @(x, y)F(x, y, 0);  

来电

res = fsolve(funcc, [10; 10]);  

导致错误:

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.

我该如何解决?

请重新阅读requirements for the objective function in the documentation。该函数必须采用单个矢量输入和 return 一个矢量。您正在尝试传递两个标量。相反:

F = @(x, y, z)[x+y+z; x*y*z];
funcc = @(x)F(x(1), x(2), 0);  

objective 函数的输入应与您的初始猜测一致,x0 ([10; 10])。