I'm having trouble with the differential equation example:

1 回表示 (過去 30 日間)
Steve
Steve 2020 年 3 月 22 日
編集済み: James Tursa 2020 年 3 月 22 日
I have input the following into MatLab--
van der Pol example:
function dydt = vdp1(t,y)
dydt = [y(2); (1-y(1)^2*y(2)-y(1)];
[t,y] = ode45(@vdp1, [0 20], [2; 0]);
plot(t,y(:,t), '-',t,y(:,2),'--')
When I try to run this as a program, it returns the error message 'not enough input arguments'.
I tried another example for a 1st order differential equation:
function dydt = lineary1(t,y)
dydt = [y(1)];
[t,y] = ode45(@lineary1, [0 5], [0]);
plot(t,y)
When I ran that program, I saw the same error message.
What am I doing wrong?

採用された回答

madhan ravi
madhan ravi 2020 年 3 月 22 日
function dydt = lineary1(t,y) % should be saved as lineary1.m
dydt = y(1);
And in another file named "Experiment.m"
[t,y] = ode45(@lineary1, [0 5], [0]);
plot(t,y)

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by