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 = phiddotg=9.81; L=1; m=1;dydt = [y(2); ((-6*g*sin(y(1)))/(L*(1+3*(sin(y(1))^2))))];endfunction maincode = maint0=0;T=10; y0 = [60;0]; [ts,ys] = ode45(@phi_ddot,[t0,T],y0); plot(ts,ys(:,1),'r')end
Best Answer