can you help please

1 回表示 (過去 30 日間)
Mike
Mike 2015 年 4 月 6 日
コメント済み: Star Strider 2015 年 4 月 7 日
I have this code (attached)
it keeps giving me error message saying:
Error using @(y)((-0.02^2)*sqrt(2*(9.81)*y))/(2*4*y-(y^2)) Too many input arguments.

回答 (1 件)

Star Strider
Star Strider 2015 年 4 月 6 日
The problem is in this (and similar) lines:
y1(i+1) = y1(i) + f(t(i),y1(i))*h;
You are passing your ‘f’ function 2 arguments when it only takes one.
  2 件のコメント
Mike
Mike 2015 年 4 月 6 日
Can you help me on how i can avoid this error
Star Strider
Star Strider 2015 年 4 月 7 日
You already have ‘t’ defined as a vector, so I don’t know why you need it as input to your function, since you’re not using it there.
One possibility:
y1(i+1) = y1(i) + f(y1(i))*h;
and so with the others. That should at least run without problems (I didn’t test it). See if it improves your code.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by