Error: Fsolve: Not enough input arguments

3 次查看(过去 30 天)
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!

采纳的回答

Geoff Hayes
Geoff Hayes 2014-11-16
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 个评论
Robert
Robert 2014-11-19
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 2014-11-19
How does the third variable fit into your h equation?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by