Error: Fsolve: Not enough input arguments

조회 수: 3 (최근 30일)
Robert
Robert 2014년 11월 15일
댓글: Geoff Hayes 2014년 11월 19일
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