Using ODE45 to solve a system of 2nd order ODEs equation
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Missael Hernandez
am 6 Mai 2020
Kommentiert: Missael Hernandez
am 6 Mai 2020
I am trying to solve

This is what I have written as my finction script. everytime I try to solve it once I type the initial condiitions to the Command Windown, I get "Show complete stack trace." How can I solve my problem?
function theta_dot = pendulum(t,x)
theta_dot = [x(2);
-8.8*x(1)-1.8*x(3);
x(4);
1.8*x(1)+8.8*x(3)];
end
0 Kommentare
Akzeptierte Antwort
Bjorn Gustavsson
am 6 Mai 2020
After fixing the sign-errors in your ODE-function this:
thetathetadot0 = [0 0 0 -1];
[t,theta] = ode45(@(t,y) pendulum(t,y),0:0.1:10,thetathetadot0);
plot(t,theta)
works just fine.
HTH
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!