I'm having trouble with the differential equation example:

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

madhan ravi
madhan ravi il 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)

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by