ODE45 Returning Wrong Signed Answer
Afficher commentaires plus anciens
Hey, I have been struggling with this for the past few days. Basically, I have an equation that models the angular acceleration of a rigid body (pendulum). I want to integrate it twice (to get the plot of angle vs time). The angle should be decreasing, however, in my plot it is increasing. I can't seem to figure out why. The equation is correct, I suspect there is something I have implemented wrong.
Here is a sample of my code, first I have the function in its own file, then I use the main code with the input main. If you have any idea why it is producing the wrong answer please let me know
function dydt = phiddot
g=9.81; L=1; m=1;
dydt = [y(2); ((-6*g*sin(y(1)))/(L*(1+3*(sin(y(1))^2))))];
end
function maincode = main
t0=0;
T=10;
y0 = [60;0];
[ts,ys] = ode45(@phi_ddot,[t0,T],y0);
plot(ts,ys(:,1),'r')
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Lengths and Angles dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!