% inputs
l1= 1;
l2= 0.6;
theta1= linspace(0,90,10);
theta2= linspace(0,90,10);
for i= 1:length(theta1)
THETA1= theta1(i);
for j= 1:length(theta2)
THETA2= theta2(j);
%coordinates
x1 = 0;
y1 = 0;
x2 = l1*cosd(THETA1);
y2 = l1*sind(THETA1);
x3 = x2 + l2*cosd(THETA2);
y3 = y2 + l2*sind(THETA2);
%plotting
line([x1 x2],[y1 y2],'linewidth',3,'Color','b')
line([x2 x3],[y2 y3],'linewidth',3,'color','r')
pause(0.3);
end
end
The lengths of the arms were taken randomly.The 10 different angles were given to theta1 and theta2.To taking each and every angle of the theta1 with respective to theta2 for loop was used.loop was used for taking single angle of the first arm to the all angles of the second arm.