%Plots the displacement , velocity , acceleration and jerk of a Cam follower with cycloidal motion
L=10;beta=120;for theta=0:0.2:120y=L*((theta/beta)-(sin(2*pi*theta/beta)/(2*pi)));y1=(L/beta)*(1-cos(2*pi*theta/beta));y2=(2*pi*L/beta^2)*sin(2*pi*theta/beta);y3=((4*pi^2*L)/(beta^3))*cos(2*pi*theta/beta);figure(1)subplot(2,1,1)plot(theta,y)hold onsubplot(2,1,2)plot(theta,y1)hold onfigure(2)subplot(2,1,1)plot(theta,y2)hold onsubplot(2,1,2)plot(theta,y3)hold onendfor theta=120:0.2:190 y=L*sin(pi/2); y1=(L/beta)*(1-cos(2*pi));y2=(2*pi*L/beta^2)*sin(2*pi);y3=((4*pi^2*L)/(beta^3))*cos(pi/2);figure (1)subplot(2,1,1)plot(theta,y)subplot(2,1,2)plot(theta,y1)figure(2)subplot(2,1,1)plot(theta,y2)subplot(2,1,2)plot(theta,y3)endbeta=90;for theta=190:0.2:280 omega=theta-190; y=L*(1-(omega/beta)+(sin(2*pi*omega/beta)/(2*pi)));y1=(-L/beta)*(1-cos(2*pi*omega/beta));y2=(-2*pi*L/beta^2)*sin(2*pi*omega/beta);y3=((-4*pi^2*L)/(beta^3))*cos(2*pi*omega/beta);figure(1)subplot(2,1,1)plot(theta,y)subplot(2,1,2)plot(theta,y1)figure(2)subplot(2,1,1)plot(theta,y2)subplot(2,1,2)plot(theta,y3)endfor theta=280:0.2:360 y=L*sin(pi); y1=(L/beta)*(1-cos(2*pi));y2=(2*pi*L/beta^2)*sin(2*pi);y3=((4*pi^2*L)/(beta^3))*cos(pi/2);figure(1)subplot(2,1,1)plot(theta,y)subplot(2,1,2)plot(theta,y1)figure(2)subplot(2,1,1)plot(theta,y2)subplot(2,1,2)plot(theta,y3)endfigure(1)subplot(2,1,1)xlabel('\theta');ylabel('Y');title('Displacement');subplot(2,1,2)xlabel('\theta');ylabel('Y1');title('1st Derivative(Velocity)');figure(2)subplot(2,1,1)xlabel('\theta');ylabel('Y2');title('2nd derivative(Acceleration)');subplot(2,1,2)xlabel('\theta');ylabel('Y3');title('3rd Derivative(Jerk)');
[EDITED, Please format your code, thanks]
Best Answer