Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Paraphrase MatLab code.
- w=400*2*pi/60; %given omega 400 rpm (We know that omega=400rpm (Given))
- syms l2 l4 b1 b2 b3 b4 %unknowns
- %given
- l1=2.5;
- l3=1;
- l5=0;
- b5=pi/3;
- %1st equation (Equation 1)
- %b1+b2+b3+b4+b5==2*pi
- %2nd equation (Equation 2)
- %l1-l2-l3-l4==0
- %3rd equation (Equation 3)
- %-l3/b3==-40/w
- %4th equation (Equation 4)
- %-pi*l2/(2*b2)==-40/w
- %5th equation (Equatoin 5)
- %-2*l4/b4==-40/w
- %6th equation (Equatioh 6)
- %-pi^2*l2/(4*b2^2)==-5.2683*l1/b1^2
- %6 unknowns and 6 equations
- [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);
- L2=double(L2);L2=L2(2); %L2 had two answers and appropriate answer was picked
- L4=double(L4);L4=L4(2); %L4 had two answers and appropriate answer was picked
- B1=double(B1);B1=B1(2); %B1 had two answers and appropriate answer was picked
- B2=double(B2);B2=B2(2); %B2 had two answers and appropriate answer was picked
- B3=double(B3);B3=B3(2); %B3 had two answers and appropriate answer was picked
- B4=double(B4);B4=B4(2); %B4 had two answers and appropriate answer was picked
- L=[l1,L2,l3,L4,l5]; %L vector
- B=[B1,B2,B3,B4,b5]; %Beta vector
- %clean up the variable that wont be needed
- clear l1 l2 l3 l4 l5 b1 b2 b3 b4 b5 L2 L4 B1 B2 B3 B4
- theta=linspace(0,2*pi,1000); %theta in rad with 1000 data points
- n=length(theta); %size of theta
- %initial setup
- y=zeros(1,n);
- y_p=zeros(1,n);
- y_wp=zeros(1,n);
- for i=1:n
- if theta(i)<=B(1) %8th order polynomical
- 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 );
- 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 );
- 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 );
- elseif theta(i)<=B(1)+B(2) %H-3
- y(i)=L(1)-L(2) + L(2)*cos (pi * (theta(i)-B(1))/(2*B(2)) ) ;
- y_p(i)=-pi*L(2)/(2*B(2)) *sin(pi*(theta(i)-B(1))/(2*B(2)));
- y_wp(i)=-pi^2*L(2)/(4*B(2)^2) *cos(pi*(theta(i)-B(1))/(2*B(2)));
- elseif theta(i)<=B(1)+B(2)+B(3) %uniform
- y(i)=-L(3)/B(3)*(theta(i)-(B(1)+B(2)))+ L(1)-L(2);
- y_p(i)=-40/w;
- y_wp(i)=0;
- elseif theta(i)<=B(1)+B(2)+B(3)+B(4) %C-4
- 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)) ) ;
- y_p(i)=-L(4)/B(4) * (1+ cos(pi* (theta(i)-(B(1)+B(2)+B(3)))/B(4) ) );
- y_wp(i)=pi*L(4)/B(4)^2 * sin(pi*(theta(i)-(B(1)+B(2)+B(3)))/B(4));
- else %dwell
- y(i)=0;
- y_p(i)=0;
- y_wp(i)=0;
- end
- end
- theta_d=theta*180/pi; %theta in degree
- figure(1)
- plot(theta,y)
- title(‘y vs theta’)
- xlabel(‘theta (rad)’)
- ylabel(‘y (inch)’ )
- axis([0 2*pi 0 3])
- figure(2)
- plot(theta,y_p)
- xlabel(‘theta (rad)’)
- ylabel(‘y prime (inch/rad)’ )
- axis([0 2*pi -1 5])
- title(‘y prime vs theta’)
- figure(3)
- plot(theta,y_wp)
- title(‘y” vs theta’)
- xlabel(‘theta (rad)’)
- ylabel(‘y double prime (inch/rad^2)’ )
- axis([0 2*pi -15 15])
- %given
- Rr=0.5;
- e=1;
- Rp=2.5*2.75; % L * factor from the figure
- %initial setup
- R=zeros(1,n);
- gamma=zeros(1,n);
- lamda=zeros(1,n);
- Xf=zeros(1,n);
- Yf=zeros(1,n);
- phi=zeros(1,n);
- sigma=zeros(1,n);
- Xs=zeros(1,n);
- Ys=zeros(1,n);
- d=sqrt(Rp^2-e^2); %equation 1
- for i=1:n
- R(i)=sqrt(e^2+(d+y(i))^2 ); %equation 2
- gamma(i)=atan(e/(d+y(i))); %equation 3
- lamda(i)=theta(i)+gamma(i); %equation 4
- Xf(i)=R(i)*cos(lamda(i)); %equation 5
- Yf(i)=R(i)*sin(lamda(i)); %equation 5
- phi(i)=atan(y_p(i)/(Rp+y(i))); %equation 8
- sigma(i)=(theta(i)-phi(i)); %equation 6
- Xs(i)=Xf(i)-Rr*cos(sigma(i)); %equation 7
- Ys(i)=Yf(i)-Rr*sin(sigma(i)); %equation 7
- end
- figure(4)
- plot(Xs,Ys)
- grid on
- title(‘cam profile’)
- xlabel(‘inch’)
- ylabel(‘inch’)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement