matlab - fsolve doesn't work with parametrized function handles -
for example, have defined 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 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 fix it?
please re-read requirements objective function in documentation. function must take a single vector input , return vector. you're trying pass 2 scalars. instead:
f = @(x, y, z)[x+y+z; x*y*z]; funcc = @(x)f(x(1), x(2), 0); the input objective function should match initial guess, x0 ([10; 10]).
Comments
Post a Comment