https://youtu.be/tP1j_dVXQZI

EXPLANATION OF PROGRAM
% A program to simulate the forward kinematics of a 2R Robotic Arm
clear all
close all
clc
% Taking inputs
% Length of link-1 (L1) and link-2 (L2) in meter
L1 = 1 ;
L2 = o.5;
% Angle traced by link-1 in degrees (theta 1)
theta_1=linspace(0,90,9);
% Angle traced by link-2 in degrees (theta_2)
theta_2=linspace(0,90,19);
% Initialising base coordinates of link-1
x_0 = 0;
y_0 = 0;
ct=1;
for i=1:length (theta_1)
THETA_1 = theta_1(i);
for j= 1: length (theta_2)
THETA_2=theta_2(j);
% Calculating the coordinates of end point of link-1
x_1=x_0+L1*cosd(THETA_1);
y_1=y_0+L1*sind(THETA_1);
% Calculating the coordinates of the end of link-2
% End coordinates for link-1 are the start coordinates for link-2
x_2=x_1+L2*Cosd(THETA 2);
y_2=y_1+L2*sind(THETA_2);
% Plotting the robotic arm for simulation
plot([x_0 x_1],[y_0 y_1],[x_1 x_2],[y_1 y_2],"linewidth",2) ;
axis([-0.1 1.5 0 1.5]);
% Pausing the current plot for a while before movoing to the next
%plot
pause(0.03);
% Capturing the current plot to combine later
M(ct) = getframe(gcf);
% Incrementing ct so that each frame is captured in M
ct=ct+1;
end
%Making a movie from collected frames
movie(M);
% Creating a video file of ".avi' format to save the animation
videofile=VideoWriter('forward_kinematics_of_2R_robotic_arm.avi','UncompressedAVI');
open (videofile);
% Writing the movie in the videofile created
writeVideo(videofile, M);
close(videofile);