Error: Fsolve: Not enough input arguments

3 views (last 30 days)
Hi, I've seen several posts similar to mine, but after trying the fixes I still am getting the same error.
My code:
%%%cell 2
%%%second cell
h = @(t,z) [ (-0.2)*(z(1) - z(1).^3/3 - z(2) + I); (-0.2)*(0.7*(z(1) + 0.7 - 0.8*z(2))) ];
l = @(z) f(0,z);
fp2 = fsolve(h,[0 0]); % Find the fixed point
Vss2 = fp2(1); Wss2 = fp2(2); % Get the steady-state V and W values from "fp"
J2 = [ [1 - Vss2^2, -1]; [(-0.2*y)*0.7, (-0.2*y)*-0.8*0.7]]; % The Jacobian
Lambda2 = eig(J2); % Eigenvalues of Jacobian
The error I get:
Error using @(t,y,z)[(-0.2)*(z(1)-z(1).^3/3-z(2)+I);(-0.2)*(0.7*(z(1)+0.7-0.8*z(2)))]
Not enough input arguments.
Error in fsolve (line 219)
fuser = feval(funfcn{3},x,varargin{:});
Error in robcapps_2cell_FN (line 29)
fp2 = fsolve(h,[0 0]); % Find the fixed point
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
I'm fairly new to Matlab, so I'm sure it's something simple. Thanks in advance!

Accepted Answer

Geoff Hayes
Geoff Hayes on 16 Nov 2014
Robert - the error message is telling you that not enough input parameters are being supplied to your function h via fsolve. According to the documentation for fsolve, the input function fun is a function that accepts a vector x and returns a vector F, the nonlinear equations evaluated at x. So a single input only. Your h is defined with two inputs (one of which is unused, t) as
h = @(t,z) [ (-0.2)*(z(1) - z(1).^3/3 - z(2) + I); (-0.2)*(0.7*(z(1) + 0.7 - 0.8*z(2))) ];
though the error message seems to be indicating that there are three input variables, t, y and z. As neither t nor y are ever used in your function, then you should be able to define h as
h = @(z)[ (-0.2)*(z(1) - z(1).^3/3 - z(2) + I); (-0.2)*(0.7*(z(1) + 0.7 - 0.8*z(2))) ];
This assumes that I has already been initialized. Try making the above change and see what happens!
  2 Comments
Robert
Robert on 19 Nov 2014
Thank you so much! That did work. But now I need to couple the equations through a third shared variable. I will also need to use the ode45 solver to plot these equations with the coupling. How can I modify the equations to include this third variable?
Thank you again!
Geoff Hayes
Geoff Hayes on 19 Nov 2014
How does the third variable fit into your h equation?

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!