Pendulum problem (subprogram source)

%
%   This is subfunction for ODE45 solver 
%   probelm 4.170
%

function xdot = p4_170_solver(t,x)

%
%   Constants and input variables
%

g = 9.81;            %  gravity
l = 1;               %  length of the bar

x_dot1 = x(2);
x_dot2 = (3*g)/(2*l)*sin(x(1));

xdot = [x_dot1; x_dot2];