g = 9.8;
l = 0.5;

%

f = @(t, x) [x(2); -g * sin(x(1)) / l];

%

f(0, [0; 1])

%

wn = sqrt(g / l)

%

tn = 2 * pi / wn

%

theta_m = deg2rad(170)

%

[t, theta] = ode45(f, [0, 4 * tn], [theta_m; 0]);

%

figure
plot(t, theta(:,1))
hold on
plot(t, theta_m * cos(wn * t))
legend("simulation","equation")