I'm having trouble with the differential equation example:

1 vue (au cours des 30 derniers jours)
Steve
Steve le 22 Mar 2020
Modifié(e) : James Tursa le 22 Mar 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?

Réponse acceptée

madhan ravi
madhan ravi le 22 Mar 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)

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by