Week 2- 2R Robotic Arm Challenge

The first part without the for loop was tried to be executed but the line comand had no [] brackets defining the x and y coordinates, so to run the program i added the [].
% forward kinematics for 2R
% Input
l1= 1
l2= 2
theeta1= 45;
theeta2= 75;
x0= 0
y0= 0
x1= l1*cosd(theeta1);
y1= l1*sind(theeta1);
x2= x1+l2*cosd(theeta2);
y2= y1+l2*sind(theeta2);
line ([x0 x1], [y0 y1], 'linewidth',3, 'color','r');
line ([x1 x2], [y1 y2], 'linewidth', 3,'color','g');


the error here was not changing theeta 1 and theeta2 to THEETA1 and THEETA2

end command was typed only once and ended just the second for loop and not the first, so another end command was included.

Problem with movie file, the exact MATLAB command was not been given when checked the Movie would be movie and the following line command had spelling mistakes too, so chnaged the spellings to make it correct.
% movie of kinematics for 2R arm
% Input
l1 =2;
l2= 1;
ct=1;
theeta1= linspace(0,90,10);
theeta2=linspace(0,90,10);
for i= 1:length(theeta1)
Theeta1= theeta1(i);
for j= 1:length(theeta2)
Theeta2= theeta2(j);
x0= 0;
y0= 0;
x1= l1*cosd(Theeta1);
y1= l1*sind(Theeta1);
x2= x1+l2*cosd(Theeta2);
y2= y1+l2*sind(Theeta2);
plot ([x0 x1], [y0 y1],[x1 x2], [y1 y2], 'linewidth',3);
axis([-0.1 4, -1 4]);
%pause(0.3)
M(ct)= getframe(gcf);
ct=ct+1;
end
end
movie (M)
videofile= VideoWriter('forward_kinematics.avi');
open(videofile)
writeVideo(videofile,M)
close(videofile)
The length of ARM 1 is taken as 2 and the length of ARM 2 is 1, linspace comand is used for both theeta 1&2 which gives 10 equal intervals between 0-90 degrees. for loop is used to define every value of theeta 1&2 at every interval and a counter is used from 1 which keeps on increasing by 1 after every frame is played. PLot command helps in ploting both the arms and giving the actual positioning of the arms at different intervals and M is the ARRAY where we call every frame. movie command helps in generating a movie and then is saved by using videofile.