Code for Results

Code for Results

clear all clf clc a= 1.5; b_tot = 5.5; c = 4; d_tot = 5.3; f = 5.5; g = 1.85; h = 1; l = 3.5; k = 1.25; n = 4; crank = 0:1:360; theta1 = pi/2; for i = 1:length(crank) theta2 = deg2rad(crank(i)); if (theta2 > pi/2) && (theta2 <= (3/2*pi)) theta3 = atan(((a*sin(theta2))-c)/(a*cos(theta2)))-pi; else theta3 = atan(((a*sin(theta2))-c)/(a*cos(theta2))); end theta3deg(i) = rad2deg(theta3); b(i) = (a*sin(theta2)-c)/sin(theta3); b2 = b_tot - b(i); theta32 = abs(theta3); theta4 = atan(((b2*sin(theta32))-f)/((b2*cos(theta32))-g)); theta4deg(i) = rad2deg(theta4); dx(i) = (g-(b2*cos(theta32))); dy(i) = (f-(b2*sin(theta32))); d(i) = sqrt((dx(i)^2)+(dy(i)^2)); phi = atan((n-(b2+h))/k); phideg(i) = rad2deg(phi); m(i) = l - (k*(cos(phi))); end O = [0 0]; axis(gca, 'equal'); axis([-5 5 -2 10]) figure(1) for i = 1:length(crank) theta2 = deg2rad(crank(i)); theta3 = deg2rad(theta3deg(i)); theta4 = deg2rad(theta4deg(i)); A = a*[cos(theta2) sin(theta2)]; B = b_tot*[-cos(theta3) -sin(theta3)] + A; D = d(i)*[-(cos(theta4)) (sin(theta4))] + B; link2 = line([O(1) A(1)],[O(2) A(2)]); link3 = line([A(1) B(1)],[A(2) B(2)]); link4 = line([D(1) B(1)],[D(2) B(2)]); pin = viscircles([0, c],.01); pin2 = viscircles([-g, f+c], .01); pause(0.005); if i <length(crank) delete(link2) delete(link3) delete(link4) end end figure(2) plot(crank, theta3deg) title('Theta_3') figure(3) plot(crank, b) title('Length b_1') figure(4) plot( crank, d) title('Length d_1') figure(5) plot(crank, theta4deg) title('Theta_4') figure(6) plot(crank, phideg) title('Theta_5') figure(7) plot(crank, m) title('Length m')