This document contains MATLAB code written by Hafiz Muhammad Ayaz for his mechanical engineering assignment on forced harmonic vibration. The code generates plots of phase angle versus frequency ratio for various damping ratios. There are three sections that create plots for the phase angle in radians, phase angle in degrees, and tangent of the phase angle, all with respect to the frequency ratio. The document provides the student identification number and date and includes page numbers.
1 of 7
Download to read offline
More Related Content
Mv assignment (repaired)
1. MV ASSIGNMENT
HAFIZ MUHAMMAD AYAZ
12/15/2011
DEPARTMENT OF MECHANICAL ENGINEERING
2. MV ASSIGNMENT
% PROGRAM FOR XK/F0 WRT FREQUENCY RATIO
w_wn = 0:0.1:5;
zeta = [0 0.05 0.1 0.15 0.25 0.375 0.5 1];
col = ['y' 'm' 'c' 'r' 'b' 'g' 'k' 'b'];
i = size(zeta,2);
for j = 1:i
x = 1-((w_wn).^2);
y = 2*zeta(j)*w_wn;
exp2 = y./x;
plot(w_wn,abs(atand(exp2)),col(j));
hold on;
grid on;
legend('zeta = 0','zeta = 0.05','zeta = 0.1','zeta = 0.15','zeta =
0.25','zeta = 0.375','zeta = 0.5');
title('Forced Hormonic Vibration');
xlabel('Frequency Ratio');
ylabel('phi');
Hafiz Muhammad Ayaz 08-MECH-155 Page 2
3. MV ASSIGNMENT
% PROGRAM FOR PHASE ANGLE WRT FREQUECY RATIO
figure;
w_wn1 = 0:0.1:1;
w_wn2 = 1.1:0.1:5;
[w_wn] = [w_wn1,w_wn2];
zeta = [0 0.05 0.1 0.15 0.25 0.375 0.5 1];
col = ['y' 'm' 'c' 'r' 'b' 'g' 'k' 'b'];
i = size(zeta,2);
for j = 1:i
Hafiz Muhammad Ayaz 08-MECH-155 Page 3
4. MV ASSIGNMENT
x = 1-((w_wn1).^2);
y = 2*zeta(j)*w_wn1;
tanphi1 = (y./x);
phi1 = atand(tanphi1);
x = 1-((w_wn2).^2);
y = 2*zeta(j)*w_wn2;
tanphi2 = (y./x);
phi2 = atand(tanphi2) + 180;
phi = [phi1,phi2];
plot(w_wn,phi,col(j));
hold on;
grid on;
pause(1);
legend('zeta = 0','zeta = 0.05','zeta = 0.1','zeta = 0.15','zeta =
0.25','zeta = 0.375','zeta = 0.5','zeta = 1');
title('Forced Hormonic Vibration');
xlabel('Frequency Ratio');
ylabel('phi');
end
Hafiz Muhammad Ayaz 08-MECH-155 Page 4
5. MV ASSIGNMENT
% PROGRAM FOR TAN(PHASE ANGLE ) WRT FREQUENCY RATIO
figure;
w_wn = 0:0.1:5;
zeta = [0 0.05 0.1 0.15 0.25 0.375 0.5 1];
col = ['y' 'm' 'c' 'r' 'b' 'g' 'k' 'b'];
i = size(zeta,2);
for j = 1:i
x = 1-((w_wn).^2);
y = 2*zeta(j)*w_wn;
tanphi = y./x;
plot(w_wn,tanphi,col(j));
hold on;
grid on;
Hafiz Muhammad Ayaz 08-MECH-155 Page 5