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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -