Error: Fsolve: Not enough input arguments

5 Ansichten (letzte 30 Tage)
Robert
Robert am 15 Nov. 2014
Kommentiert: Geoff Hayes am 19 Nov. 2014
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!

Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 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 Kommentare
Robert
Robert am 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 am 19 Nov. 2014
How does the third variable fit into your h equation?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by