# Angular Velocity

A piston-connecting rod-crank mechanism is used in many engineering applications. In the mechanism
given, the crank is rotating at a speed of ω radians per minute. Figure 1 has a rod that runs from a stationary point to a top point (non-stationary) that is at distance r and
the second rod is a distance c from the top point to the block. The height, h, is from the stationary point
to the top point and x is defined as the distance from the stationary point to the block (θ is the angle
between r and x). Your program will calculate the position, velocity and acceleration and plot the values
for one revolution of the crank. The three plots will be on the same figure as subplots. This assignment
requires a main m-file and three functions.

Program Steps

1. Ask the user to input values for r, c, and ω. The values input will be in millimeters for
the lengths and revolutions per minute for the angular velocity. You will need to then
convert these values to meters and radians per second. Also, calculate the time it takes
for one revolution .
2. Create a vector for time running from zero to the time it takes for one revolution. This
vector should contain exactly 250 values. Then, calculate θ (the angle between r and x)
using the equation .
2. Find the distance x using the equation This calculation must be
done in a function with three input arguments (r, c and θ) and one output argument (the
distance).
4. Find the velocity using the equation Asecond function must be used with four input arguments (r, c, ω and θ) and one outputargument (the velocity).
5. Determine the value of the acceleration using the equation third function must be used with four input arguments (same as in step 4) and one output
argument (the acceleration).
6. Plot the values in one figure (subplot of 1 column and 3 rows) with the distance in the
first plot, velocity in the second plot and acceleration in the third plot. Be sure to label
the x and y axes of each plot (time will be on the horizontal of each one).

Solution

acclcal.m

function a=acclcal(R,C,Theta,W)

temp1=-R.*cos(Theta)*W^2;

temp2=((4*(W^2).*cos(2*Theta)*R^2).*((C^2)-((R^2).*((sin(Theta)).^2))))+((W.*sin(2*Theta)*R^2).^2);

temp3=4*(((C^2)-((R^2).*((sin(Theta)).^2))).^1.5);

a=temp1-(temp2./temp3);

end

cs151f17assn5.m

% Piston connecting rod-crank mechanism %

%% step 1

prompt = ‘Enter the value of r in millimeter ‘;

r = input(prompt)

prompt = ‘Enter the value of c in millimeter ‘;

c = input(prompt)

prompt = ‘Enter the value of omega (angular velocity) in rev/minute ‘;

w=input(prompt)

R=r*1e-3;

C=c*1e-3;                   % conversions

W=w*(2*pi/60);

T=2*pi/W;

fprintf(‘value of r=%.3f meter \n’,R);

fprintf(‘value of c=%.3f meter \n’,C);

fprintf(‘value of time period=%.3f sec \n’,T);

%% step 2

T_vector=linspace(0,T,250);    % time vector

Theta=W.*T_vector;             % angle for each timing instant

%% step 3

x=xcal(R,C,Theta);             % calculated x vector in meter

%% step 4

v=velcal(R,C,Theta,W);         % calculated velocity vector in meters/sec

%% step 5

a=acclcal(R,C,Theta,W);        % calculated acceleration vector in meters/sec^2

%% step 6

figure

subplot(3,1,1)

plot(T_vector,x,’r’,’Linewidth’,2)

xlabel(‘Time (sec)’)

ylabel(‘Distance (m)’)

subplot(3,1,2)

plot(T_vector,v,’g’,’Linewidth’,2)

xlabel(‘Time (sec)’)

ylabel(‘Velocity (m/s)’)

subplot(3,1,3)

plot(T_vector,a,’b’,’Linewidth’,2)

xlabel(‘Time (sec)’)

ylabel(‘Acceleration (m/s^2)’)

velcal.m

function v=velcal(R,C,Theta,W)

v=(-R*W.*sin(Theta))-((W.*sin(2*Theta)*R^2)./(2*sqrt((C^2)-(R^2).*((sin(Theta)).^2))));

end

xcal.m

function x=xcal(R,C,Theta)

x=R.*cos(Theta)+sqrt((C^2)-(R^2).*((sin(Theta)).^2));

end