フィルターのクリア

not enough input argument

3 ビュー (過去 30 日間)
Tze Ting Ong
Tze Ting Ong 2018 年 2 月 21 日
コメント済み: Stephen23 2018 年 2 月 21 日
Hi I have a problem with my function on matlab and it's driving me crazy I am very new to matlab and I was wondering what went wrong in my command because I keep getting "not enough input argument" and this appears in my command window:
>> Tut2Q2 Not enough input arguments.
Error in Tut2Q2 (line 3) dydx = [y(2); -0.54*y(2)-(0.0729+pi)*y(1)];
My script file is:
function dydx = Tut2Q2(x,y)
dydx = [y(2); -0.54*y(2)-(0.0729+pi)*y(1)];
end
Help please! :-(
  2 件のコメント
Torsten
Torsten 2018 年 2 月 21 日
Please supply the complete code you are using.
Best wishes
Torsten.
Stephen23
Stephen23 2018 年 2 月 21 日
@Tze Ting Ong: how are you calling the function Tut2Q2 ?

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

回答 (1 件)

C.J. Harris
C.J. Harris 2018 年 2 月 21 日
Your code, which I've included below takes two inputs, x and y, however you don't use the first input 'x' anywhere in your code, while input y is expected to be of size 2.
function dydx = Tut2Q2(x,y)
dydx = [y(2); -0.54*y(2)-(0.0729+pi)*y(1)];
end
Therefore, unless you are calling the function with y having a size of 2, it will give that error. You could change your code to use both x and y:
function dydx = Tut2Q2(x,y)
dydx = [y; -0.54*y-(0.0729+pi)*x];
end
And then call it with two inputs:
out = Tut2Q2(1,2);
With your current definition, you'd have to call it as follows to achieve the same thing:
out = Tut2Q2([],[1 2]);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by