%function to be integrated
function dy = secondode(t,y)
dy=zeros(4,1); %intialize dy to a 4x1 vector

%Define parameters
Ip = 47.5;  %kg-m^2
L=7/8;      %m
m=40;       %kg
M=100;      %kg
g=9.81;     %m/s^2
T=0;
f=263;
a=Ip;
b=-m*L*cos(y(3));
c=T+m*g*L*sin(y(3));
d=m+M;
e=-m*L*cos(y(3));
g=-m*L*sin(y(3))*y(4)*y(4)+f;

%State Vector = y = [x xdot phi phidot];
dy(1) = y(2);
dy(2)=(a*g-e*c)/(a*d-e*b);
dy(3)=y(4);
dy(4)=c/a - (b/a)*(a*g-e*c)/(a*d-e*b);
