I have the following function:
Eq = @(x1, x2) [x1-6, x2+3];
fsolve(Eq, [4 1])
but get the following error:
??? Input argument "x2" is undefined.
Error in ==> @(x1,x2)[x1-6,x2+3]
Error in ==> fsolve at 193
fuser = feval(funfcn{3},x,varargin{:});
Error in ==> Untitled at 6
fsolve(Eq, [4, 1])
It works perfectly when I change the function to a one input function. Does anyone know what's going on here?
You are passing in the vector [4 1] as the x1
argument.
Do this instead:
Eq = @(x) [x(1)-6, x(2)+3];
fsolve(Eq, [4 1])
The fsolve
expects a function with one argument (either a vector or matrix), therefore a function with two arguments won't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With