I'm having trouble with the differential equation example:

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by