function[dtheta_dt] = simple_pendulum(t,theta,b,m,g,l)
dtheta_dt = zeros(2,1);
b = 0.05;
l = 1;
g = 9.81;
m= 1;
% theta = linspace(0,3,3)
dtheta_dt(1) = theta(2);
dtheta_dt(2) = (-b/m)*theta(2)-(g/l)*sin(theta(1));
end
close all
clear all
clc
t = [0,20];
theta_0 = [0,3];
[t,theta] = ode45('simple_pendulum',t,theta_0);
plot(t, theta(:,1))
hold on
plot(t, theta(:,2))
grid on
xlabel('accelaration')
ylabel('velocity')
ct = 1;
for i = 1:length(theta(:,1))
X = theta(:,1);
X1 = X(i);
x0 = 0;
y0 = 0;
l = 1;
x1 = l*sin(X1);
y1 = -l*cos(X1);
%ploting pendulam
figure(2)
plot([-0.5 0.5],[0 0],'color','r');
hold on
plot([x0 x1],[y0 y1],'color','g');
hold on
plot(x1,y1,'marker','o','markerfacecolor','r');
hold off
grid on
axis([-1.5 1.5 -1.5 1.5])
M(ct) = getframe(gcf)
ct = ct+1
end
movie(M)
videofile = VideoWriter('Forward_kinematics.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)