CLC
CLC
clear
disp(' ');
b = input('Enter length of connecting rod (b) : '); % Length of connecting rod link
if c > a+b
return;
end
theta2 = input('Enter crank angle theta2 (in degrees): '); % Crank angle in degrees
omega2 = input('Enter angular velocity of crank (omega2): '); % Angular velocity of crank
alpha2 = input('Enter angular acceleration of crank (alpha2): '); % Angular acceleration of crank
theta2_r = deg2rad(theta2);
theta3 = rad2deg(theta3_r);
fprintf('Angular Position of Connecting Rod from Slider Axis : %.2f degree\n', theta3);
d = a*cos(theta2_r) - b*cos(theta3_r);
fprintf('Linear Position of Slider from fixed point of crank : %.2f mm\n', d);
omega3 = (a*cos(theta2_r)/(b*cos(theta3_r)))*omega2;
fprintf('Angular Velocity of Connecting Rod : %.2f rad/s\n', omega3);
alpha3 = (a*(alpha2)*cos(theta2_r)-
a*((omega2)^2)*sin(theta2_r)+b*((omega3)^2)*sin(theta3_r))/b*cos(theta3_r);
accslider = -a*(alpha2)*sin(theta2_r)-
a*((omega2)^2)*cos(theta2_r)+b*(alpha3)*sin(theta3_r)+b*((omega3)^2)*cos(theta3_r);
% Set up crank angle theta2 range (in degrees) for full rotation
theta3_array = zeros(size(theta2_range_deg));
velslider_array = zeros(size(theta2_range_deg));
accslider_array = zeros(size(theta2_range_deg));
for i = 1:length(theta2_range_deg)
theta2_r = deg2rad(theta2_range_deg(i));
theta3 = rad2deg(theta3_r);
% Store connecting rod angle theta3
theta3_array(i) = theta3_r;
d = a*cos(theta2_r) - b*cos(theta3_r);
omega3 = (a*cos(theta2_r)/(b*cos(theta3_r)))*omega2;
alpha3 = (a*(alpha2)*cos(theta2_r)-
a*((omega2)^2)*sin(theta2_r)+b*((omega3)^2)*sin(theta3_r))/(b*cos(theta3_r));
accslider = -a*(alpha2)*sin(theta2_r)-
a*((omega2)^2)*cos(theta2_r)+b*(alpha3)*sin(theta3_r)+b*((omega3)^2)*cos(theta3_r);
velslider_array(i) = velslider;
accslider_array(i) = accslider;
end
figure;
grid on;
% Plot Linear Acceleration of Slider vs. Crank Angle
figure;
grid on;