Graphing a nonlinear 2nd order differential equation?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I've searched around for a similar solution to what I'm looking for but I'm terrible at debugging. I need to graph this nonlinear 2nd order differential equation:
g = 9.81
m = 15000/g
L = 1.5 meters
J = m*L^2
J*theta_dd + m*L*g*sin(theta) = 0
0 commentaires
Réponses (1)
Ameer Hamza
le 19 Oct 2020
See ode45(): https://www.mathworks.com/help/matlab/ref/ode45.html espically the example titled "Solve Nonstiff Equation".
IC = [1; 0]; % initial condition
tspan = [0 10];
[t, theta] = ode45(@odefun, tspan, IC);
plot(t, theta);
legend({'$\theta$', '$\dot\theta$'}, 'FontSize', 16, 'Interpreter', 'latex');
function dtheta = odefun(t, theta)
% theta(1) = theta, theta(2) = theta_dot
g = 9.81;
m = 15000/g;
L = 1.5;
J = m*L^2;
dtheta1 = theta(2);
dtheta2 = -m*L*g*sin(theta(1))/J;
dtheta = [dtheta1; dtheta2];
end
2 commentaires
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!