Week 2- 2R Robotic Arm Challenge
Errors faced:
in line 25 command
M(ct)=getframe(gcf); it shows the error as "the varaible M appears to change size often so provide cell size."
action taken:
without any modifications the results came but dont understand what the error is
attached the screenshot of the error
youtube video link: https://youtu.be/6Nk0smEG-kk
% forward kinematics with movie command and frame command
%inputs
close all % closes all the previous plots
clear all % clears all the previous results
clc % clears all previous in command window
l1=1.5; % values for arm l1 and l2 are given
l2=1;
theta1=linspace(0,90,10); % for theta1 and theta2 10 values are taken from 0 to 90
theta2=linspace(0,90,10);
ct=1; % counter ct is given value as 1
for i=1:length(theta1) % for loop is initiated for 1 to 10 (length theta1)
THETA1=theta1(i); % THETA1 is assigned with value of theta1
for j=1:length(theta2) % another for loop is initiated for 1 to 10(length theta1)
THETA2=theta2(j); %THETA2 is assigned with value of theta2
x0=0; %inputs for x0,y0 are given.
y0=0;
x1=l1*cosd(THETA1); %x1,y1 are assigned with their respective cos and sin value
y1=l1*sind(THETA1);
x2=x1+l2*cosd(THETA2); %x2,y2 are assigned with updated x1,y1 and theta values
y2=y1+l2*sind(THETA2);
%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'LineWidth',3)% the plot is being done
axis([-1 2.5,0 2.5]) % the axis is being fixed
pause(0.03) %this command not needed while writing movie frame program
M(ct)=getframe(gcf); %each figures frame is being saved in M
ct=ct+1; % the counter is being initiated
end
end
movie(M) %matlab generates movie with all the m
videofile=VideoWriter('forward_kinematics_videos','Uncompressed AVI'); %videofile is
open(videofile) % the video file is opened
writeVideo(videofile,M) %the video file is written
close(videofile) %the video file is closed
%output explanation
%thevideo file is being played with all captured frames
% if the theta 1 and theta2 values are extended from 10 to 40 or more the video will be clear and can see the workspace clearly,