I'm having trouble with the differential equation example:

1 Ansicht (letzte 30 Tage)
Steve
Steve am 22 Mär. 2020
Bearbeitet: James Tursa am 22 Mär. 2020
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?

Akzeptierte Antwort

madhan ravi
madhan ravi am 22 Mär. 2020
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)

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by