Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. Paraphrase MatLab code.
  2.  
  3. w=400*2*pi/60; %given omega 400 rpm (We know that omega=400rpm (Given))
  4.  
  5. syms l2 l4 b1 b2 b3 b4 %unknowns
  6.  
  7. %given
  8. l1=2.5;
  9. l3=1;
  10. l5=0;
  11. b5=pi/3;
  12.  
  13. %1st equation (Equation 1)
  14. %b1+b2+b3+b4+b5==2*pi
  15.  
  16. %2nd equation (Equation 2)
  17. %l1-l2-l3-l4==0
  18.  
  19. %3rd equation (Equation 3)
  20. %-l3/b3==-40/w
  21.  
  22. %4th equation (Equation 4)
  23. %-pi*l2/(2*b2)==-40/w
  24.  
  25. %5th equation (Equatoin 5)
  26. %-2*l4/b4==-40/w
  27.  
  28. %6th equation (Equatioh 6)
  29. %-pi^2*l2/(4*b2^2)==-5.2683*l1/b1^2
  30.  
  31. %6 unknowns and 6 equations
  32. [L2,L4,B1,B2,B3,B4]=solve(b1+b2+b3+b4+b5==2*pi , l1-l2-l3-l4==0 , -l3/b3==-40/w , -pi*l2/(2*b2)==-40/w , -2*l4/b4==-40/w,-pi^2*l2/(4*b2^2)==-l1/b1^2*5.2683,l2,l4,b1,b2,b3,b4);
  33. L2=double(L2);L2=L2(2); %L2 had two answers and appropriate answer was picked
  34. L4=double(L4);L4=L4(2); %L4 had two answers and appropriate answer was picked
  35. B1=double(B1);B1=B1(2); %B1 had two answers and appropriate answer was picked
  36. B2=double(B2);B2=B2(2); %B2 had two answers and appropriate answer was picked
  37. B3=double(B3);B3=B3(2); %B3 had two answers and appropriate answer was picked
  38. B4=double(B4);B4=B4(2); %B4 had two answers and appropriate answer was picked
  39. L=[l1,L2,l3,L4,l5]; %L vector
  40. B=[B1,B2,B3,B4,b5]; %Beta vector
  41.  
  42. %clean up the variable that wont be needed
  43. clear l1 l2 l3 l4 l5 b1 b2 b3 b4 b5 L2 L4 B1 B2 B3 B4
  44.  
  45. theta=linspace(0,2*pi,1000); %theta in rad with 1000 data points
  46. n=length(theta); %size of theta
  47.  
  48. %initial setup
  49. y=zeros(1,n);
  50. y_p=zeros(1,n);
  51. y_wp=zeros(1,n);
  52.  
  53. for i=1:n
  54. if theta(i)<=B(1) %8th order polynomical
  55. y(i)=L(1)*(6.09755*(theta(i)/B(1))^3 -20.78040*(theta(i)/B(1))^5 +26.73155*(theta(i)/B(1))^6 -13.60965*(theta(i)/B(1))^7 + 2.56095*(theta(i)/B(1))^8 );
  56. y_p(i)=L(1)/B(1)*(18.29265*(theta(i)/B(1))^2 -103.90200*(theta(i)/B(1))^4 +160.38930*(theta(i)/B(1))^5 -95.26755*(theta(i)/B(1))^6 +20.48760*(theta(i)/B(1))^7 );
  57. y_wp(i)=L(1)/B(1)^2*(36.58530*(theta(i)/B(1)) -415.60800*(theta(i)/B(1))^3 +801.94650*(theta(i)/B(1))^4 -571.60530*(theta(i)/B(1))^5 +143.41320*(theta(i)/B(1))^6 );
  58. elseif theta(i)<=B(1)+B(2) %H-3
  59. y(i)=L(1)-L(2) + L(2)*cos (pi * (theta(i)-B(1))/(2*B(2)) ) ;
  60. y_p(i)=-pi*L(2)/(2*B(2)) *sin(pi*(theta(i)-B(1))/(2*B(2)));
  61. y_wp(i)=-pi^2*L(2)/(4*B(2)^2) *cos(pi*(theta(i)-B(1))/(2*B(2)));
  62. elseif theta(i)<=B(1)+B(2)+B(3) %uniform
  63. y(i)=-L(3)/B(3)*(theta(i)-(B(1)+B(2)))+ L(1)-L(2);
  64. y_p(i)=-40/w;
  65. y_wp(i)=0;
  66. elseif theta(i)<=B(1)+B(2)+B(3)+B(4) %C-4
  67. y(i)=L(4)*(1 – (theta(i)-(B(1)+B(2)+B(3)))/B(4) -1/pi * sin(pi*(theta(i)-B(1)-B(2)-B(3))/B(4)) ) ;
  68. y_p(i)=-L(4)/B(4) * (1+ cos(pi* (theta(i)-(B(1)+B(2)+B(3)))/B(4) ) );
  69. y_wp(i)=pi*L(4)/B(4)^2 * sin(pi*(theta(i)-(B(1)+B(2)+B(3)))/B(4));
  70. else %dwell
  71. y(i)=0;
  72. y_p(i)=0;
  73. y_wp(i)=0;
  74. end
  75. end
  76.  
  77. theta_d=theta*180/pi; %theta in degree
  78.  
  79. figure(1)
  80. plot(theta,y)
  81. title(‘y vs theta’)
  82. xlabel(‘theta (rad)’)
  83. ylabel(‘y (inch)’ )
  84. axis([0 2*pi 0 3])
  85.  
  86. figure(2)
  87. plot(theta,y_p)
  88. xlabel(‘theta (rad)’)
  89. ylabel(‘y prime (inch/rad)’ )
  90. axis([0 2*pi -1 5])
  91. title(‘y prime vs theta’)
  92.  
  93. figure(3)
  94. plot(theta,y_wp)
  95. title(‘y” vs theta’)
  96. xlabel(‘theta (rad)’)
  97. ylabel(‘y double prime (inch/rad^2)’ )
  98. axis([0 2*pi -15 15])
  99.  
  100. %given
  101. Rr=0.5;
  102. e=1;
  103.  
  104. Rp=2.5*2.75; % L * factor from the figure
  105.  
  106. %initial setup
  107. R=zeros(1,n);
  108. gamma=zeros(1,n);
  109. lamda=zeros(1,n);
  110. Xf=zeros(1,n);
  111. Yf=zeros(1,n);
  112. phi=zeros(1,n);
  113. sigma=zeros(1,n);
  114. Xs=zeros(1,n);
  115. Ys=zeros(1,n);
  116.  
  117. d=sqrt(Rp^2-e^2); %equation 1
  118.  
  119. for i=1:n
  120. R(i)=sqrt(e^2+(d+y(i))^2 ); %equation 2
  121. gamma(i)=atan(e/(d+y(i))); %equation 3
  122. lamda(i)=theta(i)+gamma(i); %equation 4
  123. Xf(i)=R(i)*cos(lamda(i)); %equation 5
  124. Yf(i)=R(i)*sin(lamda(i)); %equation 5
  125. phi(i)=atan(y_p(i)/(Rp+y(i))); %equation 8
  126. sigma(i)=(theta(i)-phi(i)); %equation 6
  127. Xs(i)=Xf(i)-Rr*cos(sigma(i)); %equation 7
  128. Ys(i)=Yf(i)-Rr*sin(sigma(i)); %equation 7
  129. end
  130.  
  131. figure(4)
  132. plot(Xs,Ys)
  133. grid on
  134. title(‘cam profile’)
  135. xlabel(‘inch’)
  136. ylabel(‘inch’)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement