Not enough input arguments in function? Help!!

1 回表示 (過去 30 日間)
Danielle Moore
Danielle Moore 2016 年 2 月 22 日
編集済み: jgg 2016 年 2 月 22 日
I have the function
function z = funct(t,S)
z = 0.4*S-((0.4*S.^2)./10);
and
function euler(func,S0,dt,t0,tf)
% Time interval
t=t0:dt:tf;
% Loop using Euler's method
for i = 1:length(t)-1
S(i+1) = S(i) + dt*(feval(func,t(i),S(i)));
end
t=t'
S=S'
plot(t,N)
xlabel('Time')
ylabel ('S')
when I type this into command window
euler(funct,7,.001,0,25)
I get this error
Not enough input arguments.
Error in funct (line 2)
z = 0.4*S-((0.4*S.^2)./10);
PLEASE HELP!!!!-
  1 件のコメント
jgg
jgg 2016 年 2 月 22 日
編集済み: jgg 2016 年 2 月 22 日
Are you sure you posted all your code? I can't replicate your error: I get that S is undefined in Euler, since you never declare it anywhere. If I correct it so S = S0 (to start) I then get another error about N.
Also I notice that funct doesn't use t at all.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 2 月 22 日
Don't type that into the command window. Instead type
euler(@funct,7,.001,0,25)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by