theta2 = 0:20; % theta 2 range theta1 = 0; theta = []; % empty vector used for storage of theta values from four bar pos/ function t_angle = 58; % transformation angle of local coordinate
% evaluate local thetas with four bar position functions
for j = 1:length(theta2) t_2 = (theta2(j)) + (360-t_angle); % find theta 2 in local coordinate by q = fourbar(Lprime,theta1,t_2,-1); theta(j,:) = q; end
theta(:,1)=58; theta(:,2)=theta2(:); theta(:,3:4)= theta(:,3:4) + t_angle; % convert back to angle in respect to global XY coordina
axis([-2 10 -2 5]) xlabel('x') ylabel('y') title('Position path') hold on plot(A(:,1),A(:,2),'r','LineWidth',2) plot(B(:,1),B(:,2),'k','LineWidth',2) plot(C(:,1),C(:,2),'b','LineWidth',2) plot(D(:,1),D(:,2),'g','LineWidth',2) legend('A','B','C','D') hold off
figure (2) %angular hold on title('Angular Velocity vs \theta_2') xlabel('\theta_2') ylabel('\omega') plot(theta2,w3,'r','LineWidth',2) plot(theta2,w4,'k','LineWidth',2) legend('\omega_3','\omega_4') hold off
figure (3) %linear hold on title('Linear Velocity vs \theta_2') xlabel('\theta_2') ylabel('V(in/s)') plot(theta2,VA.*ones(length(theta2),1),'r','LineWidth',2) plot(theta2,VB.*ones(length(theta2),1),'k','LineWidth',2) plot(theta2,VC,'b','LineWidth',2) plot(theta2,VD,'g','LineWidth',2) legend('VA','VB','VC','VD') hold off
figure (4) %angular hold on title('Angular Acceleration vs \theta_2') xlabel('\theta_2') ylabel('\alpha') plot(theta2,a3,'r','LineWidth',2) plot(theta2,a4,'k','LineWidth',2) legend('\alpha_3','\alpha_4') hold off
figure (5) %linear hold on title('Linear Acceleration vs \theta_2') xlabel('\theta_2') ylabel('A(in/s^2)') plot(theta2,AA,'r','LineWidth',2) plot(theta2,AB,'k','LineWidth',2) plot(theta2,AC,'b','LineWidth',2) plot(theta2,AD,'g','LineWidth',2) legend('A_A','A_B','A_C','A_D') hold off
% Video file name Filename = 'Kinematic analysis'; % Figure representing sinus function Figure = figure('Color','w'); hold('on'); % Creation of a Video object VR = VideoRecorder('Filename', Filename,... 'Fileformat', 'MPEG-4',... 'Figure', Figure,... 'Period', 0.05,... 'BusyMode', 'error'); % Saving start VR.start();
f(i)=getframe; end hold off VR.stop(); % Video_recorder reading Filename = get(VR,'Filename'); try winopen(Filename); catch ME error('Video_recorder "%s" cannot be read (%s).',Filenamename,ME.message);