This action might not be possible to undo. Are you sure you want to continue?
Simple Vibration Problems with MATLAB (and
Some Help from MAPLE)
Original Version by Stephen Kuchnicki
December 7, 2009
Contents
Preface ix
1 Introduction 1
2 SDOF Undamped Oscillation 3
3 A Damped SDOF System 11
4 Overdamped SDOF Oscillation 17
5 Harmonic Excitation of Undamped SDOF Systems 23
6 Harmonic Forcing of Damped SDOF Systems 33
7 Base Excitation of SDOF Systems 39
8 SDOF Systems with a Rotating Unbalance 51
9 Impulse Response of SDOF Systems 61
10 Step Response of a SDOF System 67
11 Response of SDOF Systems to Square Pulse Inputs 77
12 Response of SDOF System to Ramp Input 89
13 SDOF Response to Arbitrary Periodic Input 95
14 Free Vibration of MDOF Systems 101
15 Damping of MDOF Systems 113
16 A Universal Vibration Solver 123
17 Modeling a van der Pol Oscillator 133
18 Random Vibration and Matlab 141
v
vi CONTENTS
19 RandomlyExcited Du¢ng Oscillator 149
20 Monte Carlo Simulation of a Random System 157
21 Conclusion 165
Preface
This document is companion to the text: Mechanical Vibration: Analysis, Un
certainties and Control, by Haym Benaroya and Mark Nagurka, CRC Press
2010; contact: benaroya@rci.rutgers.edu; mark.nagurka@marquette.edu
ix
Chapter 1
Introduction
This document is intended as a companion to Mechanical Vibration: Analy
sis, Uncertainties, and Control by Haym Benaroya and Mark Nagurka. This
companion draws heavily upon the Matlab software package, produced by the
MathWorks, Inc. We do not intend to teach Matlab in this work; rather, we
wish to show how a vizualization tool like Matlab can be used to aid in solution
of vibration problems, and hopefully to provide both the novice and the experi
enced Matlab programmer a few new tricks with which to attack their problems
of interest.
Matlab (Matrix Laboratory) was born from the LINPACK routines written
for use with C and Fortran. The Matlab package provides both commandline
and programming language interfaces, allowing the user to test simple state
ments at the command prompt, or to run complicated codes by calling a func
tion name. Matlab is excellent for handling matrix quantities because it as
sumes every variable is an array. Thus, calling on the multiplication operator
alone causes Matlab to attempt matrix, not scalar multiplication. Also, Mat
lab includes special “array operators” that allow multiplication of arrays on an
elementbyelement basis. For example, if we set the variable a = [1 2 3] and
/ = [4 5 6]. we can perform the matrix multiplications:
c = a + /
0
(1.1)
d = a
0
+ / (1.2)
(Note that the apostrophe is the transpose operator in Matlab.) The result
c would be a scalar (speci…cally, 32). The variable d would contain a 3by3
matrix, whose rows would be scalar multiples of /. However, what if the values
stored in a are three masses, and those in / their corresponding accelerations?
If we wished to …nd the force on each mass, we would need to multiply the
…rst element of a by the …rst element of /. and so on for the second and third
elements. Matlab provides “array multiplication” for such an instance:
c = a. + / (1.3)
1
2 CHAPTER 1 INTRODUCTION
Take special note of the period between a and the asterisk. This tells Matlab
to ignore its usual matrix multiplication rules, and instead create c by multi
plying the corresponding elements of a and /. The result here would be c = [4
10 18]. This is one of the more useful specialized commands in Matlab, and one
we will use frequently. Other commands will be discussed as they arise.
The vast majority of these examples will use Matlab in its programming
mode. The general format is to introduce a problem, with reference to the
text where applicable, and to show the analytic solution (if derivable). Several
…gures follow each example, showing results of each vibration problem under
di¤erent sets of parameters and making use of Matlab’s integrated graphics
capabilities. Finally, the Matlab code used to generate the …gures is presented,
with comments explaining what was done, why it was done, and other ways
it could have been done in Matlab. The code should look somewhat familiar
to those who have used C and Fortran in the past; Matlab’s language shares
several common structures with both of these languages, making it relatively
easy for an experienced C or Fortran programmer to learn Matlab.
One distinction to make with Matlab programming is between script m…les
and function m…les. Both are sets of commands that are saved in a …le. The
di¤erences are that variables used in a script …le are retained in the Matlab
workspace and can be called upon after the script completes. Variables within a
function m…le cannot be used outside of the function unless they are returned
(much like C functions or Fortran subroutines). Additionally, a function must
begin with the line function ontjnt = 1n:ctio:_:a:c(·ar1. ·ar2. ...·ar·).
This line tells the Matlab interpreter that this …le is a function separate from
the workspace. (Again, the form should look familiar to Fortran and C pro
grammers.)
Chapter 2
SDOF Undamped
Oscillation
The simplest form of vibration that we can study is the single degree of freedom
system without damping or external forcing. A sample of such a system is shown
in Figure 2.1. A freebody analysis of this system in the framework of Newton’s
second law, as performed in Chapter 2 of the textbook, results in the following
equation of motion:
:
..
r + /r = 0. (2.1)
(In general, we would have the forcing function 1 (t) on the righthand side;
it’s assumed zero for this analysis.) Dividing through by :. and introducing
the parameter .
n
=
/´:. we obtain a solution of the form
r(t) = ¹sin(.
n
t + c). (2.2)
or, in terms of the physical parameters of the system, we have
r(t) =
.
2
n
r
2
o
+ _ r
2
o
.
n
cos(.
n
t ÷tan
1
_ r
o
.
n
r
o
). (2.3)
From this, we see that the complete response of an undamped, unforced, one
degree of freedom oscillator depends on three physical parameters: .
n
, r
o
, and
_ r
o
: the natural frequency, initial velocity, and initial displacement, respectively.
3
4 CHAPTER 2 SDOF UNDAMPED OSCILLATION
Figure 2.1: Typical single degree of freedom free oscillator.
From the de…nition of the natural frequency, we see that it is inversely pro
portional to
:, and is directly proportional to
/. Variation of mass or
sti¤ness, then, will cause a variation in the frequency of vibration. The graphs
on the following pages demonstrate these sensitivities. Figure 2.2 shows the
variation of the vibrational characteristics for an increasing mass while sti¤ness
remains constant. Figure 2.3 shows how the oscillatory behavior changes for
increasing sti¤ness with mass constant. For both Figures 2.2 and 2.3, the initial
velocity used was _ r
o
= 1, and the initial displacement r
0
= 3. Note that the
frequency decreases with increasing mass, but increases with increasing sti¤ness,
as expected.
Looking at Equation 2.3, it is evident that the phase angle and maximum
amplitude are also functions of the natural frequency. Again, referring to Figure
2.2, the maximum amplitude decreases with increasing mass, due to the corre
sponding reduction in natural frequency. As a result, the phase shift diminishes,
with the peak of oscillation becoming nearer to t = 0. Note that the maximum
displacement would occur at t = 0 if the initial velocity were zero. It is easily
veri…ed that, for this case, the parameter ¹ (from Equation 2.2, above) reduces
to r
o
, and the phase angle becomes ta:
1
(0´r
2
o
), or 0
.
In Figure 2.3, the maximum amplitude increases with increasing sti¤ness,
due to the increase in natural frequency. The phase angle also increases with
the sti¤ness, so the maximum amplitude of oscillation occurs at an increasingly
later time with increasing sti¤ness.
The MATLAB code used to produce the graphs follows. The input state
ments in the …rst few lines demonstrate one type of interactive programming
available in MATLAB. The portion of the statement inside the quotation marks
will appear on the screen when the program is run, so user prompts are easily
added and explained. The initialization and use of the mass matrix is demon
strated in two ways. If the variable :at1ao is set to zero, then the masses are
each given scalar values. If this ‡ag is set to one, then the masses are initialized
as part of an array. This is done to demonstrate the use of MATLAB array
5
variables and to show how they can help streamline your code. Note also that
the if..then structure in MATLAB is similar to that of Fortran in that these
statements must be closed with an end statement, as must any other loop (for
or do, for example). We also demonstrate MATLAB’s plotting routines via the
subplot command, allowing plots for all three masses to be placed on the same
axes. The second …gure below was produced by modifying the code below to
take three sti¤nesses and one mass. The modi…cations necessary are left as an
exercise for the reader.
Finally, those unfamiliar with MATLAB are probably wondering what all
the semicolons are after each line. By default, MATLAB prints the results
of each operation to the screen. However, placing a semicolon at the end of
a line suppresses this output. Since printing to screen takes time and mem
ory for MATLAB to perform, suppressing screen output of intermediate results
increases computational speed. (The reader is invited to remove all the semi
colons from the program to see the di¤erence!) This feature is also a very useful
debugging tool. Instead of inserting and removing print statements to check
intermediate calculations, the programmer can insert and delete semicolons.
6 CHAPTER 2 SDOF UNDAMPED OSCILLATION
Program 11: varym.m
% The …rst few lines obtain the desired parameter values.
% This could also be done by using assignment statements in
% the program, but then the program would need to be
% edited to change the parameters. As written, parameters
% can be changed by rerunning the program.
%
mat‡ag=0; % Set to 1 to activate mass array, zero for mass scalars.
k=input(’Enter the sti¤ness value. ’);
x0=input(’Enter the initial displacement. ’);
v0=input(’Enter the initial velocity. ’);
tf=input(’Enter the time duration to test, in seconds. ’);
if (mat‡ag)
for i=1:3
m(i)=input([’Enter mass value ’, num2str(i),’. ’]);
% More about the ’num2str’ command below.
end
else
m1=input(’Enter the …rst mass value. ’);
m2=input(’Enter the second mass value. ’);
m3=input(’Enter the third mass value. ’);
end
%
% This loop initializes the natural frequency values. This
% is more streamline by making a mass matrix [ :(1) instead
% of :1, etc.], as shown. Note that the natural frequency is stored
% in a matrix.
%
if (mat‡ag)
wn=sqrt(k./m);
%
% Array division, akin to the array
% multiplication described above. This one line produces a three
% element array of natural frequencies. Compare to
% the machinations below.
%
else
for i=1:3
switch i % Analogous to the C command; saves a lot of “if” state
ments.
case 1
m=m1;
case 2
m=m2;
case 3
m=m3;
7
end
wn(i)=sqrt(k/m);
end
end
%
% Now, the values for A and phi in the expression
% x(t)=Asin(wn*t + phi) are evaluated. Notice that, in
% order for the cosine function to evaluate properly in
% MATLAB, the wn vector is used element by element
% (thus, the loop).
%
t=0:tf/1000:tf; % We need only initialize the time increment once.
for j=1:3
a=sqrt(wn(j)^2*x0^2+v0^2)/wn(j); % The caret is the power operator.
phi=atan2(v0,wn(j)*x0); % atan2 is the fourquadrant arctangent.
x(j,:)=a*cos(wn(j)*tphi);
end
%
% Since this program was made to compare di¤erent
% parameters, a subplot format makes sense. If the number
% of varied masses is changed, the subplot statement must
% also be.
%
subplot(3,1,1)
plot(t,x(1,:))
%
% This line demonstrates the use of the num2str command.
% This command allows the value of a variable to be used
% in a title or other text. Note that the command doesn’t
% work unless the text intended as a title is enclosed in
% brackets as well as parentheses.
%
if (mat‡ag)
title([’Response for m=’,num2str(m(1)), ’, k=’, num2str(k)])
else
title([’Response for m=’,num2str(m1), ’, k=’, num2str(k)])
end
ylabel(’Response x’)
grid
subplot(3,1,2)
plot(t,x(2,:))
if (mat‡ag)
title([’Response for m=’,num2str(m(2)), ’, k=’, num2str(k)])
else
title([’Response for m=’,num2str(m2), ’, k=’, num2str(k)])
8 CHAPTER 2 SDOF UNDAMPED OSCILLATION
end
ylabel(’Response x’)
grid subplot(3,1,3)
plot(t,x(3,:))
if (mat‡ag)
title([’Response for m=’,num2str(m(3)), ’, k=’, num2str(k)])
else
title([’Response for m=’,num2str(m3), ’, k=’, num2str(k)])
end
ylabel(’Response x’)
xlabel(’Time, seconds’)
grid
0 5 10 15 20 25 30
5
0
5
Response for m=2, k=8
R
e
s
p
o
n
s
e
x
0 5 10 15 20 25 30
5
0
5
Response for m=4, k=8
R
e
s
p
o
n
s
e
x
0 5 10 15 20 25 30
5
0
5
Response for m=12, k=8
R
e
s
p
o
n
s
e
x
Time, seconds
Figure 2.2: Responses for three di¤erent masses.
9
0 5 10 15 20 25 30
5
0
5
Response for m=5, k=2
R
e
s
p
o
n
s
e
x
0 5 10 15 20 25 30
5
0
5
Response for m=5, k=6
R
e
s
p
o
n
s
e
x
0 5 10 15 20 25 30
5
0
5
Response for m=5, k=13
R
e
s
p
o
n
s
e
x
Time, seconds
Figure 2.3: Responses for three di¤erent sti¤nesses.
Chapter 3
A Damped SDOF System
In the previous example, we examined the response of an undamped single
degree of freedom oscillator subject to varied mass and sti¤ness parameters.
Here we will do the same for a damped single degree of freedom system.
Again, we begin with the equation of motion, given the system of Figure 3.1.
A simple static analysis …nds that our equation is:
:
..
r + c
.
r + / r = 0. (3.1)
If we divide through by :, we introduce the dimensionless parameters . and
c:
..
r + 2c.
n
.
r + .
2
n
r = 0. (3.2)
In the above, .
n
represents the undamped natural frequency, and c is the
viscous damping ratio. For the purposes of this example, we will assume the
underdamped case (c < 1). The solution to this equation is:
r(t) = ¹c
t.n
sin(.
J
t + c). (3.3)
In Equation 3.3, .
J
is the damped natural frequency, equal to .
n
1 ÷c
2
.
This equation is more useful if we write all of the terms as functions of
parameters .
n
and c:
11
12 CHAPTER 3 A DAMPED SDOF SYSTEM
Figure 3.1: Typical damped single degree of freedom oscillator.
r(t) =
(·
o
+ c.
n
r
o
)
2
+
r
o
.
n
1 ÷c
2
2
.
n
1 ÷c
2
2
c
(t.n)
sin
¸
.
n
1 ÷c
2
t + tan
1
r
o
.
n
1 ÷c
2
·
o
+ c.
n
r
o
¸
. (3.4)
In this expression, the term .
n
1 ÷c
2
has been substituted for .
J
.
While this equation admittedly looks intimidating, note that it only depends
on four quantities: r
o
, ·
o
, .
n
, and c. Note the similarity between the parameters
identi…ed here and the ones relevant to the undamped case; the only di¤erence
is the addition of the viscous damping coe¢cient. So, we have already seen the
e¤ects of changing all of the parameters except the damping coe¢cient. Figure
3.2 gives the variation of the response with increasing viscous damping coe¢cient
for r
o
= 3. ·
o
= 1. and .
n
= 7. Note how quickly the response becomes virtually
zero; this occurs within ten seconds, even for a damping coe¢cient as small as
0.05!
The MATLAB code used to generate the …gure follows. This code is, in
many ways, similar to the code used earlier for the mass and sti¤ness parameter
studies. However, since both the exponential term and the sine term in our
solution (Equation 3.3) depend on time, they are both vector quantities. To
multiply them properly, we must use the array multiplication operator, ’.*’.
The code again makes use of input statements to initialize the parameters.
This time, however, the damping ratios are entered in array form only. The
algorithm chosen to produce the plots works only for the underdamped case;
since we have the term .
J
=
.
n
1 ÷c
2
in the denominator of our response
equation, c = 1 will cause division by zero, and c 1 will give an imaginary
damped natural frequency. We employ some defensive programming to ensure
13
allowable values for the damping ratio are entered. Conveniently, this gives us a
reason to introduce the while loop, analogous to the “do while” loop in Fortran.
The code checks each value zeta(zi) to see if it lies between zero and one. If
not, a somewhat abrupt reminder is sent to the screen, and the loop asks for a
new entry. Otherwise, it continues to the next damping ratio value. The logical
and relational operators in MATLAB are for the most part intuitive. Thus,
if a0 simply means “if a is greater than zero.” A full list can be found by
typing help ops at the MATLAB prompt; we will explain the ones we use in
comments.
14 CHAPTER 3 A DAMPED SDOF SYSTEM
Program 21: varyzeta.m
%Initial value entry.
%The while loop in the zeta initialization section prevents
%certain values for zeta from being entered, since such
%values would crash the program.
%
wn=input(’Enter the natural frequency. ’);
x0=input(’Enter the initial displacement. ’);
v0=input(’Enter the initial velocity. ’);
tf=input(’Enter the time duration to test, in seconds. ’);
for zi=1:3
zeta(zi)=12;
while(zeta(zi)<0 [ zeta(zi)=1) % The pipe ([) means “or”.
zeta(zi)=input([’Enter damping coe¢cient value ’, num2str(zi),’.
’]);
if (zeta(zi)=1 [ zeta(zi)<0)
fprintf(’Zeta must be between 0 and 1!’);
zeta(zi)=12;
end
end
end
%
%Now, having .
n
and c, the .
J
values can be found.
%
for i=1:3
wd(i)=wn*sqrt(1zeta(i)^2);
end
%
%Solving for the response. Note the use of the array
%multiplication command (.*) in the expression for r(t).
%This command is necessary, else the program gives a
%multiplication error.
%
t=0:tf/1000:tf;
for j=1:3
a=sqrt((wn*x0*zeta(j)+v0)^2+(x0*wd(j))^2)/wd(j);
phi=atan2(wd(j)*x0,v0+zeta(j)*wn*x0);
x(j,:)=a*exp(zeta(j)*wn*t).*sin(wd(j)*t+phi);
end
%
%Now, the program plots the results in a subplot format.
%
subplot(3,1,1)
plot(t,x(1,:))
title([’Response for zeta=’,num2str(zeta(1))])
ylabel(’Response x’)
15
grid
subplot(3,1,2)
plot(t,x(2,:))
title([’Response for zeta=’, num2str(zeta(2))])
ylabel(’Response x’)
grid
subplot(3,1,3)
plot(t,x(3,:))
title([’Response for zeta=’, num2str(zeta(3))])
ylabel(’Response x’)
xlabel(’Time, seconds’)
grid
16 CHAPTER 3 A DAMPED SDOF SYSTEM
0 1 2 3 4 5 6 7 8 9 10
5
0
5
Response for zeta=0.05
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
2
0
2
4
Response for zeta=0.2
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
2
0
2
4
Response for zeta=0.5
R
e
s
p
o
n
s
e
x
Time, seconds
Figure 3.2: Responses for various zeta values.
Chapter 4
Overdamped SDOF
Oscillation
The previous example is valid only for the underdamped case, c < 1. But what
happens when this condition is not met? There are two cases to explore: c 1
(the overdamped case), and c = 1 (the critically damped case). First, we need
to see how these cases arise in order to understand what the results will be. The
equation of motion of a damped single degree of freedom oscillator is:
..
r + 2c.
n
.
r + .
2
n
r = 0. (4.1)
Assume a solution of the form ¹c
X
, substitute it appropriately into Equation
4.1, and obtain the quadratic formula de…ning possible values for `:
` = ÷c.
n
±.
n
c
2
÷1. (4.2)
Note that the quantity inside the radical is always greater than zero, since
we have assumed c 1. Therefore, the solution of the equation of motion is
r(t) = c
t.n
(a
1
c
.n
t
2
1
+ a
2
c
.n
t
2
1
). (4.3)
If we again take our initial displacement as r
o
and initial velocity ·
o
, the
constants a
1
. a
2
become
a
1
=
÷·
o
+ (÷c +
c
2
÷1).
n
r
o
2.
n
c
2
÷1
. a
2
=
·
o
+ (c +
c
2
÷1).
n
r
o
2.
n
c
2
÷1
. (4.4)
17
18 CHAPTER 4 OVERDAMPED SDOF OSCILLATION
Equation 4.3 is a decaying exponential and the system will simply return to
its initial position instead of oscillating about the equilibrium. This is shown
in Figure 4.1. Note that if c = 1, a singularity exists in the constants; a
second independent solution must be found. From our knowledge of ordinary
di¤erential equations, we can …nd
r(t) = (a
1
+ a
2
t)c
.n
. (4.5)
where a
1
= r
o
. and a
2
= ·
o
+ .
n
r
o
.
Figure 4.1 was generated for .
n
= 7. r
o
= 3. and i
o
= 1. Notice how the
critically damped response returns to equilibrium faster than the others. For
the plots in the …gure, the motion with critical damping is stopped after about
two seconds, while the others do not reach equilibrium until more than eight
seconds. This is the distinguishing characteristic of the critically damped case.
Note also that the motion of the masses is, as expected, purely exponential;
there is no oscillation, only a decay of the response to equilibrium.
The MATLAB code is again presented below. The astute reader may ask
why the codes for underdamped, critically damped, and overdamped vibration
could not be combined into a single code. Certainly they can be; the modi…
cations are left to the reader. The resulting code should reject negative values
for the damping ratio. (Hint: You may …nd the switch command to be useful,
especially when used with its otherwise case.)
19
Program 31: overdamp.m
%Initial value entry. The while loop in the zeta initialization
%section prevents illegal values for zeta from being entered,
%since such values would crash the program.
%
wn=input(’Enter the natural frequency. ’);
x0=input(’Enter the initial displacement. ’);
v0=input(’Enter the initial velocity. ’);
tf=input(’Enter the time duration to test, in seconds. ’);
for zi=1:3
zeta(zi)=0.12;
while(zeta(zi)<1)
zeta(zi)=input(’Enter a damping coe¢cient value. ’);
if zeta(zi)<1
fprintf(’Zeta must be greater than 1!’);
zeta(zi)=0.12;
end
end
end
%
%Solving for the response. Notice that the variable den is used
%for the denominator of the constants, as well as the exponent
%values. If a variable can be created that will serve several
%purposes, it will save time and typing. (imagine typing the
%expression for den three times and you’ll understand).
%
t=0:tf/1000:tf;
for j=1:3
if zeta(j)1
a1n=v0+(zeta(j)+(zeta(j)^21)^0.5)*wn*x0;
a2n=v0+(zeta(j)+(zeta(j)^21)^0.5)*wn*x0;
den=wn*(zeta(j)^21)^0.5;
a1=a1n/(2*den);
a2=a2n/(2*den);
x(j,:)=(a1*exp(den*t)+a2*exp(den*t)).*exp(zeta(j)*wn*t);
elseif zeta(j)==1
a1=x0;
a2=v0+wn*x0;
x(j,:)=(a1+a2*t).*exp(wn*t);
end
end
%Now, the program plots the results in a subplot format.
%
subplot(3,1,1)
plot(t,x(1,:))
title([’Response for zeta=’,num2str(zeta(1))])
20 CHAPTER 4 OVERDAMPED SDOF OSCILLATION
ylabel(’Response x’)
grid
subplot(3,1,2)
plot(t,x(2,:))
title([’Response for zeta=’, num2str(zeta(2))])
ylabel(’Response x’)
grid
subplot(3,1,3)
plot(t,x(3,:))
title([’Response for zeta=’, num2str(zeta(3))])
ylabel(’Response x’)
xlabel(’Time, seconds’)
grid
21
0 1 2 3 4 5 6 7 8
0
2
4
Response for zeta=7
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8
0
2
4
Response for zeta=5
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8
0
2
4
Response for zeta=1
R
e
s
p
o
n
s
e
x
Time, seconds
Figure 4.1: Response of three overdamped systems.
Chapter 5
Harmonic Excitation of
Undamped SDOF Systems
In the previous examples, we examined the responses of single degree of freedom
systems which were not subjected to an external force. Now, we will examine
the e¤ects of an external force on the system. We begin with the simplest form
of external forcing: the harmonic load.
The system under consideration is shown in Figure 5.1. The forcing function
is assumed to be of the form 1(t) = 1
o
cos .t, where . is the driving frequency.
For the case with no damping, Newton’s Second Law gives us the equation of
motion :
..
r + /r = 1
o
cos .t. or
..
r + .
2
n
r = 1
o
cos .t. (5.1)
where 1
o
= 1
o
´:. We know the solution for the response r(t) to be:
r(t) = ¹
1
sin.
n
t + ¹
2
cos .
n
t +
1
o
.
2
n
÷.
2
cos .t. (5.2)
where
¹
1
=
·
o
.
n
. ¹
2
= r
o
÷
1
o
.
2
n
÷.
2
. (5.3)
The key parameters which de…ne the response are the natural and driving
frequencies, or more precisely, their ratio .´.
n.
Figure 5.2 shows the e¤ect of
varying driving frequency . for a given natural frequency, and Figure 5.3 does
23
24CHAPTER5 HARMONIC EXCITATIONOF UNDAMPED SDOF SYSTEMS
Figure 5.1: Model of a single degree of freedom subject to an external force.
the same for various natural frequencies .
n
. In these calculations, ·
o
= 0. r
o
=
0. 1
o
= 6. Making the initial conditions zero allows us to better see the e¤ects
of varying frequencies.
Note that two of the three constants in the expression for r(t) involve the
di¤erence between the frequencies. This gives rise to two interesting phenomena:
beats and resonance. Beats occur when the natural frequency and the driving
frequency are close but not equal. The result is then a rapid oscillation with a
slowly varying amplitude, as shown in Figure 5.4. Note how the both the rapid
oscillation and the slow change of the amplitude both vary along a sinusoid.
When the driving and natural frequencies are equal, . = .
n
. resonance is
the result. The third term in Equation 5.2 is not valid as a particular solution
of the governing equation of motion. Instead, the particular solution is
r
µ
(t) =
1
o
2.
n
t sin.
n
t. (5.4)
This term is the heart of the resonance problem; the amplitude of oscillation
will increase without limit. In a real system, the sti¤ness element has a certain
yield point which will be met and exceeded by a resonant vibration. Figure 5.5
shows resonant vibration.
25
The MATLAB code below uses the subplot command more elegantly than
we had in earlier examples. Instead of typing out three separate sets of plotting
commands, the subplots are done in a loop. A simple (and natural) modi…cation
to this program would be to change the number of plots in the subplot. This
could be done by introducing an integer variable :jot and changing the loops
to run from one to :jot instead of one to three. From a practical point of
view, though, introducing too many plots to the …gures would make the plot
unreadable, so care must be taken. Also, we’ve changed the parameter values
from dynamic inputs to static values. They can easily be changed back to user
inputs.
26CHAPTER5 HARMONIC EXCITATIONOF UNDAMPED SDOF SYSTEMS
Program 41  varywdr.m
%This program is very straightforward. The program takes
%the necessary input values to solve Equation
%5.3 for three di¤erent driving
%frequencies, checks for resonance (since we don’t want to
%handle that problem yet), and plots.
%
%This …le varies driving frequency of a single degree
%of freedom undamped oscillator at a set natural
%frequency. The initial displacement is 3, the velocity is
%1, the force magnitude per unit mass is 6, and the
%natural frequency is 7.
wn=7;
x0=0;
v0=0;
f0=6;
tf=10;
wdr=zeros(3,1);
x=zeros(3,1001);
for i=1:3;
wdr(i)=wn; % This is how we initialize our while loop.
while wdr(i)==wn;
wdr(i)=input(’Enter the driving frequency. ’);
if wdr(i)==wn;
fprintf(’This will produce resonance!!’)
end
end
end
t=0:tf/1000:tf;
for j=1:3
A1=v0/wn;
A2=x0(f0/(wn^2wdr(j)^2));
A3=f0/(wn^2wdr(j)^2);
x(j,:)=A1*sin(wn*t)+A2*cos(wn*t)+A3*cos(wdr(j)*t);
end
for k=1:3 % We could have used subplot this way all along.
subplot(3,1,k)
plot(t,x(k,:))
title([’Response for wdr=’,num2str(wdr(k)),’,
wn=’,num2str(wn)])
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
27
Program 42: varywn.m
%This program is similar in form to varywdr.m, except that
%now the natural frequency is the variable.
%
%This …le varies natural frequency of a single degree
%of freedom undamped oscillator at a set driving
%frequency. The initial displacement is 3, the velocity is
%1, the force magnitude per unit mass is 6, and the
%driving frequency is 7.
wdr=7;
x0=0;
v0=0;
f0=6;
tf=10;
wn=zeros(3,1);
x=zeros(3,1001);
for i=1:3;
wn(i)=wdr; % Analagous to the initialization above.
while wn(i)==wdr;
wn(i)=input(’Enter the natural frequency. ’);
if wn(i)==wdr;
fprintf(’This will produce resonance!!’)
end
end
end
t=0:tf/1000:tf;
for j=1:3
A1=v0/wn(j);
A2=x0(f0/(wn(j)^2wdr^2));
A3=f0/(wn(j)^2wdr^2);
x(j,:)=A1*sin(wn(j)*t)+A2*cos(wn(j)*t)+A3*cos(wdr*t);
end
for k=1:3
subplot(3,1,k)
plot(t,x(k,:))
title([’Response for wdr=’,num2str(wdr),’,
wn=’,num2str(wn(k))])
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
28CHAPTER5 HARMONIC EXCITATIONOF UNDAMPED SDOF SYSTEMS
Program 43: beatres.m
%The main feature of note for this code is the use of the
%ifthenelse protocol in MATLAB to allow solutions other
%than “Inf” for the resonant case. By changing the values
%of the initial conditions, wn, and f0 to input
%statements, this program would become a general solver
%for the singledegree of freedom undamped oscillator,
%subject to harmonic forcing.
%
%This program shows beats and resonance in undamped
%systems. Again, in order to better see the e¤ects, the
%initial velocity and displacement are zero.
x0=0;
v0=0;
wn=3;
wdr=input(’Enter the driving frequency. ’);
f0=6;
tf=120;
%This section chooses the proper response formula for
%the given situation.
t=0:tf/1000:tf;
if wdr==wn
A1=v0/wn;
A2=x0;
A3=f0/2*wn;
x=A1*sin(wn*t)+A2*cos(wn*t)+A3*t.*cos(wdr*t);
else
A1=v0/wn;
A2=x0(f0/(wn^2wdr^2));
A3=f0/(wn^2wdr^2);
x=A1*sin(wn*t)+A2*cos(wn*t)+A3*cos(wdr*t);
end
plot(t,x);
if wdr==wn
title(’Example of Resonance Phenomenon’);
else
title(’Example of Beat Phenomenon’);
end
xlabel(’Time, seconds’)
ylabel(’Response x’)
grid
29
0 1 2 3 4 5 6 7 8 9 10
0.5
0
0.5
Response for w=3, wn=7
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
0.02
0
0.02
Response for w=27, wn=7
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
0.01
0
0.01
Response for w=42, wn=7
R
e
s
p
o
n
s
e
x
Time, seconds
Figure 5.2: Vibration response for di¤erent driving frequencies.
30CHAPTER5 HARMONIC EXCITATIONOF UNDAMPED SDOF SYSTEMS
0 1 2 3 4 5 6 7 8 9 10
0.5
0
0.5
Response for w=7, wn=3
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
0.2
0
0.2
Response for w=7, wn=12
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
0.02
0
0.02
Response for w=7, wn=26
R
e
s
p
o
n
s
e
x
Time, seconds
Figure 5.3: Vibration response for di¤erent natural frequencies.
31
0 20 40 60 80 100 120
25
20
15
10
5
0
5
10
15
20
25
Example of Beat Phenomenon
Time, seconds
R
e
s
p
o
n
s
e
x
Figure 5.4: Example of the beating phenomenon.
32CHAPTER5 HARMONIC EXCITATIONOF UNDAMPED SDOF SYSTEMS
0 20 40 60 80 100 120
1500
1000
500
0
500
1000
1500
Example of Resonance Phenomenon
Time, seconds
R
e
s
p
o
n
s
e
x
Figure 5.5: Example of resonant vibration.
Chapter 6
Harmonic Forcing of
Damped SDOF Systems
Now, we will examine how the behavior of the system changes when we add
damping. As with the unforced case, the equations of motion change when
damping is added. They become:
:• r + c _ r + /r = 1 cos(.t). (6.1)
or with c = c´2:.
n
.
• r + 2c.
n
_ r + .
2
n
r = 1 cos(.t). (6.2)
where 1 = 1´:. The homogeneous solution to this equation is of the form
r

(t) = ¹c
t.
sin(.
J
t + 0). (6.3)
where .
J
= .
n
1 ÷c
2
. and constants ¹. 0 depend on initial conditions. The
particular solution to the external force is
r
µ
(t) = ¹
0
cos(.t ÷c). (6.4)
where
¹
0
=
1
(.
2
n
÷.
2
) + (2c.
n
.)
2
. c = tan
1
2c.
n
.
.
2
n
÷.
2
. (6.5)
33
34CHAPTER6 HARMONIC FORCING OF DAMPED SDOF SYSTEMS
The complete solution, r(t) = r

(t)+r
µ
(t) is then used to evaluate constants
¹ and 0. These constants were found for zero initial conditions using Maple;
this solution is re‡ected in the code that follows.
The addition of damping causes the response of the system to di¤er slightly,
as shown in Figures 6.1 and 6.2. In Figure 6.1, the damping ratio c was varied.
This shows that the transient period of vibration varies inversely with damping
ratio. The length of the transient period varies from about 4.5 seconds for c =
0.05 to about 2 seconds for c = 0.3. showing that, in many cases, the transient
response can be ignored due to its short time period. However, for some cases,
the transient period may be much longer or may have a very large amplitude,
so it is always important to examine the transient e¤ects of a system before
neglecting them. Notice also that the damping ratio a¤ects the amplitude of
the steadystate vibration, also in an inverse relationship. That is, the amplitude
of the response for c = 0.05 is almost 2, while that for c = 0.3 is less than 1.
Figure 6.2 shows the e¤ects of changing the natural frequency. Notice how,
for the two frequencies that are near the driving frequency, the transient period
is quite long, almost 10 seconds. However, for the large natural frequency,
the transient period is less than 4 seconds, which shows that the length of the
transient period also depends on the natural frequency.
In the damped system, resonance also takes on a di¤erent meaning. Notice
how, for . = .
n
. the amplitude does not become in…nite; the introduction
of damping introduces a term that keeps the denominator of the steadystate
amplitude from becoming zero. However, at this point, the phase angle becomes
90
. For a damped system, this condition de…nes resonance, since it is also at
this point that the denominator of the amplitude is a minimum. To prove this
last assertion to yourself, look at the denominator of the amplitude constant,
¹
0
. The amplitude will be maximized when the denominator is minimized. Both
terms are never negative, so the minimum will occur when the two frequencies
are equal (making the …rst term of the denominator zero). Also, as the driving
frequency increases greatly, the amplitude nears zero.
The MATLAB code below was used to produce the …gures. Instead of insert
ing a while statement to control the range of damping ratios used, we use an if
statement, in tandem with an error statement. If the damping ratio is outside
the allowed range, MATLAB will halt execution of the program, printing the
statement found inside the quotation marks to the screen. Controlling input in
this manner is more drastic than the method used in the previous programs.
However, those programs had many more values to input. Forcing the user of
a program to reenter several values because of a typo seems a harsh penalty to
this programmer. Also, this program introduces MATLAB’s method for con
tinuing lines. To continue an expression onto the next line, simply type three
periods in succession (ellipsis) and move to the next line. This is helpful for long
mathematical expressions, like the constants of integration below. This ellipsis
can be placed anywhere a space would be allowed, so continuing in the middle
of a variable name, for example, is not recommended.
35
Program 51: harmzeta.m
%This program solves for the response of
%a damped single degree of freedom system subject to
%a harmonic external force. The expressions used for the
%constants were found by using MAPLE.
%
wdr=3;
wn=3.5;
fo=4;
tf=10;
t=0:tf/1000:tf;
for k=1:3
zeta(k)=input(’Enter a damping ratio (zeta). ’);
if (zeta(k)<0 [ zeta(k)=1)
error(’Zeta out of range for this program!’)
end
end
for k=1:3
wd=wn*sqrt(1zeta(k)^2);
Ao=fo/sqrt((wn^2wdr^2)^2+(2*zeta(k)*wn*wdr)^2);
phi=atan2(2*zeta(k)*wn*wdr,(wn^2wdr^2));
Z1=zeta(k)*wnwdr*tan(phi);
Z2=sqrt((zeta(k)*wn)^2+2*zeta(k)*wn*wdr*tan(phi)+ ... % Continu
ation.
(wdr*tan(phi))^2+wd^2); % The extra tab is not necessary, but
helpful.
Z=(Z1+Z2)/wd;
Anum=Ao*((zeta(k)*wn*Zwd)*cos(phi)+wdr*Z*sin(phi));
Aden=Z*wd;
A=Anum/Aden;
theta=2*atan(Z);
x(k,:)=A*exp(zeta(k)*wn*t).*sin(wd*t+theta)+Ao*cos(wdr*tphi);
end
for k=1:3
subplot(3,1,k)
plot(t,x(k,:))
title([’Response for zeta=’,num2str(zeta(k)),’, wn=’, ...
num2str(wn),’, and wdr=’, num2str(wdr)])
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
36CHAPTER6 HARMONIC FORCING OF DAMPED SDOF SYSTEMS
0 1 2 3 4 5 6 7 8 9 10
2
0
2
Response for zeta=0.05, wn=3.5, and w=3
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
2
0
2
Response for zeta=0.1, wn=3.5, and w=3
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
1
0
1
Response for zeta=0.3, wn=3.5, and w=3
R
e
s
p
o
n
s
e
x
Time, seconds
Figure 6.1: Damped response for three di¤erent damping ratios.
37
0 1 2 3 4 5 6 7 8 9 10
2
0
2
Response for zeta=0.05, wn=2, and w=3
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
1
0
1
Response for zeta=0.05, wn=4, and w=3
R
e
s
p
o
n
s
e
x
0 1 2 3 4 5 6 7 8 9 10
0.05
0
0.05
Response for zeta=0.05, wn=16, and w=3
R
e
s
p
o
n
s
e
x
Time, seconds
Figure 6.2: Response variation with di¤erent natural frequencies.
Chapter 7
Base Excitation of SDOF
Systems
The base excitation problem is illustrated in Figure 7.1. Let the motion of the
base be denoted by n(t) and the response of the mass by r(t), and assuming
that the base has harmonic motion of the form n(t) = 1 sin(.
b
t). The equation
of motion for this system is:
:
..
r + c(
.
r ÷
.
n) + /(r ÷n) = 0. (7.1)
Using the assumed form for the motion, we can substitute for n and its deriva
tive, resulting in:
:
..
r + c
.
r + /r = c1 .
b
cos .
b
t + /1 sin.
b
t. (7.2)
which when divided through by the mass, yields
..
r + 2c.
.
r + .
2
r = 2c..
b
cos .
b
t + .
2
1 sin.
b
t. (7.3)
The homogeneous solution is of the form:
r

= ¹c
t.
sin(.
J
t + 0). (7.4)
The expression for each part of the particular solution is similar to that for
the general sinusoidal forcing function; the sine term produces a sine solution,
and the cosine term produces a cosine solution. If we …nd these solutions and
combine their sum into a single sinusoid, we obtain:
39
40 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS
Figure 7.1: Typical single degree of freedom system subject to base excitation.
r
µ
= ¹
o
cos(.
b
t ÷c
1
÷c
2
). (7.5)
where
¹
o
= .1
.
2
+ (2c.
b
)
2
(.
2
÷.
2
b
)
2
+ (2c..
b
)
2
. c
1
= tan
1
2c..
b
.
2
÷.
2
b
. c
2
= tan
1
.
2c.
b
.
Thus, the complete solution is the sum of the homogeneous and particular
solutions, or:
r(t) = ¹c
t.
sin(.
J
t + 0) + ¹
o
cos(.
b
t ÷c
1
÷c
2
). (7.6)
This equation tells us a great deal about the motion of the mass. First, we
can see that the particular solution represents the steadystate response, while
the homogeneous solution is the transient response, since the particular solution
is independent of the initial displacement and velocity. Using MAPLE to solve
the initial value problem (with given initial velocity and displacement not nec
essarily equal to zero), we …nd that both are dependent upon the initial velocity
41
and displacement. However, the expression for the constants ¹ and 0 is, in gen
eral, very di¢cult to solve, even for MAPLE. So, for the sake of programming
in MATLAB, the initial velocity and displacement were both assumed to be
zero. This assumption yielded simpler equations, which were used in the base
excitation programs which follow.
Figure 7.2 shows the e¤ects of changing the excitation frequency while hold
ing all other parameters constant. In the steady state, from about three seconds
forward, note that the frequency of vibration increases with the base frequency.
This is expected, since the base excitation portion dominates the steady state.
Of particular note is the bottom plot, with .
b
= 20. In the transient portion,
the response has the shape of a sum of two sinusoids; these are, of course, the
transient and steadystate functions. Since the base excitation is of such high
frequency, this graph shows best what is happening between the transient and
steady responses. Note that, if a line was drawn through the upper or lower
peaks of the motion, the result would be a curve similar to that exhibited by
a damped free response. The midpoint of the oscillation caused by the steady
response becomes exponentially closer to zero with increasing time, as the tran
sient response diminishes.
Figure 7.3 gives plots for three di¤erent vibration amplitudes. The di¤er
ences caused by changing the amplitude is what would be expected; the maxi
mum amplitude of the overall vibration and of the steadystate response both
increase with increasing input amplitude.
The plots in Figure 7.4 for various damping ratios show two e¤ects of chang
ing the damping ratio. First, the change in damping ratio causes the length
of the transient period to vary; an increase in c causes the transient period to
decrease, as the plots show. Also, the change in damping ratio causes a change
in the frequency of the transient vibration. Again, an increase in c causes a
decrease in the damped natural frequency, although the decrease is not entirely
evident from just looking at the plots. This is because the plots also include the
base excitation (steadystate) terms, whose frequency has not changed.
The MATLAB code for this situation is much more complex than the code
used in previous examples. This is mainly due to the increased di¢culty en
countered when the external load is applied to a part of the structure. When
this approach is used, the relative displacement of the two parts of the struc
ture becomes the important factor, instead of the displacement of the structure
relative to some ground. The code for this example uses a solution obtained
from the MAPLE solve routine to produce a plot of the response. An impor
tant consideration to note is that the answer given by MAPLE results in two
possible solutions; the MATLAB code attempts to locate the correct one. The
way in which MATLAB chooses the correct solution is to check which of them
matches the initial displacement condition. Note from the plots that the initial
displacements are zero for all plots, as are the initial velocities, so we can be
con…dent in the plotted solutions. The three programs given below show the
changes that need to be made in a program in order to test di¤erent parameters.
42 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS
Program 61: varywb.m
%This program solves the base excitation problem. The
%code assumes a sinusoidal base function. Also, the
%program tests three di¤erent natural frequencies.
%
y0=input(’Enter the base excitation magnitude. ’);
zeta=input(’Enter the damping ratio (zeta). ’);
if (zeta<0 [ zeta=1) % The usual test on damping ratio.
error(’Damping ratio not in acceptable range!’)
end
wn=4;
tf=10;
t=0:tf/1000:tf;
for k=1:3
wb(k)=input(’Enter a base excitation frequency. ’);
end
for m=1:3
%
%This section solves the transient response, using the
%equations obtained from MAPLE.
%
wd=wn*sqrt(1zeta^2);
phi1=atan2(2*zeta*wn*wb(m),(wn^2wb(m)^2));
phi2=atan2(wn,2*zeta*wb(m));
xi=phi1+phi2;
%These constants are what produces the two possible
%solutions discussed above. Notice the way by which
%the extraordinarily long expressions for the constants
%are broken into parts, to keep the expressions from
%spreading over several lines.
Z1=(zeta*wnwb(m)*tan(xi)+sqrt((zeta*wn)^2+2*zeta* ...
wn*wb(m)*tan(xi)+(wb(m)*tan(xi))^2+wd^2))/wd;
Z2=(zeta*wnwb(m)*tan(xi)sqrt((zeta*wn)^2+2*zeta* ...
wn*wb(m)*tan(xi)+(wb(m)*tan(xi))^2+wd^2))/wd;
Anum=sqrt((wn^2+(2*zeta*wb(m))^2)/((wn^2wb(m)^2)^2+(2* ...
zeta*wb(m)*wn)^2))*wn*y0;
Bnum1=(wd*cos(xi)+Z1*zeta*wn*cos(xi)+Z1*wb(m)*sin(xi));
Bnum2=(wd*cos(xi)+Z2*zeta*wn*cos(xi)+Z2*wb(m)*sin(xi));
Aden1=wd*Z1;
Aden2=wd*Z2;
A1=Anum*Bnum1/Aden1;
A2=Anum*Bnum2/Aden2;
th1=2*atan(Z1);
th2=2*atan(Z2);
y1(m,:)=A1*exp(zeta*wn*t).*sin(wd*t+th1);
y2(m,:)=A2*exp(zeta*wn*t).*sin(wd*t+th2);
43
end
%This portion solves the steadystate response.
for j=1:3
A=sqrt((wn^2+(2*zeta*wb(j))^2)/((wn^2wb(j)^2)^2+(2*zeta* ...
wn*wb(j))^2));
phi1=atan2(2*zeta*wn*wb(j),(wn^2wb(j)^2));
phi2=atan2(wn,(2*zeta*wb(j)));
xp(j,:)=wn*y0*A*cos(wb(j)*tphi1phi2);
end
if (xp(1,1)+y1(1,1)==xp(2,1)+y1(2,1)==xp(3,1)+y1(3,1)==0)
x=xp+y1;
else
x=xp+y2;
end
for i=1:3
subplot(3,1,i)
plot(t,x(i,:))
ylabel(’Response x’);
title([’Base Excitation with wb=’,num2str(wb(i)), ...
’ and wn=’,num2str(wn)]);
grid
end
xlabel(’Time, seconds’)
44 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS
Program 62: varyyobe.m
%This program solves the base excitation problem. The
%code assumes a sinusoidal base function. Also, the
%program tests three di¤erent base amplitudes.
%Notice that the natural frequency is now given as
%a set variable, and the variable ’y0’ is a userinput matrix.
%
wb=input(’Enter the base excitation frequency. ’);
zeta=input(’Enter the damping ratio (zeta). ’);
if (zeta<0 [ zeta=1) % The usual test on damping ratio.
error(’Damping ratio not in acceptable range!’)
end
wn=4;
tf=10;
t=0:tf/1000:tf;
for k=1:3
y0(k)=input(’Enter a base excitation magnitude. ’);
end
for m=1:3
wd=wn*sqrt(1zeta^2);
phi1=atan2(2*zeta*wn*wb,(wn^2wb^2));
phi2=atan2(wn,2*zeta*wb);
xi=phi1+phi2;
Z1=(zeta*wnwb*tan(xi)+sqrt((zeta*wn)^2+2*zeta* ...
wn*wb*tan(xi)+(wb*tan(xi))^2+wd^2))/wd;
Z2=(zeta*wnwb*tan(xi)sqrt((zeta*wn)^2+2*zeta* ...
wn*wb*tan(xi)+(wb*tan(xi))^2+wd^2))/wd;
Anum=sqrt((wn^2+(2*zeta*wb)^2)/((wn^2wb^2)^2+(2* ...
zeta*wb*wn)^2))*wn*y0(m);
Bnum1=(wd*cos(xi)+Z1*zeta*wn*cos(xi)+Z1*wb*sin(xi));
Bnum2=(wd*cos(xi)+Z2*zeta*wn*cos(xi)+Z2*wb*sin(xi));
Aden1=wd*Z1; Aden2=wd*Z2;
A1=Anum*Bnum1/Aden1;
A2=Anum*Bnum2/Aden2;
th1=2*atan(Z1);
th2=2*atan(Z2);
y1(m,:)=A1*exp(zeta*wn*t).*sin(wd*t+th1);
y2(m,:)=A2*exp(zeta*wn*t).*sin(wd*t+th2);
end
for j=1:3
A=sqrt((wn^2+(2*zeta*wb)^2)/((wn^2wb^2)^2+(2*zeta* ...
wn*wb)^2));
phi1=atan2(2*zeta*wn*wb,(wn^2wb^2));
phi2=atan2(wn,(2*zeta*wb));
xp(j,:)=wn*y0(j)*A*cos(wb*tphi1phi2);
end
45
if (xp(1,1)+y1(1,1)==xp(2,1)+y1(2,1)==xp(3,1)+y1(3,1)==0)
x=xp+y1;
else
x=xp+y2;
end
for i=1:3
subplot(3,1,i)
plot(t,x(i,:))
ylabel(’Response x’);
title([’Base Excitation with wb=’,num2str(wb), ...
’, wn=’,num2str(wn),’, and y0=’,num2str(y0(i))]);
grid
end
xlabel(’Time, seconds’)
46 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS
Program 63: varyzbe.m
%This program solves the base excitation problem. The
%code assumes a sinusoidal base function. Also, the
%program tests three di¤erent damping ratios. Again, note
%the changes between this program and the previous one.
%
y0=input(’Enter the base excitation magnitude. ’);
wb=input(’Enter the base excitation frequency. ’);
wn=4;
tf=10;
t=0:tf/1000:tf;
for k=1:3
zeta(k)=input(’Enter a damping ratio (zeta). ’);
if (zeta(k)<0 [ zeta(k)=1) % The usual test on damping ratio.
error(’Damping ratio not in acceptable range!’)
end
end
for m=1:3
wd=wn*sqrt(1zeta(m)^2);
phi1=atan2(2*zeta(m)*wn*wb,(wn^2wb^2));
phi2=atan2(wn,2*zeta(m)*wb);
xi=phi1+phi2;
Z1=(zeta(m)*wnwb*tan(xi)+sqrt((zeta(m)*wn)^2+2*zeta(m)* ...
wn*wb*tan(xi)+(wb*tan(xi))^2+wd^2))/wd;
Z2=(zeta(m)*wnwb*tan(xi)sqrt((zeta(m)*wn)^2+2*zeta(m)* ...
wn*wb*tan(xi)+(wb*tan(xi))^2+wd^2))/wd;
Anum=sqrt((wn^2+(2*zeta(m)*wb)^2)/((wn^2wb^2)^2+(2* ...
zeta(m)*wb*wn)^2))*wn*y0;
Bnum1=(wd*cos(xi)+Z1*zeta(m)*wn*cos(xi)+Z1*wb*sin(xi));
Bnum2=(wd*cos(xi)+Z2*zeta(m)*wn*cos(xi)+Z2*wb*sin(xi));
Aden1=wd*Z1;
Aden2=wd*Z2;
A1=Anum*Bnum1/Aden1;
A2=Anum*Bnum2/Aden2;
th1=2*atan(Z1);
th2=2*atan(Z2);
y1(m,:)=A1*exp(zeta(m)*wn*t).*sin(wd*t+th1);
y2(m,:)=A2*exp(zeta(m)*wn*t).*sin(wd*t+th2);
end
for j=1:3
A=sqrt((wn^2+(2*zeta(j)*wb)^2)/((wn^2wb^2)^2+(2*zeta(j)* ...
wn*wb)^2));
phi1=atan2(2*zeta(j)*wn*wb,(wn^2wb^2));
phi2=atan2(wn,(2*zeta(j)*wb));
xp(j,:)=wn*y0*A*cos(wb*tphi1phi2);
end
47
if (xp(1,1)+y1(1,1)==xp(2,1)+y1(2,1)==xp(3,1)+y1(3,1)==0)
x=xp+y1;
else
x=xp+y2;
end
for i=1:3
subplot(3,1,i)
plot(t,x(i,:))
ylabel(’Response x’);
title([’Base Excitation with wb=’,num2str(wb), ...
’ and zeta=’,num2str(zeta(i))]);
grid
end
xlabel(’Time, seconds’)
48 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS
0 1 2 3 4 5 6 7 8 9 10
10
0
10
R
e
s
p
o
n
s
e
x
Base Excitation with wb=2 and wn=4
0 1 2 3 4 5 6 7 8 9 10
10
0
10
R
e
s
p
o
n
s
e
x
Base Excitation with wb=6 and wn=4
0 1 2 3 4 5 6 7 8 9 10
2
0
2
4
Time, seconds
R
e
s
p
o
n
s
e
x
Base Excitation with wb=10 and wn=4
Figure 7.2: Response of a baseexcited system subject to three di¤erent excita
tion frequencies.
49
0 1 2 3 4 5 6 7 8 9 10
5
0
5
R
e
s
p
o
n
s
e
x
Base Excitation with wb=6, wn=4, and y0=3
0 1 2 3 4 5 6 7 8 9 10
20
0
20
R
e
s
p
o
n
s
e
x
Base Excitation with wb=6, wn=4, and y0=7
0 1 2 3 4 5 6 7 8 9 10
20
0
20
Time, seconds
R
e
s
p
o
n
s
e
x
Base Excitation with wb=6, wn=4, and y0=11
Figure 7.3: Results obtained for three di¤erent base excitation magnitudes.
50 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS
0 1 2 3 4 5 6 7 8 9 10
10
0
10
R
e
s
p
o
n
s
e
x
Base Excitation with wb=6 and zeta=0.05
0 1 2 3 4 5 6 7 8 9 10
10
0
10
R
e
s
p
o
n
s
e
x
Base Excitation with wb=6 and zeta=0.1
0 1 2 3 4 5 6 7 8 9 10
5
0
5
Time, seconds
R
e
s
p
o
n
s
e
x
Base Excitation with wb=6 and zeta=0.3
Figure 7.4: Response of a baseexcited system for di¤erent damping ratios.
Chapter 8
SDOF Systems with a
Rotating Unbalance
A rotating unbalance is depicted in Figure 8.1. Assume that the guides are
frictionless. The radius c is measured from the center of mass of the mass :. To
construct the equation of motion, we need an expression for the motion of the
rotating unbalance in terms of r. If the mass rotates with a constant angular
velocity .
:
. then the circle it de…nes can be described parametrically as:
r(t) = c sin.
:
t. n(t) = c cos .
:
t. (8.1)
Note that the sine de…nes the r coordinate because in our chosen coordinates,
r is vertical. Having this expression for r. we can then construct the equations
of motion. The position coordinate of the rotating unbalance is r+sin.
:
t, and
the acceleration is the second derivative of this expression with respect to time.
The acceleration of the mass without the unbalance is
..
r. Adding in the e¤ects
of the sti¤ness and damper, we get:
(:÷:
o
)
..
r + :
o
d
2
dt
2
(r + c sin.
:
t) = ÷/r ÷c
.
r. (8.2)
or
(:÷:
o
)
..
r + :
o
..
r ÷c.
2
:
sin.
:
t
= ÷/r ÷c
.
r. (8.3)
Finally, collecting r and its derivatives, moving the sine term to the other
side of the expression, and dividing by the system mass gives the …nal equation
of motion:
51
52CHAPTER8 SDOF SYSTEMS WITHA ROTATINGUNBALANCE
Figure 8.1: Schematic of the system in question (note the coordinate axes cho
sen).
..
r + 2c.
n
.
r + .
2
n
r = :
o
c.
2
:
sin.
:
t. (8.4)
Note that this is identical to the harmonic forcing function case we encoun
tered earlier, except that now our force is in the form of a sine rather than a
cosine. For that reason, the particular solution is of the form:
r
µ
(t) = A sin(.
:
t ÷c). (8.5)
where, with r = .
:
´.
n
.
A =
:
o
c
:
r
2
(1 ÷r
2
)
2
+ (2cr)
2
. c = tan
1
2cr
1 ÷r
2
. (8.6)
As before, the homogenous solution for this expression is:
r

(t) = ¹c
t.n
sin(.
J
t + 0). (8.7)
where ¹ and 0 are determined from the initial conditions. The …nal solution is
then r(t) = r
µ
(t) + r

(t).
For the purpose of creating a program in MATLAB, the initial conditions
were assumed to be zero. Then, MAPLE was used to solve the resulting initial
53
value problem. The solution to this is not reproduced here, due to the com
plexity of the expression; the solution for ¹ and 0 depend on the solution to
a quadratic equation. The MATLAB code that follows contains the expression
(in a few parts) for the constants in question.
Figures 8.2 through 8.4 show di¤erent varying parameter sets for the system.
Unless otherwise speci…ed, : = 7. :
o
= 3. and c = 0.1. For Figure 8.2, the
natural frequency was varied while holding all other parameters constant. Notice
how, when .
n
is not a multiple of .
:
. the motion is the sum of two sinusoids; this
is shown best by the top plot, where .
n
= 2. For the highest natural frequency
tested, the oscillation occurs along a single sinusoid. This is because the natural
frequency of the system is too high to be excited by the relatively slow rotation
frequencies. The …rst two plots have natural frequencies small enough to be
excited by the slow rotation of the eccentric mass.
In Figure 8.3, the system damping is varied. The result is that the tran
sient portion (the portion with the curve that looks like the sum of sinusoids)
becomes smaller, to the point where it disappears at c = 0.3. A di¤erence in
the magnitude of oscillation, as would be predicted from the expression we have
derived for the parameter A. is not present because the frequency ratio we are
testing is in the range where oscillation magnitude shows little variation with
damping ratio. This consideration is important in the design of machinery; if
the machine can be designed to have a much higher natural frequency than the
oscillating mass, then the level of damping can be made low without increasing
the amplitude past acceptable levels.
Finally, Figure 8.4 shows the variation of vibration with increasing system
mass. Notice how the amplitude of the vibration decreases with increasing mass;
this is due to the dependence of A on :
o
´:. As the mass ratio decreases, so
does the amplitude of vibration.
54CHAPTER8 SDOF SYSTEMS WITHA ROTATINGUNBALANCE
Program 71: vrywnrot.m
%This program solves for the response of a single
%degree of freedom system having a rotating unbalance.
%The equations of motion were derived using MAPLE and
%are valid only for zero initial conditions.
%
mo=3;
m=7;
e=0.1;
wr=4;
zeta=0.05;
tf=10;
t=0:tf/1000:tf;
for i=1:3
wn(i)=input(’Enter a natural frequency. ’);
wd(i)=wn(i)*sqrt(1zeta^2);
end
for j=1:3
r=wr/wn(j);
X=mo*e/m*(r^2/sqrt((1r^2)^2+(2*zeta*r)^2));
phi=atan2(2*zeta*r,(1r^2));
Z1=(zeta*wn(j)+wr*cot(phi))/wd(j);
Z2=sqrt((zeta*wn(j))^22*zeta*wn(j)*wr*cot(phi)+ ...
(wr*cot(phi))^2+wd(j)^2)/wd(j);
Z=Z1+Z2;
theta=2*atan(Z);
Anum=X*(wd(j)*sin(phi)Z*zeta*wn(j)*sin(phi)+Z*wr*cos(phi));
Aden=Z*wd(j);
A=Anum/Aden;
xh(j,:)=A*exp(zeta*wn(j)*t).*sin(wd(j)*t+theta);
xp(j,:)=X*sin(wr*tphi);
end
x=xp+xh;
for k=1:3
subplot(3,1,k)
plot(t,x(k,:))
title([’Rotating Unbalance with wr=’,num2str(wr),’ wn=’, ...
num2str(wn(k)),’ and zeta=’,num2str(zeta)]);
grid
end
xlabel(’Time, seconds’)
55
Program 72: vryzrot.m
%This program solves for the response of a single
%degree of freedom system having a rotating unbalance.
%The equations of motion were derived using MAPLE and
%are valid only for zero initial conditions.
%
mo=3;
m=7;
e=0.1;
wr=4;
wn=12;
tf=10;
t=0:tf/1000:tf;
for i=1:3
zeta(i)=input(’Enter a damping ratio (zeta). ’);
end
for j=1:3
wd=wn*sqrt(1zeta(j)^2);
r=wr/wn;
X=mo*e/m*(r^2/sqrt((1r^2)^2+(2*zeta(j)*r)^2));
phi=atan2(2*zeta(j)*r,(1r^2));
Z1=(zeta(j)*wn+wr*cot(phi))/wd;
Z2=sqrt((zeta(j)*wn)^22*zeta(j)*wn*wr*cot(phi)+ ...
(wr*cot(phi))^2+wd^2)/wd;
Z=Z1+Z2;
theta=2*atan(Z);
Anum=X*(wd*sin(phi)Z*zeta(j)*wn*sin(phi)+Z*wr*cos(phi));
Aden=Z*wd;
A=Anum/Aden;
xh(j,:)=A*exp(zeta(j)*wn*t).*sin(wd*t+theta);
xp(j,:)=X*sin(wr*tphi);
end
x=xp+xh;
for k=1:3
subplot(3,1,k)
plot(t,x(k,:))
title([’Rotating Unbalance with wr=’,num2str(wr),’ wn=’, ...
num2str(wn),’ and zeta=’,num2str(zeta(k))]);
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
56CHAPTER8 SDOF SYSTEMS WITHA ROTATINGUNBALANCE
Program 73: vrymrot.m
%This program solves for the response of a single
%degree of freedom system having a rotating unbalance.
%The equations of motion were derived using MAPLE and
%are valid only for zero initial conditions.
%
mo=3;
zeta=0.05;
e=0.1;
wr=4;
wn=12;
tf=10;
t=0:tf/1000:tf;
for i=1:3
m(i)=input(’Enter a system mass. ’);
end
for j=1:3
wd=wn*sqrt(1zeta^2);
r=wr/wn;
X=mo*e/m(j)*(r^2/sqrt((1r^2)^2+(2*zeta*r)^2));
phi=atan2(2*zeta*r,(1r^2));
Z1=(zeta*wn+wr*cot(phi))/wd;
Z2=sqrt((zeta*wn)^22*zeta*wn*wr*cot(phi)+ ...
(wr*cot(phi))^2+wd^2)/wd;
Z=Z1+Z2;
theta=2*atan(Z);
Anum=X*(wd*sin(phi)Z*zeta*wn*sin(phi)+Z*wr*cos(phi));
Aden=Z*wd;
A=Anum/Aden;
xh(j,:)=A*exp(zeta*wn*t).*sin(wd*t+theta);
xp(j,:)=X*sin(wr*tphi);
end
x=xp+xh;
for k=1:3
subplot(3,1,k)
plot(t,x(k,:))
title([’Rotating Unbalance with wr=’,num2str(wr),’, wn=’, ...
num2str(wn),’, mass=’,num2str(m(k)),’, and rotating mass=’, ...
num2str(mo)]);
grid
end
xlabel(’Time, seconds’)
57
0 1 2 3 4 5 6 7 8 9 10
0.2
0
0.2
Rotating Unbalance with wr=4 wn=2 and zeta=0.05
0 1 2 3 4 5 6 7 8 9 10
0.05
0
0.05
Rotating Unbalance with wr=4 wn=6 and zeta=0.05
0 1 2 3 4 5 6 7 8 9 10
0.01
0
0.01
Time, seconds
Rotating Unbalance with wr=4 wn=12 and zeta=0.05
Figure 8.2: Response of systems with di¤erent natural frequencies to a rotating
unbalance.
58CHAPTER8 SDOF SYSTEMS WITHA ROTATINGUNBALANCE
0 1 2 3 4 5 6 7 8 9 10
0.01
0
0.01
R
e
s
p
o
n
s
e
x
Rotating Unbalance with wr=4 wn=12 and zeta=0.05
0 1 2 3 4 5 6 7 8 9 10
0.01
0
0.01
R
e
s
p
o
n
s
e
x
Rotating Unbalance with wr=4 wn=12 and zeta=0.1
0 1 2 3 4 5 6 7 8 9 10
0.01
0
0.01
Time, seconds
R
e
s
p
o
n
s
e
x
Rotating Unbalance with wr=4 wn=12 and zeta=0.3
Figure 8.3: Response with varied damping ratios.
59
0 1 2 3 4 5 6 7 8 9 10
0.05
0
0.05
Rotating Unbalance with wr=4, wn=12, mass=1, and rotating mass=3
0 1 2 3 4 5 6 7 8 9 10
0.02
0
0.02
Rotating Unbalance with wr=4, wn=12, mass=3, and rotating mass=3
0 1 2 3 4 5 6 7 8 9 10
0.01
0
0.01
Time, seconds
Rotating Unbalance with wr=4, wn=12, mass=6, and rotating mass=3
Figure 8.4: E¤ects of varying system mass.
Chapter 9
Impulse Response of SDOF
Systems
In the previous few examples, we have discussed the response of single degree
of freedom systems to di¤erent forms of sinusoidal inputs. In the following
examples, we will examine the e¤ects of nonsinusoidal inputs on single degree
of freedom systems. The simplest of these is the impulse response.
An impulse is a force which is applied over a very short time when compared
to the period of vibration. The period over which the impulse is applied is
assumed to be 2c. If the impulse is centered about time t, then it is applied
from t ÷c to t +c. If the force has a total value of 1
o
. then the average value is
1
o
´2c. So, for all time except the interval around t, the value of the impulse is
0; within the interval, it is 1
o
´2c.
Using the de…nition of impulse as force multiplied by time, and noting that
impulse is the change in momentum, we see that:
(1
o
´2c) 2c = :·
o
. (9.1)
where ·
o
is the initial velocity of the system. This is because the velocity of the
system before the impulse is zero, and it is ·
o
after the impulse. So, this problem
reduces to a single degree of freedom free vibration with zero initial displacement
and initial velocity equal to 1
o
´:. Recall that for a damped oscillator, the
response is of the form:
r(t) = ¹c
t.
sin(.
J
t + c). (9.2)
Since
¹ =
(·
o
+ c.r
o
)
2
+ (r
o
.
J
)
2
´.
J
,
c = tan
1
(r
o
.
J
´ (·
o
+ c.r
o
)) .
61
62 CHAPTER 9 IMPULSE RESPONSE OF SDOF SYSTEMS
we note that, for r
o
= 0, ¹ = ·
o
´.
J
, and c = 0. Thus, Equation 9.2 becomes
r(t) =
1
o
.
J
c
t.
sin(.
J
t). (9.3)
This response, as noted above, is simply a single degree of freedom oscillator
subject to an initial velocity. The behavior with changing 1
o
is similar to
changing ·
o
in a single degree of freedom oscillator. For that reason, a program
and plots for this situation are not included; they would be the same as those
in Example 2. Included in this example is a program which simulates the Dirac
delta function (an impulse with 1
o
= 1), for an impulse around a given time and
with a given total time interval. The program simply takes the entire interval
and sets the function equal to zero for all times other than the one speci…ed,
and equal to one for the speci…ed time.
Program 82 gives an example of how this delta function can be used inside
of another program, by plotting the function over a speci…ed time interval. This
program makes use of subfunctions as well. This is more handy for singleuse
functions, such as several of the unwieldy constants we derived for some of our
earlier examples. A subfunction is called just like any other MATLAB function.
The subfunction is written after the main code, and is internal to the code.
The variables used inside the subfunction stay in the subfunction; they are not
introduced to the MATLAB workspace. Thus, if we tried to use the variable
“int” in the main code of Program 82, we would generate an error. One more
item of note is the “`delta” in the ylabel function call. That is a LaTEX
tag, which is usable inside of a MATLAB string. Notice the results when the
program is run; the yaxis reads “c (t
J
) . " substituting the value entered for t
J
.
Superscripts, subscripts, Greek characters, and other useful e¤ects are available
in this manner; “help latex” at the MATLAB prompt can give you a start on
using these.
63
Program 81: delta.m
function delta=delta(td,tf)
%This function simulates the delta function.
%The user must input the time at which the
%nonzero value is desired, td, and the ending time, tf.
%
int=tf*td;
%The variable int ensures that a value in the time vector
%will match the desired time. The strategy is to subdivide
%the interval into at least 500 steps (this ensures the
%interval over which the function is nonzero is small).
%
while int<500
int=int*10;
end
t=0:tf/int:tf;
for i=1:int
if t(i)==td
delta(i)=1;
else
delta(i)=0;
end
end
64 CHAPTER 9 IMPULSE RESPONSE OF SDOF SYSTEMS
%Program 82: subdemo.m
function [t,y]=subdemo(td,tf)
%
% A simple routine to demonstrate use of subfunctions,
% making use of the delta function as an example.
% Inputs are the time of the delta function, td,
% and the overall timespan, tf.
% Note that subfunctions cannot be used
% inside of script m…les. If we were to
% write Program 82 as a script (like most of
% our m…les to this point), the delta function
% would have to be external.
%
y=subdelta(td,tf);
% Calling the subfunction version “subdelta”
% guarantees we’ll be calling the subfunction,
% not the function from Program 81.
% Now that we have the value of the delta function,
% we need to create a time vector that goes from
% zero to tf, and has the same number of points
% as the vector y (else we will get a plotting
% error). For this, we use the “max” and
% “size” commands.
len=max(size(y));
% “size” returns the vector [nrows ncols], corresponding
% to the number of rows and columns in y. Taking the
% maximum will return the longer dimension, and is a
% shortcut usable for both row and column vectors.
t=linspace(0,tf,len);
% “linspace” is much more natural a command for this
% instance than the colon operator. This will generate
% a vector with len equallyspaced elements between
% 0 and tf.
plot(t,y)
title(’Delta Function Sample’);
ylabel([’`delta(’,num2str(td),’)’]);
xlabel(’Time, seconds’);
grid
function delta=subdelta(td,tf)
% This function is Program 81.
% Note that a subfunction is included
% with a “function” call, just like an
% external function.
int=tf*td;
while int<500
int=int*10;
65
end
t=0:tf/int:tf;
for i=1:int
if t(i)==td
delta(i)=1;
else
delta(i)=0;
end
end
Chapter 10
Step Response of a SDOF
System
In this example, the force is assumed to be applied instantaneously, but it will
be sustained out to in…nity. This is essentially an onfunction. If a force of this
sort is plotted versus time, the force looks like a step up. So then, the behavior
of the system under this type of load is considered the step response of the single
degree of freedom system. We assume the system is underdamped and will have
zero initial conditions. We already know the equation of motion,
..
r + 2c.
n
.
r + .
2
n
r = 1(t)´:. (10.1)
where
1(t) =
0 if 0 < t < t
o
1
o
if t _ t
o
. (10.2)
In order to solve the di¤erential equation, we will use the convolution integral
r(t) =

0
1(t)o(t ÷t)dt. (10.3)
Recall that the convolution integral is derived by treating the force as an in
…nite series of impulse forces. The …rst fundamental theorem of calculus then
allows the in…nite series to be treated as the integral given above. The impulse
response, just discussed, given by
r(t) =
1
o
:.
J
c
t.n
sin.
J
t = 1
o
o(t). (10.4)
67
68 CHAPTER 10 STEP RESPONSE OF A SDOF SYSTEM
where we know that
o(t) =
1
:.
J
c
t.
sin.
J
t. (10.5)
Therefore,
r(t) =
1
:.
J
c
t.n

0
1(t)c
t.nr
sin.
J
(t ÷t)dt. (10.6)
Now, since we have a general expression for r(t), we can substitute our 1(t)
into Equation 10.6 to give:
r(t) =
1
:.
J
c
t.n
o
0
(0)c
t.nr
sin.
J
(t ÷t)dt +

o
1
o
c
t.nr
sin.
J
(t ÷t)dt
¸
.
(10.7)
Note that the …rst term inside the braces is zero. For that reason, for t < t
o
,
the response of the system is zero. To …nd the response for all other times, we
must evaluate the second integral (by parts):
r(t) =
1
o
/
1 ÷
1
1 ÷c
2
c
t.n(o)
cos [.
J
(t ÷t
o
) ÷c]
¸
. t _ t
o
. (10.8)
where c = tan
1 t
1t
2
. It is important to remember that this equation is
only valid for the time after the force is applied; the response is zero before
application of the force.
Figure 10.1 shows the variation of the response with the force magnitude. As
might be expected, the only di¤erence that results from changing the magnitude
of the external force is that the magnitude of the response changes. That is,
the magnitude of the response is directly proportional to the magnitude of the
external force. The magnitude of the external force also causes a second di¤er
ence: note that when the oscillatory motion begins, it is not centered around
zero. Instead, the mass oscillates around a displacement greater than zero. The
value of this center point is also dependent on the magnitude of the external
force (from the term 1 in the Equation 10.8).
In Figure 10.2, we vary the natural frequency. This causes two changes in
the response. First, the rate of exponential decrease in the response (the e¤ect
of damping) is increased; that is, the response stabilizes more quickly. Second,
the oscillation frequency decreases, since the natural frequency also dictates the
damped frequency.
69
Finally, Figure 10.3 shows the changes caused by changing the damping ratio.
With increasing damping ratio, the amount of time to damp out all vibration
decreases. For the third ratio tested, c = 0.3, the damping is su¢cient to allow
no oscillation around the new center point (r = 1.5). A second result, which is
not immediately evident from the …gure but follows from the mathematics, is
that the phase angle changes with the damping ratio (note that c is a function
of only c.)
The three programs used for this example follow below. The way in which
the force array is created in Program 91 illustrates the convenience a¤orded the
programmer by MATLAB. In Fortran or C programming, we would be forced to
use a loop to compare whether the time at each point of the time vector exceeded
the step time, and then adjust the force vector appropriately. In MATLAB, the
greaterthan operator applied to a vector will produce a vector with zeros where
the relation is false, and ones where it is true. So if we create a matrix having
the results of t t
o
in each row, and arraymultiply this matrix by the three
by:jt: force matrix, we will produce a matrix having step forcing in each row
of the appropriate magnitude, activated at t = t
o
.
The reader may then wonder if the loop calculating the response could have
been removed in a similar manner. The answer is “yes,” and the programming is
left to the reader. The for loop is one of the more timeconsuming constructions
inside MATLAB; thus, for more complicated calculations, it is advantageous to
remove these loops from the code; this process is called vectorization of code.
Using the calculation below as an example, note …rst that the parameters j/i
and nd are calculated outside the loop. These quantities are constant for all
forces. Thus, the timedependent part of all three responses is independent
of the forcing parameters. We could then create a matrix that has the time
response in each row, and use array multiplication to include the forcedependent
parameters. (This is the algorithm for the reader exercise described above.)
70 CHAPTER 10 STEP RESPONSE OF A SDOF SYSTEM
Program 91: stepfm.m
%This program calculates the step response
%of a single degree of freedom system. This
%version tests three di¤erent force magnitudes.
%The program assumes a system mass of 1.
%
zeta=0.05;
tf=10;
npts=1000;
t=linspace(0,tf,npts);
to=2;
wn=12;
k=(wn)^2;
for i=1:3
Fm(i,1)=input(’Enter a force magnitude. ’); % Forcing Fm to be a
column vector.
end
Fint=Fm*ones(1,npts); % Fint is thus 3bynpts.
%
% Now, we perform the logical operation tto,
% and make a 3bynpts matrix of the result.
%
qtest=tto;
fmult=[qtest;qtest;qtest]; % Three rows of qtest.
Fo=Fint.*fmult; % The force matrix.
wd=wn*sqrt(1zeta^2);
phi=atan2(zeta,sqrt(1zeta^2));
for n=1:3
A=Fo(n,:)/k;
B=Fo(n,:)/(k*sqrt(1zeta^2));
x(n,:)=AB.*exp(zeta*wn*t).*cos(wd*tphi);
end
for l=1:3
subplot(3,1,l)
plot(t,x(l,:))
title([’Response for wn=’,num2str(wn),’, Fmax=’, ...
num2str(Fm(l)),’, and time=’, num2str(to)]);
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
71
Program 92: stepwn.m
%This program calculates the step response
%of a single degree of freedom system. This
%version tests three di¤erent natural frequencies.
%The program assumes a system mass of 1.
%
Fm=5;
npts=1000;
zeta=0.05;
tf=10;
t=linspace(0,tf,npts);
to=2;
qtest=tto; % Only one force vector here, so we can do this here.
Fo=Fm*qtest; % Scalar Fm * 1bynpts vector.
for i=1:3
wn(i)=input(’Enter a natural frequency. ’);
k(i)=wn(i)^2;
end
%
% This could also be vectorized.
%
for n=1:3
wd=wn(n)*sqrt(1zeta^2);
A=Fo/k(n);
B=Fo/(k(n)*sqrt(1zeta^2));
phi=atan2(zeta,sqrt(1zeta^2));
x(n,:)=AB.*exp(zeta*wn(n)*t).*cos(wd*tphi);
end
for l=1:3
subplot(3,1,l)
plot(t,x(l,:))
title([’Response for wn=’,num2str(wn(l)),’, Fmax=’, ...
num2str(Fm),’, and time=’, num2str(to)]);
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
72 CHAPTER 10 STEP RESPONSE OF A SDOF SYSTEM
Program 93: stepzeta.m
%This program calculates the step response
%of a single degree of freedom system. This
%version tests three di¤erent natural frequencies.
%The program assumes a system mass of 1.
%
npts=1000;
Fm=5;
tf=10;
t=linspace(0,tf,npts);
to=2;
qtest=tto;
Fo=Fm*qtest;
wn=12;
k=(wn)^2;
for i=1:3
zeta(i)=input(’Enter a damping ratio (zeta). ’);
end
%
% This could also be vectorized.
%
for n=1:3
wd=wn*sqrt(1zeta(n)^2);
A=Fo/k;
B=Fo/(k*sqrt(1zeta(n)^2));
phi=atan2(zeta(n),sqrt(1zeta(n)^2));
x(n,:)=AB.*exp(zeta(n)*wn*t).*cos(wd*tphi);
end
for l=1:3
subplot(3,1,l)
plot(t,x(l,:))
title([’Response for wn=’,num2str(wn),’, zeta=’, ...
num2str(zeta(l)),’, and time=’, num2str(to)]);
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
73
0 1 2 3 4 5 6 7 8 9 10
0
0.01
0.02
0.03
R
e
s
p
o
n
s
e
x
Response for wn=12, Fmax=3, and time=2
0 1 2 3 4 5 6 7 8 9 10
0
0.05
0.1
R
e
s
p
o
n
s
e
x
Response for wn=12, Fmax=7, and time=2
0 1 2 3 4 5 6 7 8 9 10
0
0.05
0.1
Time, seconds
R
e
s
p
o
n
s
e
x
Response for wn=12, Fmax=11, and time=2
Figure 10.1: Step response of a single degree of freedom system to di¤erent step
magnitudes.
74 CHAPTER 10 STEP RESPONSE OF A SDOF SYSTEM
0 1 2 3 4 5 6 7 8 9 10
0
0.5
R
e
s
p
o
n
s
e
x
Response for wn=4, Fmax=5, and time=2
0 1 2 3 4 5 6 7 8 9 10
0
0.1
R
e
s
p
o
n
s
e
x
Response for wn=7, Fmax=5, and time=2
0 1 2 3 4 5 6 7 8 9 10
0
0.02
0.04
0.06
Time, seconds
R
e
s
p
o
n
s
e
x
Response for wn=12, Fmax=5, and time=2
Figure 10.2: Step response of single degree of freedom systems having di¤erent
natural frequencies.
75
0 1 2 3 4 5 6 7 8 9 10
0
0.02
0.04
0.06
R
e
s
p
o
n
s
e
x
Response for wn=12, zeta=0.05, and time=2
0 1 2 3 4 5 6 7 8 9 10
0
0.02
0.04
R
e
s
p
o
n
s
e
x
Response for wn=12, zeta=0.1, and time=2
0 1 2 3 4 5 6 7 8 9 10
0
0.02
0.04
Time, seconds
R
e
s
p
o
n
s
e
x
Response for wn=12, zeta=0.3, and time=2
Figure 10.3: Step response of a single degree of freedom system to di¤erent
levels of damping.
Chapter 11
Response of SDOF Systems
to Square Pulse Inputs
A square pulse is a single pulse of constant magnitude and …nite duration. To
analyze the response of systems to a square wave input, we will treat the square
wave as the sum of two equal and opposite step inputs applied at di¤erent times.
The time interval between application of the step inputs is the duration of the
square wave.
Let us assume that the magnitude of the square wave is 1
o
, and its duration
is t
1
seconds. To simulate the wave using step inputs, we begin with a step
input of magnitude 1
o
from time t = 0. and add to it at time t
1
a step input of
magnitude ÷1
o.
By superposition, the total response is the sum of the response
of the system to each step input.
Recall that the response of a single degree of freedom system to a step input
of magnitude 1
n
applied at time t
o
is:
r(t) =
1
n
/
1 ÷
1
1 ÷c
2
c
t.n(o)
cos [.
J
(t ÷t
o
) ÷c]
¸
. t _ t
o
. (11.1)
where c = arctan c´
1 ÷c
2
. If we now consider the two step inputs separately,
denoting the response of the system to the input at time t = 0 as r
1
(t) and the
response to the input at time t = t
1
as r
2
(t). we …nd that:
r
1
(t) =
1
o
/
1 ÷
1
1 ÷c
2
c
t.
cos [.
J
t ÷c]
¸
. t _ 0 (11.2)
and
77
78CHAPTER11 RESPONSE OF SDOF SYSTEMS TOSQUARE PULSE INPUTS
r
2
(t) = ÷
1o
/
1 ÷
1
1 ÷c
2
c
t.(1)
cos [.
J
(t ÷t
1
) ÷c]
¸
. t _ t
1
. (11.3)
The total response is then:
r(t) =
1
o
/
1 ÷
1
1 ÷c
2
c
t.n
cos [.
J
t ÷c]
¸
. 0 _ t < t
1
. (11.4)
r(t) =
1
o
c
t.n
/
1 ÷c
2
¸
c
t.n1
cos [.
J
(t ÷t
1
) ÷c] ÷cos (.
J
t ÷c)
. t _ t
1
. (11.5)
Notice how, for the time interval after t
1
, the response no longer includes a
\1 ÷ " term; the addition of the two responses has removed this term entirely.
Again recalling a previous example, the \1 ÷" term caused the oscillation to be
about a new equilibrium (i.e., r = 1
o
´/). Now, since the term has disappeared,
the oscillation is centered around zero.
The movement of the center point of the oscillation is best shown in Figure
11.1, which tests three di¤erent values of 1
o
. The oscillation begins about a
center point at r = 1
o
´/. When the square wave ends, or, when the equal
and opposite step is added, the center point returns to zero. Assume, for a
moment, that the magnitude of the second step is not equal to that of the
…rst; call it 1
1
. In this case, the center point of the oscillation after adding
the second step input would be at r = (1
o
÷1
1
) ´/. To prove this to yourself,
perform the superposition used to obtain Equation 11.5, above (remember that
1
1
is negative!). A constant term will remain, and this term will be equal to
(1
o
÷1
1
) ´/. Another result which is evident from Figure 10.1 is that the change
in 1
o
causes the magnitude of the oscillations to increase, as would be expected
from Equation 11.5.
Figure 11.2 shows the e¤ects of changing the natural frequency. Notice that
a transition point occurs when the second step input is added. The sudden shift
in vibration characteristics is expected, since we have a piecewise expression for
r(t). But note that while the transition becomes more abrupt as the natural
frequency increases, it is never discontinuous. Since the motion of the mass
remains continuous, we can infer that the approach is correct; if we had obtained
a discontinuity in the motion, we would know the expression is incorrect. This
is because a discontinuous expression would imply that the mass moved from
one point to another nonadjacent point without passing through the points in
between, a physically impossible situation.
Finally, Figure 11.3 demonstrates the response behavior for three di¤erent
damping ratios. Again, notice how the high damping ratio (c = 0.3) causes all
of the vibration to be damped out quickly, so that the mass is practically at rest
79
when the second step input is applied. Again, we see that the transient period
decreases with increasing damping ratio.
The MATLAB code to produce these …gures demonstrates the vectorization
discussed in the previous example. Note how the logical operation t < t
o
is used
to create a matrix of zeros and ones, where the ones correspond to times before
t
o
. Then the MATLAB “not” operator (the tilde, ~) is used to arrive at times
after t
o
. The reader is encouraged to rewrite the vectorized calculation as a loop
(in any of the three codes) and see for himself the di¤erence in time expenditure
as the number of points is increased by a few orders of magnitude. While there
are no fewer actual calculations performed in the vectorized code, the di¤erence
is that MATLAB’s vector/matrix calculations are highly optimized, and so the
code is faster when handling one matrix calculation instead of many scalar
calculations.
One more di¤erence between these codes and the previous is that we’ve
inserted another use of the colon operator. As explained in Program 101, the
statement a = /(:); has a particular meaning in MATLAB. For a vector /.
MATLAB will return a column vector a that is equal to a column vector / or
the transpose of a row vector /. That is, if we wish to be certain whether a vector
we are working with is a column vector, then we can use the colon operator in
this manner to force it to be so; the output of a = /(:) is a column vector for
any vector /.
Another interesting consequence of this use of the colon operator is the result
for a matrix /. The colon operator would return a column vector a consisting of
the rows of / stacked on top of each other. The reader is encouraged to try this,
and see the results. Additionally, what would we do if we wanted to force a to be
a row vector? Finally, what if we wished to make these script instead functions,
taking the number of points in the time vector as inputs? How would we modify
the code then? The advantage would be that all the variables from the function
would not become part of our workspace. Often, this is a disadvantage from a
debugging perspective, but is very nice to have in working code.
80CHAPTER11 RESPONSE OF SDOF SYSTEMS TOSQUARE PULSE INPUTS
% Program 101: sqrewn.m
% This program …nds the response of a single
% degree of freedom system to a square wave input.
% The wave is assumed to begin at t=0, and lasts until
% t=to. The system mass is again assumed to be equal to 1.
%
npts=1000;
Fm=5;
zeta=0.05;
to=3;
tf=10;
t=linspace(0,tf,npts);
for i=1:3
wn(i)=input(’Enter a natural frequency. ’);
k(i)=sqrt(wn(i));
end
% Demonstrating another use of the colon operator.
% In this sense, wn(:) turns wn into a column
% vector if it was a row vector, and leaves it as
% a column vector if it was one already. Either
% way, we know the result will be a column vector wn.
wn=wn(:);
k=k(:);
%
% To use the logical operators, we need to create a vector
% that is one for t<to, and turn it into a matrix.
%
qtest=t<to;
qpiece=[qtest;qtest;qtest]; % 3bynpts matrix.
% Now, we need a similar sized matrix for the force magnitude.
Fo=Fm*ones(3,npts); % 3bynpts, again.
q=sqrt(1zeta^2);
% In order to calculate the response in a vectorized manner,
% we’ll need a wn, k, and wd for each point in time and each
% di¤erent value. That can be done by multiplying the
% 3by1 matrices we get from our input and calculation
% by ones(1,npts).
%
wd=wn*q; % 3by1 matrix.
wnmat=wn*ones(1,npts);
wdmat=wd*ones(1,npts);
kmat=k*ones(1,npts);
phi=atan2(zeta,q);
A=Fm./kmat; % We need a sti¤ness for each force/time point.
tmat=[t;t;t]; % And a 3bynpts time matrix.
x1=A.*(1exp(zeta*wnmat.*tmat).*cos(wdmat.*tmatphi)/q);
81
x2=A.*exp(zeta*wnmat.*tmat).*(exp(zeta*wnmat.*to).*cos(wdmat.*(tmat
to)phi)cos(wdmat.*tmatphi))/q;
x=x1.*qpiece+x2.*(~qpiece); % “not” qpiece.
for l=1:3
subplot(3,1,l)
plot(t,x(l,:))
title([’Square Wave Response for wn=’, num2str(wn(l)), ...
’, to=’,num2str(to),’ ,and Fm=’, num2str(Fm)])
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
82CHAPTER11 RESPONSE OF SDOF SYSTEMS TOSQUARE PULSE INPUTS
%Program 102: sqrefm.m
%This program …nds the response of a single
%degree of freedom system to a square wave input.
%The wave is assumed to begin at t=0, and lasts until
%t=to. The system mass is again assumed to be equal to 1.
%
npts=1000;
wn=11;
k=(wn)^2;
zeta=0.05;
to=3;
tf=10;
t=linspace(0,tf,npts);
for i=1:3
Fm(i)=input(’Enter a force magnitude. ’);
end
Fm=Fm(:); % See above.
% As with the step response example earlier,
% we can use MATLAB’s logical operators to
% create a piecewise function without resorting
% to a loop. This can be done with the
% statement: qtest=(tt1)(tt2), when
% the square wave begins at t=t1 and ends at
% t=t2. For the case of t1=0, a simpler
% statement is valid:
qtest=(t<to);
Fo=Fm*ones(1,npts); % Since solution is piecewise, we need Fm throughout.
% This code demonstrates vectorization of this
% piecewise expression. We’ll be making use of
% the qtest vector above to tell the code when
% to activate each solution.
%
qpiece=[qtest;qtest;qtest]; % One row for each Fm value.
q=sqrt(1zeta^2);
wd=wn*q;
phi=atan2(zeta,q);
A=Fo/k; % 3bynpts matrix.
tmat=[t;t;t]; % Again, 3bynpts.
x1=A.*(1exp(zeta*wn*tmat).*cos(wd*tmatphi)/q); % Solution for t<to.
x2=A.*exp(zeta*wn*tmat).*(exp(zeta*wn*to).*cos(wd*(tmatto)phi)cos(wd*tmat
phi))/q;
x=x1.*qpiece+x2.*(~qpiece); % ~is the “not” operator.
for l=1:3
subplot(3,1,l)
plot(t,x(l,:))
title([’Square Wave Response for wn=’, num2str(wn), ...
83
’, to=’,num2str(to),’ ,and Fm=’, num2str(Fm(l))])
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
84CHAPTER11 RESPONSE OF SDOF SYSTEMS TOSQUARE PULSE INPUTS
% Program 103: sqrez.m
% This program …nds the response of a single
% degree of freedom system to a square wave input.
% The wave is assumed to begin at t=0, and lasts until
% t=to. The system mass is again assumed to be equal to 1.
%
npts=1000;
wn=11;
k=(wn)^2;
Fm=7;
to=3;
tf=10;
t=linspace(0,tf,npts);
for i=1:3
zeta(i)=input(’Enter a damping ratio (zeta). ’);
end
zeta=zeta(:); % Once more.
% Again we will vectorize the code by using the logical operators
% on t and to. This time it will be somewhat easier, since the
% sti¤ness and force are scalar. We will need matrices for any
% quantities derived from the damping ratio, and for time.
%
qtest=t<to;
qpiece=ones(3,1)*qtest; % Another way to create the matrix.
tmat=ones(3,1)*t;
zmat=zeta*ones(1,npts); % 3bynpts.
q=sqrt(1zmat.^2); % 3bynpts. Note the array square operator.
wd=wn*q; % wd is 3bynpts.
phi=atan2(zmat,q); % MATLAB will handle this on an elementbyelement
basis.
A=Fm/k; % Scalar.
x1=A*(1exp(zmat*wn.*tmat).*cos(wd.*tmatphi)./q);
x2=A*exp(zmat*wn.*tmat).*(exp(zmat*wn*to).*cos(wd.*(tmatto)phi)cos(wd.*tmat
phi))./q;
x=x1.*qpiece+x2.*(~qpiece);
for l=1:3
subplot(3,1,l)
plot(t,x(l,:))
title([’Square Wave Response for wn=’, num2str(wn), ...
’, to=’,num2str(to),’ ,and zeta=’, num2str(zeta(l))])
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
85
0 1 2 3 4 5 6 7 8 9 10
0.05
0
0.05
R
e
s
p
o
n
s
e
x
Square Wave Response for wn=11, to=3 ,and Fm=3
0 1 2 3 4 5 6 7 8 9 10
0
0.2
R
e
s
p
o
n
s
e
x
Square Wave Response for wn=11, to=3 ,and Fm=7
0 1 2 3 4 5 6 7 8 9 10
0
0.2
Time, seconds
R
e
s
p
o
n
s
e
x
Square Wave Response for wn=11, to=3 ,and Fm=11
Figure 11.1: Plot of responses for three di¤erent force magnitudes.
86CHAPTER11 RESPONSE OF SDOF SYSTEMS TOSQUARE PULSE INPUTS
0 1 2 3 4 5 6 7 8 9 10
5
0
5
R
e
s
p
o
n
s
e
x
Square Wave Response for wn=4, to=3 ,and Fm=5
0 1 2 3 4 5 6 7 8 9 10
2
0
2
4
R
e
s
p
o
n
s
e
x
Square Wave Response for wn=8, to=3 ,and Fm=5
0 1 2 3 4 5 6 7 8 9 10
2
0
2
4
Time, seconds
R
e
s
p
o
n
s
e
x
Square Wave Response for wn=12, to=3 ,and Fm=5
Figure 11.2: Square wave response variation with di¤erent natural frequencies.
87
0 1 2 3 4 5 6 7 8 9 10
0
0.2
R
e
s
p
o
n
s
e
x
Square Wave Response for wn=11, to=3 ,and zeta=0.05
0 1 2 3 4 5 6 7 8 9 10
0
0.2
R
e
s
p
o
n
s
e
x
Square Wave Response for wn=11, to=3 ,and zeta=0.1
0 1 2 3 4 5 6 7 8 9 10
0
0.1
Time, seconds
R
e
s
p
o
n
s
e
x
Square Wave Response for wn=11, to=3 ,and zeta=0.3
Figure 11.3: E¤ects of changing damping ratio on the square wave response.
Chapter 12
Response of SDOF System
to Ramp Input
Another common form of input encountered in real applications is the ramp
input. To examine the response of a single degree of freedom system to this sort
of input, we must again apply the convolution integral. Assuming that the load
is increased uniformly at a rate of 1
o
per second and reaches its maximum at
time t
J
. then the expression for the external force is:
1(t) =
1
o
t for 0 _ t < t
J
.
1
o
t
J
for t _ t
J
.
(12.1)
Substituting the expression for 1(t) into the convolution integral yields:
r(t) =
]o
n.
d
c
t.n

0
tc
t.nr
sin.
J
(t ÷t)dt for 0 _ t < t
J
.
]o
n.
d
c
t.n

d
0
tc
t.nr
sin.
J
(t ÷t)dt + t
J


d
c
t.nr
sin.
J
(t ÷t)dt
for t _ t
J
.
(12.2)
This expression is best evaluated using MAPLE or a table of integrals.
r(t) =
1
o
:.
J
c
t.n
1
c
2
.
2
n
+ .
2
J
2
¸
.
J
c
t.n
tc
2
.
2
n
+ t.
2
J
÷2c.
n
+ 2c.
n
.
J
cos(.
J
t)
+
c
2
.
2
n
÷.
2
J
sin(.
J
t)
. 0 _ t < t
J
.
89
90CHAPTER12 RESPONSE OF SDOF SYSTEMTO RAMP INPUT
r(t) =
1
o
:.
J
c
t.n
1
c
2
.
2
n
+ .
2
J
2
¸
.
J
c
t.n
tc
2
.
2
n
+ t.
2
J
÷2c.
n
+ 2c.
n
.
J
cos(.
J
t)
+
c
2
.
2
n
÷.
2
J
sin(.
J
t)
+
1
o
t
J
/
÷
1
o
t
J
/
1 ÷c
2
c
t.n(
d
)
cos(.
J
(t÷t
J
)÷c). t _ t
J
.
(12.3)
Note that / represents the system sti¤ness. This solution is re‡ected in the
MATLAB code that follows. An important note about the solution for this
expression is that there is no equilibrium position, as seen for the step and
square wave responses, until after the input has levelled o¤. This is because the
constant that creates the new center point is the result of an integration that
does not start at zero, and no such integration exists in this solution until after
t
J
.
From Figure 12.1, one would infer that the transition to the new equilibrium
of vibration is discontinuous, as it was in the step and square wave responses.
Notice how the response seems to be nonexistent for the …rst few seconds, until
the load is fully applied, and then begins oscillating, as in the step response.
So, at this point, it is reasonable to assume that the ramp response and step
response of a single degree of freedom system are similar.
However, Figure 12.2 shows that this is not the case. This …gure only shows
the response during the transient loading period. Notice how the system is
oscillating during this period, around a constantly increasing equilibrium. That
is, if a line was drawn through the identical point on each period of the sinusoid,
the result would be a line of positive slope. This shows that the ramp response
does have a subtle di¤erence from the step response; the ramp response has
less de‡ection at the point in time that the full load is applied than the step
response.
The Matlab code below follows the same general structure we have seen
previously. We vectorize the code, so that we apply Matlab’s strength (vector
math) to the problem, avoiding the slower loops. Note that both portions
of the piecewise solution for r(t) are multiplied by the same constant factor.
Thus, we initialize the variable a1 in Program 101 once. Also, we use vector
multiplication to construct two solution matrices over the entire time interval.
Finally, we make use of Matlab’s logical operators to assemble the full piecewise
solution.
91
% Program 111: rampfo.m
%This program solves the ramp response of a
%single degree of freedom system. The external
%force is assumed of the form F(t)=fo*t, and
%is assumed to last for te seconds, after which
%it levels o¤ at F=fo*te until in…nity.
%Again, a unit system mass is assumed.
npts=1000;
wn=5;
zeta=.05;
wd=wn*sqrt(1zeta^2);
k=wn^2;
te=4;
for kr=1:3
fo(kr)=input(’Enter a force magnitude (fo). ’);
end
fo=fo(:); % Force fo to be a column vector.
tf=10;
t=linspace(0,tf,npts);
qtest1=t<te;
qtest2=tte;
% This time, we need two conditional matrices.
amult1=[qtest1;qtest1;qtest1];
amult2=[qtest2;qtest2;qtest2];
% This constant is used for both parts.
a1=fo/(k*(zeta^2*wn^2+wd^2)^2);
% The solution for t<te.
num1=t*(zeta*wn)^2+t*wd^22*zeta*wn;
num2=exp(zeta*wn*t).*(2*zeta*wd*wn*cos(wd*t)+ ...
((zeta*wn)^2wd^2)*sin(wd*t));
x1=a1*(num1+num2); % (3by1)*(1bynpts)=(3bynpts).
% Now, the solution for tte.
num3=te*(zeta*wn)^2+te*wd^22*zeta*wn;
num4=exp(zeta*wn*te)*(2*zeta*wd*wn*cos(wd*te)+ ...
((zeta*wn)^2wd^2)*sin(wd*te));
a=fo*te/k;
q=sqrt(1zeta^2);
phi=atan2(zeta,q);
r=a/q*(1exp(zeta*wn*(tte)).*cos(wd*(tte)phi));
s=a1*(num3+num4)*ones(1,npts); % num3 and num4 are scalars, so we
must vectorize this.
x2=r+s;
x=x1.*amult1+x2.*amult2; % This gives a matrix of three 1bynpts solution
vectors.
for i=1:3
subplot(3,1,i)
92CHAPTER12 RESPONSE OF SDOF SYSTEMTO RAMP INPUT
plot(t,x(i,:))
title([’Response for wn=’,num2str(wn),’, fo=’, ...
num2str(fo(i)),’ zeta=’,num2str(zeta)])
ylabel(’Response x’)
grid
end
xlabel(’Time, seconds’)
93
0 1 2 3 4 5 6 7 8 9 10
0.5
0
0.5
1
R
e
s
p
o
n
s
e
x
Response for wn=5, fo=3 zeta=0.05
0 1 2 3 4 5 6 7 8 9 10
0
2
4
R
e
s
p
o
n
s
e
x
Response for wn=5, fo=7 zeta=0.05
0 1 2 3 4 5 6 7 8 9 10
5
0
5
10
Time, seconds
R
e
s
p
o
n
s
e
x
Response for wn=5, fo=26 zeta=0.05
Figure 12.1: Response of a single degree of freedom system to di¤erent rates of
loading.
94CHAPTER12 RESPONSE OF SDOF SYSTEMTO RAMP INPUT
0 0.5 1 1.5 2 2.5 3 3.5 4
0
0.2
R
e
s
p
o
n
s
e
x
Response for wn=5, fo=3 zeta=0.05
0 0.5 1 1.5 2 2.5 3 3.5 4
0
R
e
s
p
o
n
s
e
x
Response for wn=5, fo=7 zeta=0.05
0 0.5 1 1.5 2 2.5 3 3.5 4
1
0
1
2
Time, seconds
R
e
s
p
o
n
s
e
x
Response for wn=5, fo=26 zeta=0.05
Figure 12.2: Focusing on the …rst few seconds of oscillation, showing that the
system does oscillate during the transient period.
Chapter 13
Response of SDOF Systems
to Arbitrary Periodic Input
An arbitrary periodic input can be thought of as any periodic input that cannot
be expressed as a single sine or cosine function. For example, a sum of sines
and cosines is an arbitrary periodic input. The most straightforward method to
analyze the response to a periodic input is the Fourier series. A Fourier series
representation of an arbitrary periodic function can take the form:
1(t) =
a
o
2
+
1
¸
n=1
(a
n
cos :.
T
t + /
n
sin:.
T
t) . (13.1)
where T is the period of the function, and .
T
=
2t
T
. The coe¢cients are obtained
by using the orthogonality properties of harmonic functions:
a
n
=
2
T
T
0
1(t) cos :.
T
tdt. : = 0. 1. 2. ...
/
n
=
2
T
T
0
1(t) sin:.
T
tdt. : = 1. 2. ....
These coe¢cients can be easily evaluated using the wellknown integrals:
T
0
sin:.
T
t sin:.
T
tdt =
0 if : = :.
T´2 if : = :.
95
96CHAPTER13 SDOF RESPONSE TOARBITRARY PERIODIC INPUT
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
Time, Seconds
F
(
t
)
Sawtooth Wave
Figure 13.1: Sawtooth wave to be de…ned by a Fourier series. One period is
shown.
97
T
0
cos :.
T
t cos :.
T
tdt =
0 if : = :.
T´2 if : = :.
T
0
cos :.
T
t sin:.
T
tdt = 0.
Using these relationships, the evaluation of the Fourier coe¢cients will be
come reasonable. As a demonstration, Figure 13.1 shows a plot of the sawtooth
wave for T = 5. The wave is de…ned by:
1(t) =
4
T
t ÷1 for 0 _ t _
T
2
.
1 ÷
4
T
t ÷
T
2
for
T
2
_ t _ T.
(13.2)
The Fourier coe¢cients which de…ne this function are a
0
= 0.
/
n
=
2
T
T/2
0
4
T
t ÷1
sin:.
T
t dt +
T
T/2
¸
1 ÷
4
T
t ÷
T
2
sin:.
T
t dt
¸
.
(13.3)
Using Maple, we …nd that this reduces to:
/
n
=
4 sin(:¬) ÷2 sin(2:¬) + :¬ cos(2:¬)
:
2
¬
2
÷
1
:¬
.
where : is an integer, sin(:¬) = sin(2:¬) = 0. and cos(2:¬) = 1. Thus, we
obtain:
/
n
=
:¬
:
2
¬
2
÷
1
:¬
= 0.
The only nonzero terms that describe this wave are the a
n
terms:
a
n
=
2
T
T/2
0
4
T
t ÷1
cos :.
T
t dt +
T
T/2
¸
1 ÷
4
T
t ÷
T
2
cos :.
T
t dt
¸
.
or
98CHAPTER13 SDOF RESPONSE TOARBITRARY PERIODIC INPUT
a
n
=
4 cos :¬ ÷2 cos 2:¬ ÷:¬ sin2:¬ ÷2
:
2
¬
2
. (13.4)
Note that since : is an integer, sin(2:¬) = 0 for all :. For even :. a
n
= 0.
However, for odd :. a
n
= ÷8´:
2
¬
2
. Therefore,
1(t) = ÷
8
¬
2
¸
cos
2¬
T
t +
1
9
cos
6¬
T
t +
1
25
cos
10¬
T
t + ...
. (13.5)
To evaluate this expression using Matlab, we would need to perform two
simple steps. First, we would need to …nd a point where the terms of the series
become negligible, to our desired level of accuracy. Then, we would need to
solve the vibrating system for each term of the in…nite series and superpose
these results. This process is not compatible with Matlab; the program needed
to perform this would be too long. For this reason, no such program is included
here. The program below shows that a few terms of the in…nite series can
provide a very close approximation to the total series.
This program is written as a function, taking as input the desired number of
terms in the Fourier series. The time span is presumed to be 5 seconds. In Figure
13.2, we plot the results for several numbers of terms to show the convergence.
To get di¤erent sawtooth waves, one would have to either change T (to get a
di¤erent period) or add a premultiplying factor (to change the amplitude). Such
improvements are left to the reader.
function [t,F]=foursaw(nterm)
% Program 1: foursaw.m
% This function returns the
% Fourier representation for
% a sawtooth wave having nterm
% number of nonzero Fourier coe¢cients,
% as well as a corresponding time
% vector (for ease in plotting).
%
t=linspace(0,5,500);
T=5; % Period of 5 seconds.
F=zeros(size(t));
if nterm<1
error(’Number of terms must be a positive integer!’)
end
for i=1:nterm
n=2*i1; % Getting odd values only.
F=F+(8/pi^2)*cos(2*pi*n/T*t)/n^2;
end
99
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
Time, seconds
S
a
w
t
o
o
t
h
a
p
p
r
o
x
i
m
a
t
i
o
n
1 term
3 terms
5 terms
10 terms
Figure 13.2: Four sawtooth approximations. Note that 10 terms provide a very
good approximation to the actual function.
Chapter 14
Free Vibration of MDOF
Systems
The simplest multidegree of freedom system is, of course, the two degree of
freedom system, for which we will consider free vibration in this example. As
sume that the system is as pictured in Figure 14.1. Note that we need two
coordinates to de…ne this system’s motion. Applying Newton’s second law to
each mass results in two governing equations
:
1
..
r
1
+ (/
1
+ /
2
)r
1
÷/
2
r
2
= 0 (14.1)
:
2
..
r
2
÷/
2
r
1
+ (/
2
+ /
3
) r
2
= 0. (14.2)
The motion of the masses are coupled. To solve these equations, it would be
advantageous if we could …nd a coordinate system in which the equations were
not coupled. Then, the problem would reduce to two single degree of freedom
Figure 14.1: Typical two degree of freedom free oscillator.
101
102 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS
systems, which we have already solved. The procedure of decoupling can be
shown in matrix notation:
:
1
0
0 :
2
¸
¸
..
x +
/
1
+ /
2
÷/
2
÷/
2
/
2
+ /
3
¸
¸
x = 0. (14.3)
where x =
r
1
r
2
. and
..
x =
..
r
1
..
r
2
. Let us denote the matrix multiplying
..
x by ' (the mass matrix) and the matrix multiplying x by 1. The modal
analysis procedure may then be summarized as follows:
1. Find the eigenvalues and matrix of eigenvectors for the matrix 1 ÷`'.
Let this matrix of eigenvectors be l, and denote its columns (the eigenvectors)
by ¦n¦
I
.
2. Normalize the eigenvectors with respect to the mass matrix through the
products ¦n¦
T
I
' ¦n¦
I
= 1. ¦n¦
T
I
1¦n¦
I
= .
2
I
= `
I
. where .
I
is the natural
frequency of mode i.
3. From the solution of the motion in the decoupled modal coordinates, we
arrive at:
x(t) =
2
¸
I=1
¦n¦
I
¦n¦
T
I
'x(0) cos .
I
t +
1
.
I
¦n¦
T
I
'
.
x(0) sin.
I
t
(14.4)
The main bene…t of this procedure (from a MATLAB standpoint) is that it is
easily extended to : degrees of freedom by changing the limit of the summation
in Equation 14.4 from 2 to :. Of course, we would also have : natural frequencies
and eigenvectors, but the procedures for …nding them (i.e., solving the eigenvalue
problem) and normalizing the eigenvectors with respect to the mass matrix are
unchanged. The following program, modfree.m, is capable of solving : degree
of freedom free vibration through the modal analysis procedure outlined above.
The following …ve …gures show the results of di¤erent masses, sti¤nesses, and
initial conditions on the motion. Recall that this is free vibration; zero initial
conditions will lead to zero motion. For the …rst three …gures, :
1
= 1. :
2
= 4.
/
1
= /
3
= 10. and /
2
= 2. Since the masses and sti¤nesses are not changing, the
natural frequencies for these cases will be identical: .
1
= 3.480. and .
2
= 1.700.
For Figure 14.2, the initial displacement of each degree of freedom is 1. Notice
how the second mode of vibration seems to show little evidence of the …rst
mode; it looks like a single sinusoid, instead of a sum of sinusoids. This is due
to the di¤erence in mass between the two degrees of freedom; remember that
the second mass is four times the …rst.
As validation for this assertion, look at Figure 14.3. This …gure has zero
initial velocity as well, but the initial displacements are now 3 and –2, respec
tively. Again, the second mode is vibrating along a single sinusoid; since the
103
mass ratio is unchanged, the mode behavior is as well. If we eliminated an initial
displacement from the second degree of freedom, we would expect the system
to vibrate in both modes, at least in the second degree of freedom. As Figure
14.4 shows, this is the case. Notice that the …rst mode only vibrates in one
frequency this time; this is because the displacement of the second mass and its
velocity are too small to impart any appreciable force on the …rst mass.
As a …nal proof of the e¤ects of the mass on the mode shapes, look at Figure
14.5. This …gure was created by interchanging the masses; the mass of 4 units
is in the …rst degree of freedom, and the mass of 1 unit is in the second. Notice
how the …rst mode shape is now a single sinusoid, and the second is a sum. A
peculiarity to this case is that the system is symmetric; that is, the response of
the …rst mode in Figure 14.2 matches that of the second mode in Figure 14.5,
and vice versa. This is due to the symmetric sti¤ness matrix. If we change the
value of either /
1
or /
3
, the symmetric behavior would no longer exist.
Figure 14.6 shows the e¤ects of adding an initial velocity to the system.
As expected from a single degree of freedom system, the initial velocity a¤ects
the slope of the response curve at the starting point, but has no e¤ect on the
qualitative aspects of the mode shapes, or on the natural frequencies. Also, the
maximum amplitude of vibration is increased for both modes.
Figure 14.7 shows the result of changing the mass matrix to : =
3 0
0 9
¸
¸
.
As a result, .
1
= 2.014. and .
2
= 1.131. These reduced natural frequencies are
re‡ected in the …gure; when compared to Figure 14.2, the curves of Figure 14.7
have a lower frequency. The curves look a little more “spread out” than those
in Figure 14.2. However, the second mode shape is still a single sinusoid, not a
sum like the …rst shape. Note that both initial displacements were again 1.
Finally, Figure 14.8 shows the result of changing /
1
and /
3
to 1 unit, and
/
2
to 3 units. The natural frequencies become .
1
= 2.150. and .
2
= 0.6154.
Again, the di¤erence between Figure 14.2 and Figure 14.8 is readily apparent.
A peculiarity that develops is that the …rst mass’s vibration comes in more
distinct peaks; one peak reaches 1, and the next is about 0.7. In Figure 14.2,
the di¤erence is 1 to less than 0.5.
104 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS
Program 131: modfree.m
% This code solves ndegree of freedom free
% vibration using the modal analysis techniques
% of Section 7.6.1.
%
clear;
M=input(’Enter the mass matrix: ’);
[n,o]=size(M);
if n~=o then
error(’M matrix must be square!’);
end
K=input(’Enter the sti¤ness matrix: ’);
[n,o]=size(K);
if n~=o then
error(’K matrix must be square!’);
end
qu=0;
[u,l]=eig(K,M);
% Using “eig” in this way allows us to subtract M*w^2
% from K, instead of I*w^2 (where I is the n by n identity
% matrix).
% The output from “eig” gives unitlength eigenvectors.
% We need to scale them with respect to M.
%
for s=1:n
alfa=sqrt(u(:,s)’*M*u(:,s));
u(:,s)=u(:,s)/alfa;
end
x0=input(’Enter the initial displacement column vector: ’);
xd0=input(’Enter the initial velocity column vector: ’);
tf=input(’Enter the …nal time: ’);
t=0:0.1:tf;
q=tf/0.1;
x=zeros(size(n,q));
% Applying Equation 7.183.
%
for j=1:n
w(j)=sqrt(l(j,j));
xt=u(:,j)*(u(:,j)’*M*x0*cos(w(j).*t)+u(:,j)’*M*xd0/...
w(j)*sin(w(j).*t));
x=x+xt;
end
% Plotting the modes in a subplot format.
% Note that, for more than 3 or 4 degrees
% of freedom, the plots will become nearly
% unreadable.
105
%
for r=1:n
subplot(n,1,r)
plot(t,x(r,:))
xlabel(’Time, seconds’);
ylabel([’Response x’,num2str(r)]);
end
106 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS
0 5 10 15 20 25 30
1
0.5
0
0.5
1
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
2
1
0
1
2
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 14.2: Response to initial displacement vector of [1 1].
107
0 5 10 15 20 25 30
4
2
0
2
4
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
2
1
0
1
2
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 14.3: Response after changing initial displacement to [3 –2].
108 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS
0 5 10 15 20 25 30
1
0.5
0
0.5
1
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
0.2
0.1
0
0.1
0.2
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 14.4: Response after changing initial displacement to [1 0].
109
0 5 10 15 20 25 30
1
0.5
0
0.5
1
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
0 5 10 15 20 25 30
2
1
0
1
2
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
Figure 14.5: Response after interchanging system masses.
110 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS
0 5 10 15 20 25 30
2
1
0
1
2
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
2
1
0
1
2
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 14.6: Response with initial velocity [4 2] and initial displacement [1 1].
111
0 5 10 15 20 25 30
1
0.5
0
0.5
1
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
2
1
0
1
2
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 14.7: Response with increased system masses.
112 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS
0 5 10 15 20 25 30
1
0.5
0
0.5
1
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
2
1
0
1
2
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 14.8: Response with reduced system sti¤nesses.
Chapter 15
Damping of MDOF Systems
In the previous example, the free response of systems having more than one de
gree of freedom was discussed. Now, viscous damping is added to the system, as
shown in Figure 15.1, and we will examine the changes caused by this addition.
The equations of motion become:
:
1
..
r
1
+ (c
1
+ c
2
)
.
r
1
÷c
2
.
r
2
+ (/
2
+ /
1
) r
1
÷/
2
r
2
= 0 (15.1)
:
2
..
r
1
+ c
2
.
r
2
÷
.
r
1
+ /
2
(r
2
÷r
1
) = 0. (15.2)
In matrix form, we obtain:
'
..
x + C
.
x + 1x = 0.
where ' =
:
1
0
0 :
2
¸
¸
. C =
c
1
+ c
2
÷c
2
÷c
2
c
2
¸
¸
. 1 =
/
1
+ /
2
÷/
2
÷/
2
/
2
¸
¸
.
As we know, with damping present, there is no guarantee that the equations
will decouple by the procedure used earlier. However, for proportional damping,
i.e., C = C
n
' + C

1. it is possible to follow the previous decoupling proce
dure. This is because both 1 and ' are diagonalized through the matrix of
eigenvectors l. Thus, a scalar multiplied by ' or 1 will also be diagonalized,
and the sum of two diagonal matrices is also diagonal.
While proportional damping is something of a savior for modal analysis, it
presents a headache when programming. The only way to assure decoupled
equations in a program is to specify C
n
and C

instead of entering the matrix
113
114 CHAPTER 15 DAMPING OF MDOF SYSTEMS
C into the program, or to take the matrix C, go through the …rst two steps of
modal analysis with it, and then check it for diagonality. Both of these methods
have ‡aws; in the …rst case, the person using the program may not know C
n
and C

at all, and they may be di¢cult to calculate. For the second algorithm,
the program may run through a signi…cant amount of calculation to deduce that
the given data is invalid. This wastes time and e¤ort, especially if the data is
invalid due to an error in entry of values. So, when programming, the most
e¢cient way to handle damping is through the modal damping ratios (though
the program given below retains some ‡exibility by allowing entry of the modal
damping ratios or the factors C
n
and C

).
The modal damping ratios are simply an analogue for the damping ratios
we saw earlier in our study of single degree of freedom systems. They are called
modal damping ratios because they are applied independently to each modal
(decoupled) equation; the modal damping ratios are automatically decoupled.
Calling the modal damping ratios c
I
. where i is the number of the mode being
examined, the equations of motion in the modal coordinates become:
..
c
I
+ 2c
I
.
I
.
c
I
+ .
2
I
c
I
= 0. i = 1. 2. . . . . (15.3)
where c is the modal coordinate variable, and .
I
represent the natural frequen
cies of each mode. This is the same as for the damped single degree of freedom
oscillator, whose solution was:
c
I
(t) = ¹
I
c
t
i
.i
sin(.
JI
t + c
I
). (15.4)
where .
JI
is the damped natural frequency of that mode (.
I
1 ÷c
2
I
). and
¹
I
=
¸
.
c
Io
+ c
I
.
JI
c
Io
2
+ (c
Io
.
JI
)
2
.
2
JI
¸
1/2
(15.5)
Figure 15.1: Two degree of freedom damped oscillator under consideration here.
115
c
I
= tan
1
c
Io
.
JI
.
c
Io
+ c
I
.
JI
c
Io
. (15.6)
noting that c
Io
and
.
c
Io
refer to the initial displacement and velocity in the modal
coordinate, respectively. Having obtained the solution for q(t). we then use the
last step of the modal analysis procedure to …nd x(t). Note that this method
uses the entire modal analysis procedure as if damping did not exist, and then
adds in the damping when solving for c
I
(t). The program at the end of this
example, used to generate the …gures that follow, demonstrates this approach.
Figures 15.2 through 15.4 use :
1
= 9. :
2
= 1. /
1
= 24. /
2
= 3. c
1
= 0.05.
and c
2
= 0.1. Figure 15.2 uses an initial displacement vector of r
0
= [1 0]. and
the results show the e¤ect of the damping; the response gradually dies out. In
Figure 15.3, an initial velocity of [3 2] is added, and the result is no increase
in the transient period (as expected), but an increase in amplitude. Finally,
Figure 15.4 removes the velocity and changes the initial displacement to [2 1].
and the result is a greater amplitude, but the same length of transient period
as Figure 15.3. In all three …gures, note that both responses show the e¤ects of
multiple sinusoids, even though the …rst mass is much greater than the second.
This is because the …rst sti¤ness is very large; this sti¤ness keeps the mass from
gaining too much velocity, and so the smaller mass can e¤ectively transfer its
momentum to the larger.
Finally, Figure 15.5 changes the damping ratios to c
1
= 0.07 and c
2
= 0.03.
The di¤erence between this …gure and Figure 15.2 is that here the responses have
a greater amplitude and a larger transient period, due to the smaller damping
ratios.
116 CHAPTER 15 DAMPING OF MDOF SYSTEMS
Program 141: moddamp.m
% This code solves ndegree of freedom damped
% vibration using the modal analysis techniques
% of Section 7.6.3.
%
clear;
M=input(’Enter the mass matrix: ’);
[n,o]=size(M);
if n~=o
error(’M matrix must be square!’);
end
K=input(’Enter the sti¤ness matrix: ’);
[n,o]=size(K);
if n~=o
error(’K matrix must be square!’);
end
% Giving the option to input damping via
% modal damping ratios or through the multiplying
% factors Cm and Ck.
%
fprintf(’Press 1 to enter modal damping ratios, ’)
qz=input(’or anything else to enter Cm and Ck. ’);
if qz==1
for iz=1:n
zeta(iz)=input([’Enter the damping for mode ’,num2str(iz),’: ’]);
end
else
fprintf(’Given that [c]=Cm[M]+Ck[K], ’);
Cm=input(’Enter the factor Cm: ’);
Ck=input(’Enter the factor Ck: ’);
end
qu=0;
[u,l]=eig(K,M);
% Using “eig” in this way allows us to subtract M*w^2
% from K, instead of I*w^2 (where I is the n by n identity
% matrix).
% The output from “eig” gives unitlength eigenvectors.
% We need to scale them with respect to M.
%
for s=1:n
alfa=sqrt(u(:,s)’*M*u(:,s));
u(:,s)=u(:,s)/alfa;
end
x0=input(’Enter the initial displacement column vector: ’);
xd0=input(’Enter the initial velocity column vector: ’);
tf=input(’Enter the …nal time: ’);
117
t=0:0.1:tf; q=tf/0.1;
x=zeros(size(n,q));
for j=1:n
w(j)=sqrt(l(j,j));
% If modal damping ratios were entered, we already have
% a zeta vector. If not, we need to calculate from Cm
% and Ck.
%
if qz~=1
zeta(j)=0.5*(Cm/w(j)+Ck*w(j));
end
wd(j)=w(j)*sqrt(1zeta(j)^2);
xt=u(:,j)*(u(:,j)’*M*x0*cos(w(j).*t)/sqrt(1zeta(j)^2)+u(:,j)’*M*xd0/...
w(j)*sin(w(j).*t)/wd(j));
x=x+xt;
end
for i=1:n
x(i,:)=x(i,:).*exp(zeta(i)*w(i).*t);
end
for r=1:n
subplot(n,1,r)
plot(t,x(r,:))
xlabel(’Time, seconds’);
ylabel([’Response x’,num2str(r)]);
end
118 CHAPTER 15 DAMPING OF MDOF SYSTEMS
0 5 10 15 20 25 30
1
0.5
0
0.5
1
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
2
1
0
1
2
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 15.2: Damped response of a two degree of freedom system.
119
0 5 10 15 20 25 30
2
1
0
1
2
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
6
4
2
0
2
4
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 15.3: Response of a damped 2DOF oscillator after adding an initial
velocity.
120 CHAPTER 15 DAMPING OF MDOF SYSTEMS
0 5 10 15 20 25 30
2
1
0
1
2
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
4
2
0
2
4
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 15.4: Response of the same system to a di¤erent initial displacement.
121
0 5 10 15 20 25 30
1
0.5
0
0.5
1
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
0 5 10 15 20 25 30
2
1
0
1
2
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 15.5: Response of the 2DOF system with di¤erent modal damping ratios.
Chapter 16
A Universal Vibration
Solver
The next logical step in this sequence of examples would now be to introduce
forcing functions of di¤erent types (as seen earlier with the single degree of
freedom cases), and create several di¤erent programs. While this method is
e¤ective, it is not e¢cient by any stretch of the imagination. The best way to
proceed from here would be to create a program that solves all vibration cases,
no matter what the forcing function or number of degrees of freedom.
The simplest way to go about this is to begin with a general program that
does not include the external force. Program 1, ndofold.m, demonstrates this
method. Some techniques used in this program demonstrate ways to make a
program modular. We need a general program to be as modular as possible
so that any changes that need to be made between runs of the program (like
changing the masses or the sti¤nesses) can be done without editing the code.
The …rst major step in achieving this goal is the …rst line of the code. This line
assigns a variable to the number of degrees of freedom. This way, in any loops
or assignment statements made afterward, this variable can be referred to, and
can represent any number of degrees of freedom.
The next several lines initialize the variables needed later. This is done in
lieu of a clear statement, because the clear statement will remove some variable
that will be needed later. Additionally, not using the clear command has the
advantage of allowing the user to assign variable names to the desired mass,
sti¤ness, and other matrices. This way, when the program prompts for these
later, the user need only enter the variable name, not the entire matrix. If clear
is used, the matrices cannot be created beforehand. The tradeo¤ in not using
clear is that MATLAB must be told how large the matrices are to be; if these
sizes are not speci…ed, MATLAB will think the variables are to be the size that
they are already. If we are now solving a three degree of freedom problem,
and we had just previously solved a 2DOF system, MATLAB will think the
mass matrix is to be 2 by 2. The …fth element entered would set o¤ an error
123
124 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER
message. The command used …lls each matrix with zeros; this is a harmless way
to initialize variables. Note how the variable : is used throughout this portion;
imagine the headache that would be involved if the program had not prompted
for : earlier. Each time an : appears, a change would have to be made to allow
a di¤erent number of degrees of freedom to be analyzed.
After the initialization section, the program prompts for each matrix that
will be needed. Having the necessary information, the program then solves the
system by modal analysis, and prints out the output. Note how each calculation
is done in loops that run from 1 to :. This maintains the generality of the
program, allowing the user to specify with the …rst input how large the matrices
will be. Notice also that the plots are put up one at a time. This is done
because there is no way to guarantee a subplot of any number of columns will
be readable. Imagine a forty degree of freedom system, and you will understand
why a subplot cannot be guaranteed. So, the pause command is implemented
after each plot to allow the user to examine each plot to his satisfaction and
to get a printout of the plot before the next one comes up (a printout can
be obtained from the graphics window in MATLAB for Windows only). The
program does not automatically print the graphs because they may be incorrect
or uninteresting, and to print them in such a case would be a waste of time and
paper. However, modifying the program to specify printing would take a few
seconds (replace pause with print in the code). Also, a loop could be created at
the beginning of the program to allow the user to specify whether output goes
to the screen only, to a …le, to the printer, or to a combination of the three. A
sample of such a loop follows here:
%This loop allows the user to specify the nature of the output.
%Notice how the loop assumes that the user will enter the
%wrong response; this is to correct for any mistakes, and
%to thwart those who love to crash programs.
%Also, the program initializes the variable right before the loop
%to the value necessary to continue the loop.
outp=8;
while outp==8
fprintf(’Enter 1 to print to the screen only, 2 to print to a …le, `n’)
outp=input(’or 3 to print to the printer. ’);
%Notice how the text was split across two lines by using
%the fprintf statement. This allows the text for input
%statements to be as long as needed.
%
if outp~=1&outp~=2&outp~=3
%Translation: “If outp isn’t equal to 1, 2, or 3.”
%“~” means “not” for a MATLAB logical statement,
%and the ampersand (&) is “and”, as usual.
%This is where we let the user know he’s made a mistake.
fprintf(’Enter 1, 2, or 3!!!’)
%Direct and to the point.
125
%Now, outp is reset to the value needed to continue the
%loop, since we need the loop to continue.
%
outp=8;
end
end
%One “end” for the “if”, and one for the “for”.
%A common mistake is to leave one out, and then
%MATLAB tells you that it came to the end of the
%…le in the middle of a loop. (Not a pleasant feeling.)
So, there’s the loop! It’s not long (without the comments), and it’s e¤ective.
It can be expanded as much as necessary to allow for any combination of printing
options. One more thing: to get this to work, you need to put the following into
the printout loop (where the pause is now):
if outp==2
%“==” in MATLAB is “equals” to you and me.
print dps …le1.ps
elseif outp==3
print
elseif outp==1
pause
end
Note that if you type “else if” instead of “elseif”, MATLAB reads the “else
if” as a new if statement, needing its own end. Another common mistake.
Now, it’s just a matter of adding forcing functions to the mix. This task,
however, is nearly impossible to do in a general way with the algorithm selected.
So, we need to go back to the drawing board and …nd a simpler method. The
…rst thing to realize is that the di¤erences among the several possible vibration
cases occur in solving the di¤erential equations. Every problem in vibrations
begins as a set of secondorder di¤erential equations, possibly coupled, possibly
not. Fortunately, MATLAB has the ode45 command, which solves di¤erential
equations numerically for a given time interval and initial conditions. Unfortu
nately, this command requires that the di¤erential equations exist in a function
M…le which de…nes the system of di¤erential equations. Also, these di¤erential
equations must be …rstorder.
The problem of order is really not a di¢culty at all; there is a method by
which a secondorder di¤erential equation can be transformed into a system of 2
…rstorder equations. However, unless a general M…le can be created, the user
would have to create his own function M…le each time, which would then be
used for ode45. So then where would be the use of a program?
The answer lies in automating the process of creating an M…le. MATLAB
has …le transfer protocols, like any other programming language. We can write a
program that tells MATLAB to create a speci…c M…le from a general procedure
126 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER
we write into the program, and then solve the resulting system of di¤erential
equations with ode45. Program 2, ndof.m, performs this task.
Again, the program begins by specifying the number of degrees of freedom
for the run. The necessary matrices are initialized, and the inputs are obtained.
After this, the program performs the …rst few steps of modal analysis, in order
to …nd the natural frequencies. We can do this because the natural frequencies
only depend on the mass and sti¤ness matrices; we know that these can be
decoupled.
The next set of commands are initiated if a damping ratio matrix was en
tered. This loop changes the damping ratios into damping coe¢cients, by re
versing the modal analysis procedure. This can be done because the damping
ratio vector that the user enters is related to the diagonal of the decoupled
damping coe¢cient matrix. Since this damping coe¢cient matrix is decoupled,
it can be transformed from the modal coordinate system (the decoupled coor
dinate) back to the original coordinate system by applying the reverse of the
modal analysis procedure.
Now that the program has the original values of the mass, sti¤ness, and
damping coe¢cient matrices, the M…le can be created. The program …rst
opens the …le with the fopen command. The strings in parentheses by the
command specify the …lename, and the read/write privilege desired (‘w+’ means
’write and overwrite,’ which allows a user of this program to make several runs
in succession without erasing the M…le previously created; the previous M…le
is lost). The fopen command is set equal to a variable because the command
speci…es an arbitrary number by which MATLAB identi…es the …le. The only
way to get this number is by setting fopen equal to a variable, so that this
number will be stored in an accessible place.
The reason that we need this identi…cation number is shown by the fprintf
statements that follow the fopen command. Each statement begins with the
…le identi…cation number, so that MATLAB knows to write the text to the …le
speci…ed earlier, not to the screen. If the …le identi…cation number was not set
equal to a variable, we would have no way to access it, and no way to write to
the …le.
Next, the functions de…ning the external forces on each degree of freedom
are entered individually. This is necessary because a text string entered into
a MATLAB variable is stored one character per matrix element. So, if all the
external forces were entered at once, there would be no way of telling how long
the force variable would be, or how many elements the matrix would have. The
method used in the program avoids these di¢culties.
Notice the use of the num2str command within the fprintf statements. This
command allows the value of a variable to be used in a text statement as text;
it is possible to use the value of a variable in an fprintf statement, but not as
text. Note that to use the num2str command, the text to be printed must be
within brackets as well as parentheses; this is because, if the brackets are not
included, MATLAB thinks the statement ends when the quotes are closed, and
will produce an error instead of including the desired value of the variable.
Finally, the program uses an fclose statement to tell MATLAB that nothing
127
else is to be entered into the …le. This is set equal to a variable, because
MATLAB indicates a successful write transfer through the fclose statement;
a user can tell if the …le was written successfully by seeing the value of this
variable.
Now, the program takes initial values necessary for ode45, and solves. The
plots come printed individually; a print loop similar to the one described above
can be inserted into this code to allow printing to a printer or to …les.
Figures 16.1 and 16.2 show the results of using ndof.m. Each …gure represents
a degree of freedom of the system, whose parameters are as follows: :
1
= 9.
:
2
= 1. c
1
= 2.7. c
2
= 0.3. /
1
= 27. /
2
= 3. 1
1
= 0. 1
2
= 3 cos 2t. Notice how
each degree of freedom shows the transient response over the …rst two seconds,
and then settles into a steadystate response based on the single forcing function.
The natural frequencies calculated by the program are .
1
= 1.41 and .
2
= 2.00.
which match those calculated by hand. Also, the responses of each mode are
found through manual calculation to be:
r
1
(t) = 0.2451 cos(2t + 0.1974) ÷0.6249 sin(2t) (16.1)
r
2
(t) = 0.7354 cos(2t + 0.1974) + 1.8749 sin(2t). (16.2)
Looking at the maximum magnitudes of the responses shown in Figures 16.1
and 16.2, we see that they are approximately equal to the sum of the coe¢cients
of the sine and cosine terms in the expression above, as we would expect. So,
from this example, we see the power of the program and, more importantly,
verify that the program works.
128 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER
Program 161: ndofold.m
%This program calculates the damped response of
%multidegree of freedom systems without external forcing.
%The user must enter the modal damping ratios; no other
%method of describing damping is supported.
n=input(’How many degrees of freedom are present? ’);
m=zeros(n,n);
k=zeros(n,n);
s=zeros(n,n);
p=zeros(n,n);
l=zeros(n,n);
ac=zeros(1,n);
phi=zeros(1,n);
m=input(’Enter the mass matrix. ’);
ko=input(’Enter the sti¤ness matrix. ’);
zeta=input(’Enter the damping ratio (zeta) matrix. ’);
x0=input(’Enter the initial displacements. ’);
xp0=input(’Enter the initial velocities. ’);
ti=input(’Enter the initial time. ’);
tf=input(’Enter the …nal time. ’);
t=ti:(tfti)/1000;tf;
[b1,b2]=size(t);
x=zeros(n,b2);
r=zeros(n,b2);
a=m^(1/2);
kt=a*ko*a;
[p,l]=eig(kt);
s=a*p;
si=inv(s);
r0=zeros(n,1);
rp0=zeros(n,1);
r0=si*x0’;
rp0=si*xp0’;
w=sqrt(l);
wd=zeros(size(w));
for k=1:n
wd(k,k)=w(k,k)*sqrt(1zeta(k)^2);
end
%Note that the same loop control variable can be used for
%every loop, so long as the loops are not nested within
%each other.
for k=1:n
ac(k)=sqrt(wd(k,k)^2*r0(k)^2+(rp0(k)+zeta(k)*w(k,k)*r0(k))^2)/wd(k,k);
phi(k)=atan2(wd(k,k)*r0(k),(rp0(k)+zeta(k)*w(k,k)*r0(k)));
r(k,:)=ac(k)*exp(zeta(k)*w(k,k)*t).*sin(wd(k,k)*t+phi(k));
end
129
x=s*r;
clg
for k=1:n
plot(t,x(k,:))
o=num2str(k);
title([’Response x’,o])
xlabel(’Time, seconds’)
ylabel(’Displacement’)
grid
…gure(gcf)
pause
end
for k=1:n
fprintf(’Natural frequency w%g=%g `n’,k,w(k,k))
end
Program 162: ndof.m
%This program, as stated above, writes its own
%M…le to use in ode45. This algorithm allows
%any external force combination to be examined,
%and also allows the external force to be
%a userde…ned function.
n=input(’How many degrees of freedom are present? ’);
x=zeros(1,2*n);
ct=zeros(n,n);
m=input(’Enter the mass matrix. ’);
aw=2;
while aw==2
fprintf(’Press 0 to enter a damping coe¢cient matrix, or’)
aw=input(’press 1 to enter a damping ratio (zeta) matrix. ’);
if aw==0
c=input(’Enter the damping coe¢cient matrix. ’);
elseif aw==1
zeta=input(’Enter the damping ratio matrix. ’);
else
fprintf(’Please enter 0 or 1.’)
aw=2;
end
end
k=input(’Enter the sti¤ness matrix. ’);
a=m^(0.5);
kt=a*k*a;
[p,q]=eig(kt);
omega=sqrt(q);
if aw==1
for zt=1:n
ct(zt,zt)=zeta(zt)*2*omega(zt,zt);
130 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER
end
af=a^(1);
c=af*ct*af;
end
…d=fopen(’pdx.m’, ’w+’);
fprintf(…d,’function pdx=pdx(t,x)`n’);
for i=1:n
fprintf(…d,[’pdx(’,num2str(i), ’)=((’]);
for j=1:n
if k(i,j)==0
else
fprintf(…d,[’(’,num2str(k(i,j)),’)*x(’,num2str(j+n),’)’]);
end
if c(i,j)==0
else
fprintf(…d,[’+(’,num2str(c(i,j)),’)*x(’,num2str(j),’)’]);
end
end
f=input([’Enter F’,num2str(i), ’(t) in quotes, like ‘3*cos(2*t)‘. ’]);
fprintf(…d,[’)+(’,num2str(f),’))/(’,num2str(m(i,i)),’);`n’]);
end
for i2=1:n
fprintf(…d,[’pdx(’,num2str(i2+n),’)=x(’,num2str(i2),’);`n’]);
end
status=fclose(…d);
v0=input(’Enter the initial velocities as a row vector. ’);
x0=input(’Enter the initial displacements as a row vector. ’);
ti=input(’What is your initial time? ’);
tf=input(’What is your …nal time? ’);
init=[v0,x0];
[t,ny]=ode45(’pdx’,ti,tf,init);
for kl=1:n
plot(t,ny(:,kl+n),’b’);
title([’Response x’,num2str(kl)]);
xlabel(’Time, seconds’);
ylabel(’Displacement, m’);
grid
…gure(gcf)
pause
end
for l=1:n
fprintf(’Natural frequency w%g=%g. `n’,l,omega(l,l))
end
131
0 2 4 6 8 10 12 14 16 18 20
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x1
Figure 16.1: Response of the …rst mode.
132 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER
0 2 4 6 8 10 12 14 16 18 20
2.5
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
,
m
Response x2
Figure 16.2: Response of the second mode.
Chapter 17
Modeling a van der Pol
Oscillator
The next several examples will examine how we can use Matlab to solve for
more realworld vibratory systems. The …rst such system we will look at is
the oscillatory motion of a structure surrounded by a ‡uid. Examples of such
structures include the support pylons of o¤shore oil platforms and antennae
attached to the exterior surfaces of aircraft. These structures exhibit vibratory
motion due to the creation of vortices in the ‡uid by viscous interaction between
the structure and the particles comprising the ‡uid. Several investigators have
applied the van der Pol equation,
• r + c
r
2
÷1
_ r + r = 0. c 0 (17.1)
as a model for the motion of such a structure. Note that this equation, given
the positive parameter c. exhibits the usual form of damping when [r[ < 1. How
ever, when [r[ 1. the term multiplying _ r will become negative. If we were to
solve for • r. then, the damping term would add energy to the system, instead
of removing it. This negative damping approximates some of the phenomena
observed in such ‡uidstructure interactions, and so is an attractive (and nec
essary) feature of the model. (The text gives a brief discussion of this problem
as well, in Section 2.4.2.)
We will demonstrate how we can use Matlab to help us visualize the solution
to such a problem. First, we must solve the nonlinear ordinary di¤erential
equation given above. Unfortunately, we will not be able to arrive at an analytic
solution, as we did with several of the earlier problems we examined. What
we will be forced to do, then, is to integrate the equation analytically over a
particular time interval.
At …rst glance, it appears that we should be able to use a program like
the general solver in the previous example. This impression is correct, but to
use such a program would be wasteful. Why would we use a program that
was designed for a general case, having many varied inputs, when the only
133
134 CHAPTER 17 MODELING A VAN DER POL OSCILLATOR
parameters we will have to use here are the parameter c, the initial conditions,
and the time step?
The trouble then becomes, how are we going to allow the parameter c to
be dynamically assigned to the function in question? Our answer will come
from Matlab’s global variable capability. We will also de…ne our van der Pol
oscillator solver as a function, so we can demonstrate another useful technique
to generalize Matlab functions. We will make c_o into a global variable, so that
it can be passed freely between the main function and the function evaluating
the van der Pol equation. (We will explain why we do not simply make c into
a global variable in a moment.) This is illustrated in the code below; Program
1 is the main function, and Program 2 is the function used by ode45 to solve
the equation. We also introduce the nargin statement with this program. This
command reads the input to the function, evaluating how many input arguments
have been passed into it (you can think of it as Number of ARGuments INput).
We de…ne the function to take three inputs, but by using nargin, we allow as
few as zero inputs to be passed to the function, providing default values for
each input parameter. This allows our function to be quite ‡exible; if we’re
only interested in looking at the e¤ects of changing the parameter c. we need
not remember to pass in the same initial conditions and time span. We can use
the default values provided by the function in each case.
To assign these default values, we test the value of nargin three times. If
this value is zero, the three if statements provide all of the default input data.
If it is one, the function uses the default values for the initial state and the time
span. If the number of arguments is two, the function uses only the default time
span. (Experienced C programmers may be wondering why we chose three if
statements instead of a switch statement. The reader is invited to recast the
nargin processing portion of this program to use the switch operator, and see
how the program changes.)
Our trick to make this function work is to declare the parameter c_o as
global. Note that there are two global statements in the programs below;
one at the start of the main function, and one at the beginning of the function
used by ode45. Also note that there are no semicolons at the end of these
statements; there is no output to suppress, so semicolons are unnecessary. We
are then able to use c_o in the subfunction as if it was assigned there, and not in
the parent function, after initializing c_o to the value of c. This construction is
needed because the function to be evaluated by ode45 must be a function of the
state and the time; adding in an extraneous third parameter will lead to errors.
We could de…ne every variable we use as global, but that would uneccessarily
clutter the workspace with variables, and is considered poor technique. Global
variables should be used with caution, as they allow parameters inside of a
function to be changed transparently (for example, we could write Program 2
to adjust the value of c. e¤ectively defeating the input value). The bene…t of
creating this van der Pol solver as a function is that the only variables created in
the workspace are the outputs t and r; not even the global variable c_o remains
in the workspace after function termination.
Now, why did we go to the trouble of introducing a spare parameter c_o to
135
be our global variable? The answer comes from how Matlab handles its global
variables. If you were to change c_o to c in the given code, you would …nd
no trouble for the default case (no input arguments). However, if you called
the function with a speci…c value of c. Matlab would print a warning statement
saying that the value of your local variable (c) “may have been changed to
match the global.” This is because Matlab sees the variable c that is input to
the function as a variable local to the function, and then sees the same variable
declared as global later. Since the tail end of the warning includes the ominous
statement “Future versions of Matlab will require that you declare a variable to
be global before you use that variable,” this author thinks it prudent to write
his code in a way that will be forwardcompatible, where possible. That means
that our global variables will not be used before they are declared. In general,
we will set apart our global variables with a trailing “g,” like in the program
below. The curious reader is encouraged to rewrite the code to use c as a global
parameter, generating the Matlab warning.
The two …gures below show some results for the default case (as de…ned
in Program 1). Figure 17.1 shows a simple comparison of displacement versus
time; we see oscillatory behavior. The other two …gures that follow are phase
diagrams
1
, which are plots with the velocity on the yaxis and displacement on
the xaxis. These diagrams are often used in studies of nonlinear and chaotic
systems, since they can clearly show the e¤ects of initial conditions on the
response.
The key feature of Figure 17.2 is the closed loop. Note that the initial lo
cation is denoted by a circle, and the …nal state by a triangle. The closed loop
means that the van der Pol system eventually settled down into oscillatory be
havior. We can prove to ourselves that a closed loop in phase space corresponds
to an oscillating response by considering the function r = sin(t) . If we take
this (obviously oscillating) function as our displacement, then the velocity is
described by n = cos (t) . If we were to plot this result in phase space, we would
arrive at a circle; these functions r(t) . n (t) are parametric equations for a circle.
The van der Pol oscillator’s loop is not precisely circular, so it is not periodic
in the same regular way as the sine or cosine function. However, it will repeat
the same sets of positions and velocities.
Figure 17.3 is the same default system with di¤erent initial conditions;
we used the command [t. r] = :o·c·dj (0.5. [÷1. 5]) . Again, this initial point
([÷1. 5]) is denoted by a circle, and the …nal point by a triangle. Note that, in
spite of the di¤erent initial conditions, the motion settles into the same limit
cycle. Thus, the limit cycle is determined by the parameter c. and not by the
initial conditions. This limit cycle behavior is similar to a phenomenon seen in
the vibration of structures in a moving ‡uid; thus, several investigators have
used the van der Pol equation to describe these systems. The reader is encour
aged to try di¤erent initial conditions to see that the limit cycle is indeed a
universal of the system.
2
1
Also called phase portraits by some authors.
2
However, changing the parameter e will certainly change the form of the limit cycle in
136 CHAPTER 17 MODELING A VAN DER POL OSCILLATOR
function [t,x]=solvevdp(e,x0,tspan)
% Program 1: solvevdp.m
% This function takes in a value for e in the
% van der Pol oscillator expression,
% x”+e(x^21)x’+x=0, where primes denote
% di¤erentiation in time. The function
% will automatically assume x(0)=1, x’(0)=0
% and a thirtysecond time interval (tspan=[0 30])
% if these values are not provided. Also, a
% value of e=0.5 is assumed if none is given.
global e_g
if nargin<1 e=0.5; end % An “if” statement on a single line.
if nargin<2 x0=[1 0]; end
if nargin<3 tspan=[0 30]; end
e_g=e;
%
% O¤ to the ode solver.
%
[t,x]=ode45(’dxvdp’,tspan,x0);
function dx=dxvdp(t,x);
global e_g
% Program 2: dxvdp.m
% This is the function called on by ode45 to provide the
% derivative of our state vector x. We need to set up the
% secondorder di¤erential equation as a system of two
% …rstorder equations. Our state vector x consists of
% the variable x and its time derivative.
%
dx(1,1)=x(2);
dx(2,1)=(e_g*(x(1)^21)*x(2)+x(1));
phase space.
137
0 5 10 15 20 25 30
2.5
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
D
i
s
p
l
a
c
e
m
e
n
t
Time
Figure 17.1: Displacement vs. time curve for the van der Pol oscillator under
the default conditions of Program 1.
138 CHAPTER 17 MODELING A VAN DER POL OSCILLATOR
2.5 2 1.5 1 0.5 0 0.5 1 1.5 2 2.5
2.5
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
V
e
l
o
c
i
t
y
Displacement
Figure 17.2: Phase diagram for the van der Pol equation. Note the closed limit
cycle.
139
3 2 1 0 1 2 3 4
3
2
1
0
1
2
3
4
5
6
V
e
l
o
c
i
t
y
Displacement
Figure 17.3: Phase portrait of the same van der Pol oscillator with di¤erent
initial conditions.
Chapter 18
Random Vibration and
Matlab
The focus in the text is probabilistic modeling of forces in vibrating systems.
Our aim here is to show how Matlab can be used as an aid in modeling random
processes, and thus in visualizing the response of systems subjected to random
forcing.
1
The logical starting point for this e¤ort is to show how we can create
random forcing histories to apply to a deterministic model. Unlike the problems
posed in the text, we will not be looking for the response statistics at this time;
instead, we will arrive at sample response realizations, which we will later use to
arrive at the response statistics numerically, contrasting the analytic approach
taken in the chapter.
To illustrate some of the challenges associated with a random forcing input,
let us look at a sinusoidal forcing input of the form 1 (t) = ¹cos (.t) . We …rst
need to determine how we will introduce randomness to this system. That is,
will we apply a random force amplitude, a random frequency, or both? If we are
modeling a given physical system, we will …nd that this question often answers
itself. For example, we may have derived the power spectral density of a typical
input to our system, and found that the vast majority of the energy input to
the system comes at one particular frequency. For this case, we could then (as
a …rst approximation) treat the forcing frequency as deterministic, and use a
random distribution for the amplitude.
2
Having determined the parameter we will consider to be random, we need to
arrive at a probability density function for our this parameter. That is, will we
use a uniform distribution, a Gaussian distribution, or some other description?
Before we decide this, let us have a look at the distributions available inside
Matlab.
1
Following the example of the textbook, we will limit ourselves mainly to random forcing
of deterministic systems.
2
In general, we would also have a random phase angle associated with this forcing. We
omit the phase angle here for simplicity of analysis.
141
142 CHAPTER 18 RANDOM VIBRATION AND MATLAB
The uniform and Gaussian distributions are built into Matlab through the
rand and randn commands, respectively.
3
Typing a=rand(n) at the Matlab
prompt will return an : : array of randomlygenerated numbers in a. using
a uniform distribution on the interval [0.0,1.0]. The randn command returns
a random number from a Gaussian distribution having a mean of zero and
standard deviation of one. Note that Matlab’s random numbers are actually
“pseudorandom”; that is, they depend on an initial state vector. For some
applications, we will want to compare the results of several di¤erent systems to
a random loading. For instances like this, we can use the state of the random
number generator to subject each comparison case to the same realization of the
random loading process. If we want to ensure that we get a di¤erent realization
each time, we can use the suggestion available in the Matlab help for rand,
and initialize the state to sum(100*clock). This will reset the random number
generator based on the current time.
4
Both methods are useful for di¤erent
cases. Any other probability distributions would have to be derived from the
two described above or created from scratch by the user.
Following the lead of Section 4.8, let us look at the system described by
• r + 2c.
n
_ r + .
2
n
r = 1 (t) (18.1)
where we will take 1 (t) to be the sinusoid above having random amplitude
¹(t) . It will be convenient for us to apply the condition of ergodicity to this
system. Thus, we will solve for the steadystate response only, neglecting the
transient response. (This also eliminates the need to specify initial conditions.)
We can solve for the steadystate response in two ways using Matlab. We can
use the results of the analysis we did earlier, giving an analytic solution, or we
can use the numerical integration routines. We’ll do the latter in this case, to
show how we can transport the amplitude values back and forth where they are
needed, and to show how we can handle the discrete datapoint set.
Again, we use the nargin function to allow any number of input parameters
from zero to the maximum of …ve. Recall from the last example that we used less
than statements instead of a switch expression to de…ne parameters. This is
because expression cases of a switch in Matlab do not require a break statement
to end each expression set, unlike the C analogue. Thus, we cannot allow cases
for lower numbers of input arguments to “fall through” to higher numbers, like
we could in C. We also set the length of the amplitude vector ¹ to be the
same as the length of the t:ja: vector, or 1000 elements if the input t:ja: is
shorter. We do this to make interpolation of ¹ based on values of t simpler.
When Matlab integrates our di¤erential equation, the values of t that it will test
are not necessarily the same as the values in t:ja:. Thus, we will interpolate
linearly between neighboring values of ¹ corresponding to the two elements
3
There also exist three other commands, two of which produce sparse matrices, while the
third gives a vector with a random permutation of the …rst n integers. These are not useful
to us here.
4
Speci…cally, the clock command returns a sixelement vector, containing the current year,
month, day, hour, minute, and second.
143
of t:ja: that surround the current time value t.
5
In order to ensure that the
amplitude is always greater than zero, we multiply each element of ¹ by its
sign. This leads to a distribution that is not rigorously Gaussian. We could
improve our odds of not getting negative values for ¹ by changing the standard
deviation such that 3o in each direction is positive. The coding for this is left
to the reader. The error expression in the default (otherwise) case of our
switch expression will print the message in quotes to the screen, informing the
user of the function that the allowed values of the ‡ag are zero and one.
We are confronted with one more problem if we wish to use the di¤erential
equation solver. That is, how do we remove the transient response? It is not as
simple as setting the initial conditions to zero, of course, since the position and
velocity imparted by the forcing function at time zero are not necessarily zero.
What we must do is solve the di¤erential equation at time t = t
0
. and then
substitute into the relation the values of the forcing and the forced response at
that time, to solve for the initial position and velocity required to match the
forced response. Recall our earlier analysis, showing that r(t) = r
µ
(t) +r

(t) .
where:
r

(t) = ¹

c
t.
sin(.
J
t + 0). (18.2)
and
r
µ
(t) = ¹
0
(t) cos(.t ÷c). (18.3)
where we found that the constants ¹
0
and c are:
¹
0
=
¹(t)
(.
2
n
÷.
2
) + (2c.
n
.)
2
. c = tan
1
2c.
n
.
.
2
n
÷.
2
. (18.4)
We need to specify the initial conditions r(t
0
) and _ r(t
0
) so that we can have
¹

= 0. eliminating the transient response r

(t) . This is as straightforward as
specifying r(t
0
) = r
µ
(t
0
) and _ r(t
0
) = _ r
µ
(t
0
) . or:
r(t
0
) = ¹
0
(t
0
) cos (.t
0
÷c)
_ r(t
0
) = ÷.¹
0
(t
0
) sin(.t
0
÷c) . (18.5)
This is easily coded into Matlab, using the initial value of the force amplitude
in the random array ¹. We neglect the time derivative of the randomlyvarying
amplitude ¹ as a …rst approximation. Figure 18.1 is the displacement versus
time curve for the oscillation. The oscillation remains periodic even with the
random forcing amplitude, albeit with an irregular amplitude. The force ampli
tude is shown in Figure 18.2. The plot only shows the …rst …ve seconds to give
a ‡avor for the variations in the force.
function [t,x,A]=randamp(tspan,wn,zeta,dist‡ag,omega);
% Program 1: randamp.m
% This program solves a single degree
5
This is a coarse approximation, to be sure, but has the bene…t of being simple to imple
ment. The reader is welcome to devise other re…nements.
144 CHAPTER 18 RANDOM VIBRATION AND MATLAB
% of freedom oscillator given an
% input of the form F(t)=Acos(omega*t+phi),
% where A is a random variable.
% dist‡ag should be zero for uniform,
% and 1 for Gaussian distribution.
%
global A_g tspan_g zeta_g wn_g omega_g phi_g % needed by the ode
de…nition.
if nargin<1 tspan=linspace(0,30,1000); end
if nargin<2 wn=1; end
if nargin<3 zeta=0.05; end
if nargin<4 dist‡ag=0; end
if nargin<5 omega=3.5; end
%
% Assigning global values.
%
tspan_g=tspan; zeta_g=zeta;
wn_g=wn; omega_g=omega; phi_g=0; % Zero phase angle.
% Since we’ve got to have an amplitude for each
% time step (ease of interpolation), we need to be speci…c
% about how many time steps we’ve been given. We’ll say that if
% tspan has fewer than 1000 elements, then we make
% it a 1000element vector.
m=max(size(tspan));
if m<1000
tspan=linspace(t(1),t(m),1000);
end
%
% Now, we de…ne the amplitude A, between 0 and 5 for
% the uniform distribution, and as a distribution with
% mean of 2.5 for the Gaussian. We will force A=0,
% so the Gaussian distribution will need a little
% bit of tweaking (and it won’t be rigorously Gaussian).
%
switch dist‡ag
case 0
A=5*rand(size(tspan)); % A now has a range from 0 to 5.
case 1
A=2.5+randn(size(tspan)); % One standard deviation will span [1.5,3.5].
A=A.*sign(A); % Multiplying A by the signum function of itself.
otherwise
error(’Distribution ‡ag must be zero or one.’);
end
%
% Next, we de…ne the initial conditions to remove transients.
%
145
phi=atan(2*zeta*omega*wn/(wn^2omega^2));
x0=A(1)*cos(omega*tspan(1)phi);
xd0=A(1)*omega*sin(omega*tspan(1)phi);
xv0=[x0,xd0];
%
% Storing A in the global value.
%
A_g=A;
%
% Now we’re ready to solve the ODE.
%
[t,x]=ode45(’randdx’,tspan,xv0);
function dx=randdx(t,x)
%
% Program 2: randdx.m
% Di¤erential equation de…nition for
% the randomlyvaried amplitude case.
%
global A_g tspan_g zeta_g wn_g omega_g phi_g % Need these for the
interpolation.
At=interp1(tspan_g,A_g,t); % Finding the correct value of A.
% interp1 is a builtin function.
%
dx(1,1)=x(2,1);
dx(2,1)=At*cos(omega*tphi)(2*zeta*wn*x(2,1)+wn^2*x(1,1));
146 CHAPTER 18 RANDOM VIBRATION AND MATLAB
0 5 10 15 20 25 30
1
0.5
0
0.5
1
1.5
Time, seconds
D
i
s
p
l
a
c
e
m
e
n
t
Figure 18.1: Displacement versus time plot for the random Du¢ng oscillator.
147
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Time, seconds
A
m
p
l
i
t
u
d
e
Figure 18.2: Amplitude versus time curve for …ve seconds, to show variations.
Chapter 19
RandomlyExcited Du¢ng
Oscillator
This example expands on some of the ideas of the previous, in that now we will
apply a random forcing input to a nonlinear oscillator. We could call upon the
van der Pol oscillator of a few examples ago, but instead we will introduce the
Du¢ng equation:
• r + c _ r + /r + o (r) = ¹cos .t (19.1)
where the parameters c and / are assumed to be positive, and [[ < 1. Note that
 is not restricted to solely positive nor negative values. This equation allows
us to choose the parameter  and the function o (r) to model nearlylinear
springs, for example. Also, this equation retains some attractive quasilinear
qualities. Speci…cally, if we set ¹ = 0 and c = 0. we would expect roughly
oscillatory motion for small amplitudes r. and that if we further introduce a
small damping coe¢cient c. these smallamplitude oscillations would reduce to
zero. If we assume a function o (r) such that sgn(o (r)) = sgn(r), then the
sign of the parameter  determines the character of the sti¤ness element being
modeled.
1
If  < 0. then we see that the restoring force will be smaller in
extension, and arrive at a soft spring. Conversely, if we take  0. the spring
gains sti¤ness in extension over the purely linear case, and is called a hard
spring.
Of course, we are not limited to the class of functions o (r) described above.
For example, if we choose the parameter  0 and select o (r) = ÷r
2
. we then
get a net restoring force /r + o (r) that is negative for r < 0 and positive
for r 0. In other words, the spring will be soft in extension but hard in
compression, meaning that the center of oscillation (equilibrium point) will be
shifted slightly away from zero, where the magnitude of the shift depends on
the relative values of / and .
1
Recall from an earlier example that sgn(x) is the signum function, which returns 1 if x
is negative, 1 if x is positive, and 0 if x is zero.
149
150CHAPTER19 RANDOMLYEXCITED DUFFINGOSCILLATOR
Let us use the Du¢ng oscillator as a model for response to a harmonic input.
Programs 1 and 2 below use the di¤erential equation solver suite inside Matlab
to calculate a numerical solution to a Du¢ng equation, given the input values
of c. /. . ¹. and .. The function uses o (r) = ÷r
2
; this can be readily changed
by editing the di¤erential equation de…nition function (Program 2). Also, the
time span and initial conditions are …xed inside the code, to keep the number
of inputs manageable. Program 1 can be quickly edited to take a di¤erent time
increment or initial conditions, or to take them as function inputs. Figure shows
the results of the hardcoded default case.
Having arrived at a solution for the Du¢ng equation, our next step is to
introduce a random forcing function. Unlike the previous example (and in
preparation for the next) we will select a random forcing frequency and am
plitude, which will remain constant for the duration of the oscillation. If we
design this function properly, we will not need to write a new program to pro
vide the di¤erential equation; we will send the same set of global variables. This
implementation is given in Program 3 below. Again, we leave the time interval
and initial conditions de…ned within the function. (The reader is encouraged to
rewrite the function to take the time increment, initial conditions, or both as
inputs, providing default values via nargin.) We use the uniform distribution
generator inside Matlab to provide a forcing amplitude between zero and 5, and
a forcing frequency between zero and 2¬. Note that the function returns four
arrays: the time vector t, the state vector r. the random amplitude ¹. and
the random frequency n. This is for ease of comparison between runs, and also
makes for a useful check on our random solution. Knowing the values of ¹ and
n used by the code, we can run our deterministic solver (Program 1) using the
default values for c. c and /. and the random values for ¹ and n. The results
for a few default runs are plotted below, along with the random frequency and
amplitude used. Of special note is the third run in Figure 19.3. It happened
that we got lucky (or unlucky, depending on the point of view) on this run, and
got a random forcing frequency very close to the system’s natural frequency
of one. Hence, we see a nearlyresonant condition in this undamped oscillator.
The phase diagram in Figure 19.4 corresponds to this run. The response traces
out arcs in the phase plane that are circular, but by no means closed. Exam
ining the plot point by point shows that the oscillation travels back and forth
through the phase plane, meaning that the mean point of the oscillation does
not move one way or the other; it is stationary at zero. The interested reader
is encouraged to look at this behavior for himself. A simple way to accomplish
this is to run the Du¢ng oscillator function with the given parameters, and then
type the following at the Matlab prompt:
for i=1:max(size(x))
plot(x(i,1),x(i,2),’o’)
hold on
pause
end
Matlab will execute this loop as if it was inside a function or script, and you
151
will be able to track the movement in the phase plane.
2
function [t,x]=simpdu¤(e,c,k,A,w)
% Program 1: simpdu¤.m
% Function to set up and implement the ode45
% solution of a Du¢ng oscillator. The
% time increment is hardcoded to be
% [0,30], and the initial conditions
% set to [0,0].
%
global c_g k_g e_g A_g w_g % Will be used in ode solution.
tspan=[0 30];
xinit=[0 0]’;
% The customary nargin check.
if nargin<1 e=0.01; end
if nargin<2 c=0.05; end
if nargin<3 k=1; end
if nargin<4 A=3; end
if nargin<5 w=2.7; end % w chosen to prevent resonance.
[t,x]=ode45(’du¤dx’,tspan,xinit);
function dx=du¤dx(t,x)
% Program 2: du¤dx.m
% Function to return the updated state
% vector for a Du¢ng oscillator.
%
global c_g k_g e_g A_g w_g
g=x(1,1)^2; % Explicitly stating g(x).
dx(1,1)=x(2,1);
dx(2,1)=A_g*cos(w_g*t)(c_g*x(2,1)+k_g*x(1,1)+e_g*g);
% Since we stated g(x) above, the equation for x”
% looks like the Du¢ng equation. Also, we need
% only change that one line of code above to use
% a di¤erent function g(x).
function [t,x,A,w]=randdu¤(e,c,k)
%
% Program 3: randdu¤.m
% This function provides random force amplitude
% and frequency to a Du¢ng oscillator. Both values
% are taken from a uniform distribution.
%
global e_g c_g k_g A_g w_g % Tagging these with “_g” for consistency.
tspan=[0 30];
xinit=[0 0]’;
if nargin<1 e=0.01; end
if nargin<2 c=0.05; end
2
You may also have to sit through many pauses; the x array we computed was 2by457.
152CHAPTER19 RANDOMLYEXCITED DUFFINGOSCILLATOR
if nargin<3 k=1; end
rand(’state’,sum(clock*100)); % Resetting random generator state.
A=5*rand(1);
w=2*pi*rand(1);
e_g=e; c_g=c; k_g=k; A_g=A; w_g=w;
[t,x]=ode45(’du¤dx’,tspan,xinit);
153
0 5 10 15 20 25 30
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
Time, seconds
A
m
p
l
i
t
u
d
e
Figure 19.1: Response of the randomlyexcited Du¢ng oscillator with . =
3.7960 and ¹ = 3.7999.
154CHAPTER19 RANDOMLYEXCITED DUFFINGOSCILLATOR
0 5 10 15 20 25 30
4
3
2
1
0
1
2
3
4
Time, seconds
A
m
p
l
i
t
u
d
e
Figure 19.2: Response of the Du¢ng oscillator to amplitude ¹ = 4.4531 and
forcing frequency . = 1.7404.
155
0 5 10 15 20 25 30
15
10
5
0
5
10
Time, seconds
A
m
p
l
i
t
u
d
e
Figure 19.3: Response to ¹ = 1.0062 and . = 1.0115.
156CHAPTER19 RANDOMLYEXCITED DUFFINGOSCILLATOR
1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8
2.5
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
Figure 19.4: Phase plot for the nearlyresonant case above.
Chapter 20
Monte Carlo Simulation of
a Random System
In the previous example, we looked at a system under random excitation, where
we modeled the amplitude of a harmonic input force as a timevarying ran
dom process, using a normal or uniform distribution. Consider now a related
problem, where we again have a harmonicallyexcited single degree of freedom
oscillating system, where the excitation is of the form:
1 (t) = ¹cos (.t) . (20.1)
where the parameters ¹ and . are random variables. As with the previous
analysis, we assume that the forcing will be applied in a certain range, that is:
¹
1
_ ¹ _ ¹
2
.
.
1
_ . _ .
2
(20.2)
where ¹
1,
¹
2,
.
1
. .
2
are known constants. One approach would be to model the
results with ¹ and . at mean values, which could form a good basis to estimate
the behavior of a linear system. However, let us address the more interesting
(and di¢cult) problem of estimating the behavior of a nonlinear system, such as
the Du¢ng oscillator from the previous example. There is no longer a guarantee
that the mean values for the inputs will correspond to the mean values of the
response, so we need an alternate method to arrive at some response statistics.
1
To approximate the statistics of our nonlinear system, we choose to em
ploy the Monte Carlo methodology, developed systematically by Metropolis and
Ulam (1949). In general, the Monte Carlo method has two forms: the proba
bilistic form, where actual random variable distributions are available, and the
1
In addition to the numerical approach presented here, one can apply perturbation theory
to a nonlinear system to estimate the response. For more, see Nonlinear Ordinary Di¤erential
Equations, by D.W. Jordan and P. Smith (Oxford University Press), or A First Look at
Perturbation Theory, by J. G. Simmonds and J. E. Mann, Jr. (Dover Books).
157
158CHAPTER20 MONTE CARLO SIMULATIONOF ARANDOMSYSTEM
deterministic form, where such distributions are unknown. Here, we follow a
deterministic algorithm, though adaptation of the method as described here to
its probabilistic form is a matter of substituting the known random distributions
for the ones we will presume here.
The method in both of its forms can be broken down into three steps:
1. Simulation of the random variable(s);
2. Solution of the deterministic problem for a large number of random vari
able realizations;
3. Statistical analysis of results.
We have already performed most of the work for the …rst step above. Since
we have ranges over which we presume the random variables ¹ and . will vary,
we can describe both as uniformlydistributed between their extreme values. We
could also use a Gaussian distribution, using for the mean the midpoint of the
given ranges. Our standard deviation would then be selected so the endpoint
values given correspond to three standard deviations from the mean value in
either direction. In this way, about 99.7% of the randomlygenerated values
would fall between the prescribed extreme values. We will demonstrate the pro
cedure for uniformlydistributed variables, and leave the Gaussian distribution
as an exercise for the reader.
In order to solve the deterministic problem, we will use the di¤erential equa
tions de…nition function we presented in the previous example. What we need
to create is a separate driver for this function, a code that will run several real
izations and return our desired quantities. Of course, this means that we need
to determine which output quantities interest us. For the purpose of demonstra
tion, we will track the maximum displacement and maximum velocity for each
realization. If it was necessary, we could retain the entire history of oscillation
for each realization, but a simple demonstration will capture the spirit of the
Monte Carlo methodology. The reader is encouraged to modify the given code
to add whatever complication he wishes.
2
We will only arrive at useful statistics for our system if we can apply the
conditions of ergodicity to the system. Thus, we will again de…ne the system
initial conditions so that the transients are removed, like we did with our …rst
example of a random forcing input. These values can either be computed as
needed, right before sending to the ODE solver, or they can be computed in
advance. We choose the former for our demonstration. (The reader may be
wondering if this calculation can be vectorized. It can; the programming is left
as an exercise.) Also, with the manner in which we have chosen to specify global
variables, we can set the value of the global amplitude and frequency right before
calling for the ODE solution. We specify the random variables as row vectors
(arbitrarily) and we force them to lie on the desired domains. Then, we set up
2
A word of warning, however: Reduce the value of the damping coe¢cient c at your own
risk. Our initial value for this parameter was 0.05, and the integrator did not complete any
attempted run of the code at that value of c:
159
a for loop to run the ODE solver the speci…ed number of times, solving for the
appropriate initial displacement and velocity for each. After the ode solution is
found, the maximum displacement and velocity is found and stored, as are the
input amplitude and frequency, and the time span used. We may then perform
whatever statistical analyses we wish on this data.
The four histograms below show the variations in several parameters for a set
of 100 random realizations of the Du¢ng oscillator. Figure 20.1 is the histogram
of force amplitudes, and Figure 20.2 is the set of forcing frequencies. Since we
chose uniform distributions for both of these quantities, we expect the number
of values in each range to be about the same. This is the case; the di¤erence
between the most and least common force amplitude range is eight occurrences,
and the di¤erence between the most and least common frequency range is ten
occurrences. For a larger sample size, we would expect these numbers to reduce
on a percentage basis.
3
Our results, however, are not uniformly distributed. Figure 20.3 shows the
variation of maximum displacement values. The vast majority (65%) had max
imum displacement under 10. The shape of the distribution is akin to a one
sided Gaussian distribution, implying that our normallydistributed inputs led
to Gaussian output. Figure 20.4 also shows a onesided Gaussian distribution,
with 85% of the resulting maximum velocities falling under 10. One can readily
see how this information could be applied to a design procedure; if we wanted
to have 90% certainty of a displacement less than 10, we would see that the
default system is inadequate.
It is also possible to do more complicated analyses involving other aspects
of the data. The reader is invited to rewrite the routine to return all of the
displacement and velocity histories (hint: threedimensional matrices will be
helpful). Also, if we had a nonlinear model for, say, a vibrating beam, we could
use the displacement and velocity information to derive the maximum stress at
some point in the beam for each run. The possible applications of this analysis
are limited only by the systems we wish to apply it to.
function [xout,xdout,Aout,wout]=montdu¤(nruns,e,tspan)
%
% Program 1: montdu¤.m
% This code performs a Monte Carlo simulation of the
% Du¢ng oscillator. The random parameters are the
% forcing amplitude and frequency, presumed to be
% described by uniform distributions. Also, the
% sti¤ness is presumed to be one and the damping
% presumed to be 0.1. These values can be changed
% by editing the code.
%
global c_g k_g A_g w_g e_g % For compatibility with the existing du¤dx.m.
3
A test performed with 1,000 simulations showed that the di¤erence in amplitude oc
curences was 30 of 1000 between most and least common, or 3%. The di¤erence in number
of occurences for the most and least common frequency was also around 30 out of 1000.
160CHAPTER20 MONTE CARLO SIMULATIONOF ARANDOMSYSTEM
% Parameter check.
%
if nargin<1 nruns=50; end
if nargin<2 e=0.01; end
if nargin<3 tspan=[0 30]; end
%
% Sti¤ness and damping coe¢cient.
%
c_g=0.1; k_g=1; e_g=e;
wlo=0; whi=2*pi; % Extreme values for the frequency.
Alo=0.1; Ahi=10; % Extreme values for the amplitude.
A=Alo+(AhiAlo)*rand(1,nruns);
w=wlo+(whiwlo)*rand(1,nruns);
%
% Initializing the t and x vectors. This is why we want
% to specify the length of the time vector.
%
xout=zeros(1,nruns);
xdout=zeros(1,nruns);
for i=1:nruns
A_g=A(1,i); w_g=w(1,i); % Set global parameters.
x0=A_g*cos(w_g*tspan(1));
xd0=A_g*w_g*sin(w_g*tspan(1)); % Choose initial conditions to remove
transient.
xinit=[x0, xd0];
[trecv,xrecv]=ode45(’du¤dx’,tspan,xinit); % The run.
xout(1,i)=max(xrecv(:,1)); % Here we could perform a more complex analy
sis
xdout(1,i)=max(xrecv(:,2)); % of our data.
end
wout=w;
Aout=A;
161
0 1 2 3 4 5 6 7 8 9 10
0
2
4
6
8
10
12
14
16
Force Amplitudes
N
u
m
b
e
r
o
f
O
c
c
u
r
e
n
c
e
s
Figure 20.1: Histogram showing the force magnitudes among the 100 random
runs.
162CHAPTER20 MONTE CARLO SIMULATIONOF ARANDOMSYSTEM
0 1 2 3 4 5 6 7
0
5
10
15
Frequencies
N
u
m
b
e
r
o
f
O
c
c
u
r
e
n
c
e
s
Figure 20.2: Histogram showing the various frequencies applied to the Du¢ng
oscillator.
163
0 10 20 30 40 50 60 70 80
0
10
20
30
40
50
60
70
Maximum Displacement
N
u
m
b
e
r
o
f
O
c
c
u
r
e
n
c
e
s
Figure 20.3: Histogram of maximum displacement values.
164CHAPTER20 MONTE CARLO SIMULATIONOF ARANDOMSYSTEM
0 10 20 30 40 50 60
0
5
10
15
20
25
30
35
40
45
Maximum Velocity
N
u
m
b
e
r
o
f
O
c
c
u
r
e
n
c
e
s
Figure 20.4: Histogram showing maximum velocities of the simulated responses.
Chapter 21
Conclusion
This primer on MATLAB as applied to vibration problems, simple and not so
simple, can be an valuable tool to the student and the practitioner. The basic
elements are here to study a variety of vibration problems and to “play” with
the equations and the parameters. You will …nd it interesting and fun doing
this. Best of luck.
165
Contents
Preface 1 Introduction 2 SDOF Undamped Oscillation 3 A Damped SDOF System 4 Overdamped SDOF Oscillation 5 Harmonic Excitation of Undamped SDOF Systems 6 Harmonic Forcing of Damped SDOF Systems 7 Base Excitation of SDOF Systems 8 SDOF Systems with a Rotating Unbalance 9 Impulse Response of SDOF Systems 10 Step Response of a SDOF System 11 Response of SDOF Systems to Square Pulse Inputs 12 Response of SDOF System to Ramp Input 13 SDOF Response to Arbitrary Periodic Input 14 Free Vibration of MDOF Systems 15 Damping of MDOF Systems 16 A Universal Vibration Solver 17 Modeling a van der Pol Oscillator 18 Random Vibration and Matlab v ix 1 3 11 17 23 33 39 51 61 67 77 89 95 101 113 123 133 141
vi 19 RandomlyExcited Du¢ ng Oscillator 20 Monte Carlo Simulation of a Random System 21 Conclusion
CONTENTS 149 157 165
CRC Press 2010.Preface This document is companion to the text: Mechanical Vibration: Analysis. mark.edu. Uncertainties and Control.edu ix . contact: benaroya@rci.rutgers.nagurka@marquette. by Haym Benaroya and Mark Nagurka.
.
2) b (Note that the apostrophe is the transpose operator in Matlab. Matlab (Matrix Laboratory) was born from the LINPACK routines written for use with C and Fortran. produced by the MathWorks. Matlab provides “array multiplication” for such an instance: e = a: b 1 (1. Uncertainties. if we set the variable a = [1 2 3] and b = [4 5 6]. whose rows would be scalar multiples of b: However. Thus. not scalar multiplication.) The result c would be a scalar (speci…cally.Chapter 1 Introduction This document is intended as a companion to Mechanical Vibration: Analysis. calling on the multiplication operator alone causes Matlab to attempt matrix. what if the values stored in a are three masses. Matlab is excellent for handling matrix quantities because it assumes every variable is an array. we can perform the matrix multiplications: c = a b0 d = a 0 (1. rather. and Control by Haym Benaroya and Mark Nagurka. and so on for the second and third elements. Inc. For example. Also. we wish to show how a vizualization tool like Matlab can be used to aid in solution of vibration problems. We do not intend to teach Matlab in this work.3) . Matlab includes special “array operators” that allow multiplication of arrays on an elementbyelement basis. or to run complicated codes by calling a function name. we would need to multiply the …rst element of a by the …rst element of b. allowing the user to test simple statements at the command prompt.1) (1. and those in b their corresponding accelerations? If we wished to …nd the force on each mass. The Matlab package provides both commandline and programming language interfaces. This companion draws heavily upon the Matlab software package. and hopefully to provide both the novice and the experienced Matlab programmer a few new tricks with which to attack their problems of interest. 32): The variable d would contain a 3by3 matrix.
Additionally. with comments explaining what was done. Matlab’ language shares s several common structures with both of these languages. :::varN ). a function must begin with the line function output = f unction_name(var1. and instead create e by multiplying the corresponding elements of a and b: The result here would be e = [4 10 18]: This is one of the more useful specialized commands in Matlab. One distinction to make with Matlab programming is between script m…les and function m…les. Several …gures follow each example. the form should look familiar to Fortran and C programmers. and one we will use frequently. why it was done. Finally. with reference to the text where applicable. showing results of each vibration problem under di¤erent sets of parameters and making use of Matlab’ integrated graphics s capabilities. and other ways it could have been done in Matlab. var2. The vast majority of these examples will use Matlab in its programming mode.) . Variables within a function m…le cannot be used outside of the function unless they are returned (much like C functions or Fortran subroutines). The general format is to introduce a problem. This line tells the Matlab interpreter that this …le is a function separate from the workspace. (Again. Other commands will be discussed as they arise.2 CHAPTER 1 INTRODUCTION Take special note of the period between a and the asterisk. This tells Matlab to ignore its usual matrix multiplication rules. The di¤erences are that variables used in a script …le are retained in the Matlab workspace and can be called upon after the script completes. The code should look somewhat familiar to those who have used C and Fortran in the past. making it relatively easy for an experienced C or Fortran programmer to learn Matlab. the Matlab code used to generate the …gures is presented. Both are sets of commands that are saved in a …le. and to show the analytic solution (if derivable).
1.3) From this. it’ assumed zero forp s this analysis. A freebody analysis of this system in the framework of Newton’ s second law.2) x(t) = p ! 2 x2 + x2 _o n o cos(! n t !n tan 1 xo _ ): ! n xo (2. or. we would have the forcing function F (t) on the righthand side. A sample of such a system is shown in Figure 2.1) (In general. initial velocity. we obtain a solution of the form x(t) = A sin(! n t + ).Chapter 2 SDOF Undamped Oscillation The simplest form of vibration that we can study is the single degree of freedom system without damping or external forcing. results in the following equation of motion: mx + kx = 0: :: (2. _ 3 . and introducing the parameter ! n = k=m. we see that the complete response of an undamped. unforced.) Dividing through by m. and initial displacement. respectively. as performed in Chapter 2 of the textbook. one degree of freedom oscillator depends on three physical parameters: ! n . xo . we have (2. and xo : the natural frequency. in terms of the physical parameters of the system.
the phase shift diminishes. will cause a variation in the frequency of vibration. If the variable matf lag is set to zero. the maximum amplitude increases with increasing sti¤ness. then. Figure 2.3. The MATLAB code used to produce the graphs follows. so user prompts are easily added and explained. The graphs on the following pages demonstrate these sensitivities. Variation of mass or sti¤ness.4 CHAPTER 2 SDOF UNDAMPED OSCILLATION Figure 2. For both Figures 2. or 0 . the parameter A (from Equation 2. then the masses are each given scalar values. referring to Figure 2. The portion of the statement inside the quotation marks will appear on the screen when the program is run.3. o In Figure 2.2 and 2. Note that the _ frequency decreases with increasing mass. above) reduces to xo . as expected. it is evident that the phase angle and maximum amplitude are also functions of the natural frequency. then the masses are initialized ag as part of an array. It is easily veri…ed that. due to the corresponding reduction in natural frequency. The phase angle also increases with the sti¤ness. Note that the maximum displacement would occur at t = 0 if the initial velocity were zero. The input statements in the …rst few lines demonstrate one type of interactive programming available in MATLAB. the initial velocity used was xo = 1.3 shows how the oscillatory behavior changes for increasing sti¤ness with mass constant. and the initial displacement x0 = 3. we p that it is inversely prosee portional to m. This is done to demonstrate the use of MATLAB array . From the p de…nition of the natural frequency. If this ‡ is set to one. Looking at Equation 2.2. As a result. Again. but increases with increasing sti¤ness. The initialization and use of the mass matrix is demonstrated in two ways. so the maximum amplitude of oscillation occurs at an increasingly later time with increasing sti¤ness. with the peak of oscillation becoming nearer to t = 0. and the phase angle becomes tan 1 (0=x2 ). and is directly proportional to k.2 shows the variation of the vibrational characteristics for an increasing mass while sti¤ness remains constant.2.3. for this case.1: Typical single degree of freedom free oscillator. due to the increase in natural frequency. Figure 2. the maximum amplitude decreases with increasing mass.
Finally. We also demonstrate MATLAB’ plotting routines via the s subplot command. placing a semicolon at the end of a line suppresses this output. allowing plots for all three masses to be placed on the same axes. MATLAB prints the results of each operation to the screen. (The reader is invited to remove all the semicolons from the program to see the di¤erence!) This feature is also a very useful debugging tool..then structure in MATLAB is similar to that of Fortran in that these statements must be closed with an end statement. suppressing screen output of intermediate results increases computational speed. for example). The second …gure below was produced by modifying the code below to take three sti¤nesses and one mass. . Since printing to screen takes time and memory for MATLAB to perform.5 variables and to show how they can help streamline your code. as must any other loop (for or do. The modi…cations necessary are left as an exercise for the reader. However. the programmer can insert and delete semicolons. By default. Note also that the if. those unfamiliar with MATLAB are probably wondering what all the semicolons are after each line. Instead of inserting and removing print statements to check intermediate calculations.
]. if (mat‡ ag) for i=1:3 m(i)=input([’ Enter mass value ’ num2str(i). % Set to 1 to activate mass array. saves a lot of “if” statements. m2=input(’ Enter the second mass value. tf=input(’ Enter the time duration to test. This % is more streamline by making a mass matrix [ m(1) instead % of m1. end else m1=input(’ Enter the …rst mass value. ’ ). akin to the array % multiplication described above. % More about the ’ num2str’command below. As written. in seconds. k=input(’ Enter the sti¤ness value. m3=input(’ Enter the third mass value. parameters % can be changed by rerunning the program. etc. Note that the natural frequency is stored % in a matrix. % if (mat‡ ag) wn=sqrt(k.6 CHAPTER 2 SDOF UNDAMPED OSCILLATION Program 11: varym. as shown. ’ ). case 2 m=m2. case 3 m=m3. v0=input(’ Enter the initial velocity./m). .’ ’ . % mat‡ ag=0. ]). % % Array division. ’ ). . ’ ). % This could also be done by using assignment statements in % the program. This one line produces a three% element array of natural frequencies. zero for mass scalars. ’ ). case 1 m=m1. ’ ). x0=input(’ Enter the initial displacement. Compare to % the machinations below. % else for i=1:3 switch i % Analogous to the C command. ’ ). but then the program would need to be % edited to change the parameters.m % The …rst few lines obtain the desired parameter values. end % % This loop initializes the natural frequency values.
end end % % Now. phi=atan2(v0. . the subplot statement must % also be.num2str(m2). end % % Since this program was made to compare di¤erent % parameters. for j=1:3 a=sqrt(wn(j)^2*x0^2+v0^2)/wn(j). % t=0:tf/1000:tf.:)) % % This line demonstrates the use of the num2str command. ’ k=’ num2str(k)]) . x(j.1. else title([’ Response for m=’ . the loop).2) plot(t. % if (mat‡ ag) title([’ Response for m=’ .num2str(m1).:)) if (mat‡ ag) title([’ Response for m=’ . end ylabel(’ Response x’ ) grid subplot(3. .wn(j)*x0). % The caret is the power operator.x(1. a subplot format makes sense. Notice that. . . Note that the command doesn’ t % work unless the text intended as a title is enclosed in % brackets as well as parentheses.7 end wn(i)=sqrt(k/m). ’ k=’ num2str(k)]) . ’ k=’ num2str(k)]) .num2str(m(1)).num2str(m(2)). the values for A and phi in the expression % x(t)=Asin(wn*t + phi) are evaluated. % atan2 is the fourquadrant arctangent. in % order for the cosine function to evaluate properly in % MATLAB. ’ k=’ num2str(k)]) . the wn vector is used element by element % (thus. % This command allows the value of a variable to be used % in a title or other text.1. . % subplot(3. else title([’ Response for m=’ . If the number % of varied masses is changed.1) plot(t. % We need only initialize the time increment once.:)=a*cos(wn(j)*tphi).x(2.
:)) if (mat‡ ag) title([’ Response for m=’ . k=8 5 Response x 0 5 0 5 10 15 Response for m=4.8 CHAPTER 2 SDOF UNDAMPED OSCILLATION end ylabel(’ Response x’ ) grid subplot(3.x(3.num2str(m(3)). k=8 20 25 30 5 Response x 0 5 0 5 10 15 Time. end ylabel(’ Response x’ ) xlabel(’ Time. .num2str(m3).3) plot(t. . else title([’ Response for m=’ .1. .2: Responses for three di¤erent masses. ’ k=’ num2str(k)]) . ’ k=’ num2str(k)]) . k=8 20 25 30 5 Response x 0 5 0 5 10 15 Response for m=12. seconds’ ) grid Response for m=2. seconds 20 25 30 Figure 2.
. seconds 20 25 30 Figure 2.9 Response for m=5. k=2 5 Response x 0 5 0 5 10 15 Response for m=5. k=6 20 25 30 5 Response x 0 5 0 5 10 15 Response for m=5. k=13 20 25 30 5 Response x 0 5 0 5 10 15 Time.3: Responses for three di¤erent sti¤nesses.
.
Chapter 3
A Damped SDOF System
In the previous example, we examined the response of an undamped single degree of freedom oscillator subject to varied mass and sti¤ness parameters. Here we will do the same for a damped single degree of freedom system. Again, we begin with the equation of motion, given the system of Figure 3.1. A simple static analysis …nds that our equation is:
mx + cx + k x = 0:
::
:
(3.1)
If we divide through by m, we introduce the dimensionless parameters ! and :
x + 2 ! n x + ! 2 x = 0: n
::
:
(3.2)
In the above, ! n represents the undamped natural frequency, and is the viscous damping ratio. For the purposes of this example, we will assume the underdamped case ( < 1). The solution to this equation is:
x(t) = Ae
!n t
sin(! d t + ): p 1
(3.3)
2
In Equation 3.3, ! d is the damped natural frequency, equal to ! n
.
This equation is more useful if we write all of the terms as functions of parameters ! n and : 11
12
CHAPTER 3 A DAMPED SDOF SYSTEM
Figure 3.1: Typical damped single degree of freedom oscillator.
p 2 In this expression, the term ! n 1 has been substituted for ! d . While this equation admittedly looks intimidating, note that it only depends on four quantities: xo , vo , ! n , and . Note the similarity between the parameters identi…ed here and the ones relevant to the undamped case; the only di¤erence is the addition of the viscous damping coe¢ cient. So, we have already seen the e¤ects of changing all of the parameters except the damping coe¢ cient. Figure 3.2 gives the variation of the response with increasing viscous damping coe¢ cient for xo = 3; vo = 1; and ! n = 7. Note how quickly the response becomes virtually zero; this occurs within ten seconds, even for a damping coe¢ cient as small as 0.05! The MATLAB code used to generate the …gure follows. This code is, in many ways, similar to the code used earlier for the mass and sti¤ness parameter studies. However, since both the exponential term and the sine term in our solution (Equation 3.3) depend on time, they are both vector quantities. To multiply them properly, we must use the array multiplication operator, ’ . .*’ The code again makes use of input statements to initialize the parameters. This time, however, the damping ratios are entered in array form only. The algorithm chosen to produce the p plots works only for the underdamped case; 2 in the denominator of our response since we have the term ! d = ! n 1 equation, = 1 will cause division by zero, and > 1 will give an imaginary damped natural frequency. We employ some defensive programming to ensure
v u p u 2 u (vo + ! n xo ) + xo ! n 1 x(t) = u t p 2 2 !n 1 " q sin !n 1
2
2
2
e(
! n t)
t + tan
1
!# p 2 xo ! n 1 : vo + ! n x o
(3.4)
13 allowable values for the damping ratio are entered. Conveniently, this gives us a reason to introduce the while loop, analogous to the “do while”loop in Fortran. The code checks each value zeta(zi) to see if it lies between zero and one. If not, a somewhat abrupt reminder is sent to the screen, and the loop asks for a new entry. Otherwise, it continues to the next damping ratio value. The logical and relational operators in MATLAB are for the most part intuitive. Thus, if a>0 simply means “if a is greater than zero.” A full list can be found by typing help ops at the MATLAB prompt; we will explain the ones we use in comments.
x(j. end % %Solving for the response. % for i=1:3 wd(i)=wn*sqrt(1zeta(i)^2).:)) title([’ Response for zeta=’ . ’ ). . zeta(zi)=input([’ Enter damping coe¢ cient value ’ num2str(zi). ’ ]).m %Initial value entry.x(1. else the program gives a %multiplication error. x0=input(’ Enter the initial displacement. % t=0:tf/1000:tf. ’ ). while(zeta(zi)<0 j zeta(zi)>=1) % The pipe (j) means “or” . tf=input(’ Enter the time duration to test.v0+zeta(j)*wn*x0). end end end % %Now. % wn=input(’ Enter the natural frequency. Note the use of the array %multiplication command (.*sin(wd(j)*t+phi). phi=atan2(wd(j)*x0. v0=input(’ Enter the initial velocity. ’ ).num2str(zeta(1))]) ylabel(’ Response x’ ) . the program plots the results in a subplot format.14 CHAPTER 3 A DAMPED SDOF SYSTEM Program 21: varyzeta.1) plot(t.*) in the expression for x(t). for zi=1:3 zeta(zi)=12. for j=1:3 a=sqrt((wn*x0*zeta(j)+v0)^2+(x0*wd(j))^2)/wd(j). ’ ). %The while loop in the zeta initialization section prevents %certain values for zeta from being entered. end % %Now. % subplot(3.:)=a*exp(zeta(j)*wn*t). %This command is necessary. zeta(zi)=12. having ! n and . if (zeta(zi)>=1 j zeta(zi)<0) fprintf(’ Zeta must be between 0 and 1!’ ).’ . since such %values would crash the program. in seconds. the ! d values can be found.1.
x(2.1. ylabel(’ Response x’ ) grid subplot(3.15 grid subplot(3.:)) title([’ Response for zeta=’ num2str(zeta(3))]) .1.:)) title([’ Response for zeta=’ num2str(zeta(2))]) .3) plot(t.2) plot(t. seconds’ ) grid . ylabel(’ Response x’ ) xlabel(’ Time.x(3.
2: Responses for various zeta values.5 4 Response x 2 0 2 0 1 2 3 4 5 6 Time.2 4 Response x 2 0 2 0 1 2 3 4 5 6 7 8 9 10 Response for zeta=0.16 CHAPTER 3 A DAMPED SDOF SYSTEM Response for zeta=0. seconds 7 8 9 10 Figure 3.05 5 Response x 0 5 0 1 2 3 4 5 6 7 8 9 10 Response for zeta=0. .
substitute it appropriately into Equation 4. The equation of motion of a damped single degree of freedom oscillator is: x + 2 ! n x + ! 2 x = 0: n :: : (4. But what happens when this condition is not met? There are two cases to explore: > 1 (the overdamped case).2) Note that the quantity inside the radical is always greater than zero. and = 1 (the critically damped case). the solution of the equation of motion is p (a1 e!n t p x(t) = e !n t 2 1 + a2 e !n t 2 1 ): (4.3) If we again take our initial displacement as xo and initial velocity vo . and obtain the quadratic formula de…ning possible values for : q = !n !n 2 1: (4. < 1. the constants a1 . a2 become p + p p a1 = vo + ( 2 1)! n xo 1 2! n 2 . Therefore.1.4) 17 .1) Assume a solution of the form Ae t . a2 = vo + ( + 2! n 2 2 p 1)! n xo 1 : (4. First.Chapter 4 Overdamped SDOF Oscillation The previous example is valid only for the underdamped case. we need to see how these cases arise in order to understand what the results will be. since we have assumed > 1.
Note that if = 1. the modi…cations are left to the reader.5) where a1 = xo . and overdamped vibration could not be combined into a single code. especially when used with its otherwise case. This is the distinguishing characteristic of the critically damped case. there is no oscillation. and a2 = vo + ! n xo . Figure 4. The astute reader may ask why the codes for underdamped. xo = 3.18 CHAPTER 4 OVERDAMPED SDOF OSCILLATION Equation 4. For the plots in the …gure. Note also that the motion of the masses is.1. (Hint: You may …nd the switch command to be useful. while the others do not reach equilibrium until more than eight seconds. This is shown in Figure 4. purely exponential. (4. as expected. and o = 1. critically damped. Notice how the critically damped response returns to equilibrium faster than the others.) . only a decay of the response to equilibrium. The MATLAB code is again presented below.1 was generated for ! n = 7. From our knowledge of ordinary di¤erential equations. a singularity exists in the constants. Certainly they can be. the motion with critical damping is stopped after about two seconds. The resulting code should reject negative values for the damping ratio. we can …nd x(t) = (a1 + a2 t)e !n t . a second independent solution must be found.3 is a decaying exponential and the system will simply return to its initial position instead of oscillating about the equilibrium.
a2=v0+wn*x0. v0=input(’ Enter the initial velocity. tf=input(’ Enter the time duration to test. ’ ).:)) title([’ Response for zeta=’ . for zi=1:3 zeta(zi)=0. x(j. %since such values would crash the program.1. x(j.*exp(zeta(j)*wn*t). If a variable can be created that will serve several %purposes. % subplot(3.*exp(wn*t). zeta(zi)=0. end end %Now.5. ’ ). den=wn*(zeta(j)^21)^0.5)*wn*x0.:)=(a1+a2*t). the program plots the results in a subplot format.12. a2=a2n/(2*den).:)=(a1*exp(den*t)+a2*exp(den*t)). a2n=v0+(zeta(j)+(zeta(j)^21)^0. ’ ). a1=a1n/(2*den). % wn=input(’ Enter the natural frequency. (imagine typing the %expression for den three times and you’ understand).5)*wn*x0. in seconds. while(zeta(zi)<1) zeta(zi)=input(’ Enter a damping coe¢ cient value. ’ ).1) plot(t.19 Program 31: overdamp. if zeta(zi)<1 fprintf(’ Zeta must be greater than 1!’ ). end end end % %Solving for the response.m %Initial value entry.num2str(zeta(1))]) . for j=1:3 if zeta(j)>1 a1n=v0+(zeta(j)+(zeta(j)^21)^0. as well as the exponent %values.x(1. ’ ). Notice that the variable den is used %for the denominator of the constants. The while loop in the zeta initialization %section prevents illegal values for zeta from being entered. x0=input(’ Enter the initial displacement. elseif zeta(j)==1 a1=x0. ll % t=0:tf/1000:tf. it will save time and typing.12.
2) plot(t. seconds’ ) grid .:)) title([’ Response for zeta=’ num2str(zeta(2))]) .3) plot(t.x(3.:)) title([’ Response for zeta=’ num2str(zeta(3))]) .20 CHAPTER 4 OVERDAMPED SDOF OSCILLATION ylabel(’ Response x’ ) grid subplot(3.1.x(2. ylabel(’ Response x’ ) xlabel(’ Time. ylabel(’ Response x’ ) grid subplot(3.1.
1: Response of three overdamped systems. seconds 5 6 7 8 Figure 4.21 Response for zeta=7 4 Response x 2 0 0 1 2 3 4 5 6 7 8 Response for zeta=5 4 Response x 2 0 0 1 2 3 4 5 6 7 8 Response for zeta=1 4 Response x 2 0 0 1 2 3 4 Time. .
.
Chapter 5 Harmonic Excitation of Undamped SDOF Systems In the previous examples. n where fo = Fo =m. Now. their ratio !=! n: Figure 5. We know the solution for the response x(t) to be: :: (5. For the case with no damping. or more precisely.2) A1 = vo .3) The key parameters which de…ne the response are the natural and driving frequencies.1. (5. We begin with the simplest form of external forcing: the harmonic load. A 2 = xo !n fo !2 n !2 : (5.3 does 23 . we will examine the e¤ects of an external force on the system. Newton’ Second Law gives us the equation of s :: motion mx + kx = Fo cos !t. or x + ! 2 x = fo cos !t. The forcing function is assumed to be of the form F (t) = Fo cos !t. we examined the responses of single degree of freedom systems which were not subjected to an external force.1) x(t) = A1 sin ! n t + A2 cos ! n t + where fo !2 n !2 cos !t.2 shows the e¤ect of varying driving frequency ! for a given natural frequency. The system under consideration is shown in Figure 5. and Figure 5. where ! is the driving frequency.
This gives rise to two interesting phenomena: beats and resonance.5 shows resonant vibration. Note that two of the three constants in the expression for x(t) involve the di¤erence between the frequencies. xo = 0. Figure 5. The result is then a rapid oscillation with a slowly varying amplitude. ! = ! n . as shown in Figure 5.2 is not valid as a particular solution of the governing equation of motion. When the driving and natural frequencies are equal. The third term in Equation 5. vo = 0.24CHAPTER 5 HARMONIC EXCITATION OF UNDAMPED SDOF SYSTEMS Figure 5. In a real system. the amplitude of oscillation will increase without limit.4. Fo = 6: Making the initial conditions zero allows us to better see the e¤ects of varying frequencies.4) This term is the heart of the resonance problem. . Instead.1: Model of a single degree of freedom subject to an external force. the sti¤ness element has a certain yield point which will be met and exceeded by a resonant vibration. Beats occur when the natural frequency and the driving frequency are close but not equal. resonance is the result. the particular solution is xp (t) = fo t sin ! n t: 2! n (5. Note how the both the rapid oscillation and the slow change of the amplitude both vary along a sinusoid. the same for various natural frequencies ! n : In these calculations.
From a practical point of view. A simple (and natural) modi…cation to this program would be to change the number of plots in the subplot. introducing too many plots to the …gures would make the plot unreadable. This could be done by introducing an integer variable nplot and changing the loops to run from one to nplot instead of one to three.25 The MATLAB code below uses the subplot command more elegantly than we had in earlier examples. Also. though. . They can easily be changed back to user inputs. the subplots are done in a loop. Instead of typing out three separate sets of plotting commands. we’ changed the parameter values ve from dynamic inputs to static values. so care must be taken.
v0=0.1001). wdr(i)=wn. f0=6.num2str(wn)]) ylabel(’ Response x’ ) grid end xlabel(’ Time. end for k=1:3 % We could have used subplot this way all along. for i=1:3. A3=f0/(wn^2wdr(j)^2).1. the velocity is %1. wdr(i)=input(’ Enter the driving frequency. while wdr(i)==wn. The initial displacement is 3. The program takes %the necessary input values to solve Equation %5. % This is how we initialize our while loop.26CHAPTER 5 HARMONIC EXCITATION OF UNDAMPED SDOF SYSTEMS Program 41 .k) plot(t. x(j. A2=x0(f0/(wn^2wdr(j)^2)).’ . if wdr(i)==wn. the force magnitude per unit mass is 6. and plots.:)=A1*sin(wn*t)+A2*cos(wn*t)+A3*cos(wdr(j)*t). tf=10.x(k.1). wn=7. subplot(3.num2str(wdr(k)).3 for three di¤erent driving %frequencies. checks for resonance (since we don’ want to t %handle that problem yet). ’ ). wn=’ . x=zeros(3. fprintf(’ This will produce resonance!!’ ) end end end t=0:tf/1000:tf. and the %natural frequency is 7. % %This …le varies driving frequency of a single degree %of freedom undamped oscillator at a set natural %frequency.m %This program is very straightforward.varywdr.:)) title([’ Response for wdr=’ . for j=1:3 A1=v0/wn. seconds’ ) . x0=0. wdr=zeros(3.
wn(i)=wdr. f0=6.27 Program 42: varywn. the force magnitude per unit mass is 6. wn=zeros(3.:)) title([’ Response for wdr=’ . if wn(i)==wdr. ’ ). for j=1:3 A1=v0/wn(j). The initial displacement is 3. % %This …le varies natural frequency of a single degree %of freedom undamped oscillator at a set driving %frequency. seconds’ ) . except that %now the natural frequency is the variable. % Analagous to the initialization above. and the %driving frequency is 7.:)=A1*sin(wn(j)*t)+A2*cos(wn(j)*t)+A3*cos(wdr*t). A2=x0(f0/(wn(j)^2wdr^2)).num2str(wn(k))]) ylabel(’ Response x’ ) grid end xlabel(’ Time. while wn(i)==wdr.1.m. wdr=7. wn=’ .m %This program is similar in form to varywdr. x(j. v0=0.1001). for i=1:3. tf=10. A3=f0/(wn(j)^2wdr^2). fprintf(’ This will produce resonance!!’ ) end end end t=0:tf/1000:tf.’ .x(k. the velocity is %1.1).num2str(wdr). x=zeros(3.k) plot(t. end for k=1:3 subplot(3. wn(i)=input(’ Enter the natural frequency. x0=0.
%subject to harmonic forcing.x).m %The main feature of note for this code is the use of the %ifthenelse protocol in MATLAB to allow solutions other %than “Inf” for the resonant case. Again. x=A1*sin(wn*t)+A2*cos(wn*t)+A3*t. %This section chooses the proper response formula for %the given situation. wdr=input(’ Enter the driving frequency. and f0 to input %statements. end plot(t. the %initial velocity and displacement are zero. f0=6. x=A1*sin(wn*t)+A2*cos(wn*t)+A3*cos(wdr*t).*cos(wdr*t). wn=3. v0=0. A2=x0(f0/(wn^2wdr^2)). tf=120. A3=f0/(wn^2wdr^2). A2=x0. A3=f0/2*wn. this program would become a general solver %for the singledegree of freedom undamped oscillator. if wdr==wn A1=v0/wn.28CHAPTER 5 HARMONIC EXCITATION OF UNDAMPED SDOF SYSTEMS Program 43: beatres. else title(’ Example of Beat Phenomenon’ ). in order to better see the e¤ects. % %This program shows beats and resonance in undamped %systems. seconds’ ) ylabel(’ Response x’ ) grid . wn. if wdr==wn title(’ Example of Resonance Phenomenon’ ). ’ ). end xlabel(’ Time. t=0:tf/1000:tf. else A1=v0/wn. By changing the values %of the initial conditions. x0=0.
.29 Response for w=3. wn=7 7 8 9 10 Response x 0 0. wn=7 7 8 9 10 Response x 0 0.01 0 1 2 3 4 5 6 Response for w=42.02 0.01 0 1 2 3 4 5 6 Time.5 Response x 0 0.2: Vibration response for di¤erent driving frequencies. seconds 7 8 9 10 Figure 5.02 0 1 2 3 4 5 6 Response for w=27. wn=7 0.5 0.
3: Vibration response for di¤erent natural frequencies.5 0 1 2 3 4 5 6 Response for w=7.2 0.02 0 1 2 3 4 5 6 Response for w=7. wn=3 0.5 Response x 0 0.2 Response x 0 0. wn=12 7 8 9 10 0.02 0 1 2 3 4 5 6 Time. seconds 7 8 9 10 Figure 5. wn=26 7 8 9 10 Response x 0 0. .30CHAPTER 5 HARMONIC EXCITATION OF UNDAMPED SDOF SYSTEMS Response for w=7.
31 Example of Beat Phenomenon 25 20 15 10 5 Response x 0 5 10 15 20 25 0 20 40 60 Time. seconds 80 100 120 Figure 5.4: Example of the beating phenomenon. .
seconds 80 100 120 Figure 5. .32CHAPTER 5 HARMONIC EXCITATION OF UNDAMPED SDOF SYSTEMS Example of Resonance Phenomenon 1500 1000 500 Response x 0 500 1000 1500 0 20 40 60 Time.5: Example of resonant vibration.
x _ or with = c=2m! n . the equations of motion change when damping is added. • _ n (6.2) where f = F=m. (6. The homogeneous solution to this equation is of the form xh (t) = Ae p !t sin(! d t + ). The xp (t) = A0 cos(!t where ). They become: m• + cx + kx = F cos(!t).4) A0 = q f (! 2 n ! 2 ) + (2 ! n !) 33 2 . (6. = tan 1 2 !n ! : !2 !2 n (6. and constants A.3) 2 where ! d = ! n 1 .5) . As with the unforced case. we will examine how the behavior of the system changes when we add damping. particular solution to the external force is depend on initial conditions. (6.Chapter 6 Harmonic Forcing of Damped SDOF Systems Now.1) x + 2 ! n x + ! 2 x = f cos(!t).
so continuing in the middle of a variable name. for the two frequencies that are near the driving frequency. showing that. the phase angle becomes 90 : For a damped system. look at the denominator of the amplitude constant. in tandem with an error statement. This ellipsis can be placed anywhere a space would be allowed. so it is always important to examine the transient e¤ects of a system before neglecting them. which shows that the length of the transient period also depends on the natural frequency. The MATLAB code below was used to produce the …gures.1 and 6. However.2. since it is also at this point that the denominator of the amplitude is a minimum. . for ! = ! n . This shows that the transient period of vibration varies inversely with damping ratio. If the damping ratio is outside the allowed range. Also. those programs had many more values to input. as the driving frequency increases greatly. However. the transient period may be much longer or may have a very large amplitude. also in an inverse relationship.1. In the damped system. The addition of damping causes the response of the system to di¤er slightly. Forcing the user of a program to reenter several values because of a typo seems a harsh penalty to this programmer. However. the transient response can be ignored due to its short time period. This is helpful for long mathematical expressions. In Figure 6. is not recommended. Notice also that the damping ratio a¤ects the amplitude of the steadystate vibration. the amplitude nears zero. Controlling input in this manner is more drastic than the method used in the previous programs. the transient period is less than 4 seconds. for some cases. To continue an expression onto the next line. Notice how. MATLAB will halt execution of the program. Instead of inserting a while statement to control the range of damping ratios used. as shown in Figures 6. Figure 6. the transient period is quite long.2 shows the e¤ects of changing the natural frequency. simply type three periods in succession (ellipsis) and move to the next line. for the large natural frequency.5 seconds for = 0:05 to about 2 seconds for = 0:3. resonance also takes on a di¤erent meaning. like the constants of integration below. x(t) = xh (t)+xp (t) is then used to evaluate constants A and . A0 : The amplitude will be maximized when the denominator is minimized. this condition de…nes resonance. for example. almost 10 seconds. the amplitude of the response for = 0:05 is almost 2. Both terms are never negative. so the minimum will occur when the two frequencies are equal (making the …rst term of the denominator zero). this program introduces MATLAB’ method for cons tinuing lines. the introduction of damping introduces a term that keeps the denominator of the steadystate amplitude from becoming zero. The length of the transient period varies from about 4. this solution is re‡ ected in the code that follows. at this point. we use an if statement. Also. while that for = 0:3 is less than 1. These constants were found for zero initial conditions using Maple.34CHAPTER 6 HARMONIC FORCING OF DAMPED SDOF SYSTEMS The complete solution. That is. However. printing the statement found inside the quotation marks to the screen. To prove this last assertion to yourself. in many cases. Notice how. the amplitude does not become in…nite. the damping ratio was varied.
35 Program 51: harmzeta.m %This program solves for the response of %a damped single degree of freedom system subject to %a harmonic external force. The expressions used for the %constants were found by using MAPLE. % wdr=3; wn=3.5; fo=4; tf=10; t=0:tf/1000:tf; for k=1:3 zeta(k)=input(’ Enter a damping ratio (zeta). ’ ); if (zeta(k)<0 j zeta(k)>=1) error(’ Zeta out of range for this program!’ ) end end for k=1:3 wd=wn*sqrt(1zeta(k)^2); Ao=fo/sqrt((wn^2wdr^2)^2+(2*zeta(k)*wn*wdr)^2); phi=atan2(2*zeta(k)*wn*wdr,(wn^2wdr^2)); Z1=zeta(k)*wnwdr*tan(phi); Z2=sqrt((zeta(k)*wn)^2+2*zeta(k)*wn*wdr*tan(phi)+ ... % Continuation. (wdr*tan(phi))^2+wd^2); % The extra tab is not necessary, but helpful. Z=(Z1+Z2)/wd; Anum=Ao*((zeta(k)*wn*Zwd)*cos(phi)+wdr*Z*sin(phi)); Aden=Z*wd; A=Anum/Aden; theta=2*atan(Z); x(k,:)=A*exp(zeta(k)*wn*t).*sin(wd*t+theta)+Ao*cos(wdr*tphi); end for k=1:3 subplot(3,1,k) plot(t,x(k,:)) title([’ Response for zeta=’ ,num2str(zeta(k)),’ wn=’ ... , , num2str(wn),’ and wdr=’ num2str(wdr)]) , , ylabel(’ Response x’ ) grid end xlabel(’ Time, seconds’ )
36CHAPTER 6 HARMONIC FORCING OF DAMPED SDOF SYSTEMS
Response for zeta=0.05, wn=3.5, and w=3 2
Response x
0
2
0
1
2
3 4 5 6 7 Response for zeta=0.1, wn=3.5, and w=3
8
9
10
2
Response x
0
2
0
1
2
3 4 5 6 7 Response for zeta=0.3, wn=3.5, and w=3
8
9
10
1
Response x
0
1
0
1
2
3
4
5 6 Time, seconds
7
8
9
10
Figure 6.1: Damped response for three di¤erent damping ratios.
37
Response for zeta=0.05, wn=2, and w=3 2
Response x
0
2
0
1
2
3 4 5 6 7 Response for zeta=0.05, wn=4, and w=3
8
9
10
1
Response x
0
1 0.05
0
1
2
3 4 5 6 7 Response for zeta=0.05, wn=16, and w=3
8
9
10
Response x
0
0.05
0
1
2
3
4
5 6 Time, seconds
7
8
9
10
Figure 6.2: Response variation with di¤erent natural frequencies.
Chapter 7
Base Excitation of SDOF Systems
The base excitation problem is illustrated in Figure 7.1. Let the motion of the base be denoted by y(t) and the response of the mass by x(t), and assuming that the base has harmonic motion of the form y(t) = Y sin(! b t). The equation of motion for this system is:
mx + c(x
::
:
y) + k(x
:
y) = 0:
(7.1)
Using the assumed form for the motion, we can substitute for y and its derivative, resulting in:
mx + cx + kx = cY ! b cos ! b t + kY sin ! b t; which when divided through by the mass, yields
::
:
(7.2)
x + 2 ! x + ! 2 x = 2 !! b cos ! b t + ! 2 Y sin ! b t: The homogeneous solution is of the form:
::
:
(7.3)
xh = Ae
!t
sin(! d t + ):
(7.4)
The expression for each part of the particular solution is similar to that for the general sinusoidal forcing function; the sine term produces a sine solution, and the cosine term produces a cosine solution. If we …nd these solutions and combine their sum into a single sinusoid, we obtain: 39
40
CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS
Figure 7.1: Typical single degree of freedom system subject to base excitation.
xp = Ao cos(! b t where s
1
2 );
(7.5)
Ao = !Y
(! 2
! 2 + (2 ! b )2 ; ! 2 )2 + (2 !! b )2 b
1
= tan
1
2 !! b ; !2 !2 b
2
= tan
1
! : 2 !b
Thus, the complete solution is the sum of the homogeneous and particular solutions, or:
x(t) = Ae
!t
sin(! d t + ) + Ao cos(! b t
1
2 ):
(7.6)
This equation tells us a great deal about the motion of the mass. First, we can see that the particular solution represents the steadystate response, while the homogeneous solution is the transient response, since the particular solution is independent of the initial displacement and velocity. Using MAPLE to solve the initial value problem (with given initial velocity and displacement not necessarily equal to zero), we …nd that both are dependent upon the initial velocity
if a line was drawn through the upper or lower peaks of the motion. very di¢ cult to solve. This is because the plots also include the base excitation (steadystate) terms. although the decrease is not entirely evident from just looking at the plots. an increase in causes the transient period to decrease. this graph shows best what is happening between the transient and steady responses. So. from about three seconds forward. The di¤erences caused by changing the amplitude is what would be expected. The midpoint of the oscillation caused by the steady response becomes exponentially closer to zero with increasing time. the relative displacement of the two parts of the structure becomes the important factor. Again.41 and displacement. Figure 7. This is mainly due to the increased di¢ culty encountered when the external load is applied to a part of the structure. This is expected. When this approach is used. The MATLAB code for this situation is much more complex than the code used in previous examples. Figure 7. First. as the plots show. which were used in the base excitation programs which follow. in general. an increase in causes a decrease in the damped natural frequency.3 gives plots for three di¤erent vibration amplitudes.4 for various damping ratios show two e¤ects of changing the damping ratio. This assumption yielded simpler equations. these are. An important consideration to note is that the answer given by MAPLE results in two possible solutions. However. with ! b = 20: In the transient portion. since the base excitation portion dominates the steady state. the transient and steadystate functions. Since the base excitation is of such high frequency. Note that. as are the initial velocities.2 shows the e¤ects of changing the excitation frequency while holding all other parameters constant. the change in damping ratio causes the length of the transient period to vary. whose frequency has not changed. for the sake of programming in MATLAB. The code for this example uses a solution obtained from the MAPLE solve routine to produce a plot of the response. as the transient response diminishes. the maximum amplitude of the overall vibration and of the steadystate response both increase with increasing input amplitude. the change in damping ratio causes a change in the frequency of the transient vibration. of course. Note from the plots that the initial displacements are zero for all plots. the result would be a curve similar to that exhibited by a damped free response. Of particular note is the bottom plot. The way in which MATLAB chooses the correct solution is to check which of them matches the initial displacement condition. instead of the displacement of the structure relative to some ground. In the steady state. the MATLAB code attempts to locate the correct one. The plots in Figure 7. even for MAPLE. The three programs given below show the changes that need to be made in a program in order to test di¤erent parameters. note that the frequency of vibration increases with the base frequency. the response has the shape of a sum of two sinusoids. the expression for the constants A and is. . the initial velocity and displacement were both assumed to be zero. Also. so we can be con…dent in the plotted solutions.
error(’ Damping ratio not in acceptable range!’ ) end wn=4. tf=10. % wd=wn*sqrt(1zeta^2).. % y0=input(’ Enter the base excitation magnitude.42 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS Program 61: varywb. if (zeta<0 j zeta>=1) % The usual test on damping ratio.:)=A1*exp(zeta*wn*t). y2(m. for k=1:3 wb(k)=input(’ Enter a base excitation frequency. Bnum1=(wd*cos(xi)+Z1*zeta*wn*cos(xi)+Z1*wb(m)*sin(xi)). t=0:tf/1000:tf. A1=Anum*Bnum1/Aden1. Bnum2=(wd*cos(xi)+Z2*zeta*wn*cos(xi)+Z2*wb(m)*sin(xi)). Anum=sqrt((wn^2+(2*zeta*wb(m))^2)/((wn^2wb(m)^2)^2+(2* . wn*wb(m)*tan(xi)+(wb(m)*tan(xi))^2+wd^2))/wd.. The %code assumes a sinusoidal base function. th1=2*atan(Z1).. .. the %program tests three di¤erent natural frequencies. y1(m.*sin(wd*t+th1).m %This program solves the base excitation problem. ’ ). phi1=atan2(2*zeta*wn*wb(m). zeta=input(’ Enter the damping ratio (zeta)..:)=A2*exp(zeta*wn*t). Aden1=wd*Z1. end for m=1:3 % %This section solves the transient response. A2=Anum*Bnum2/Aden2.2*zeta*wb(m)). xi=phi1+phi2. to keep the expressions from %spreading over several lines. wn*wb(m)*tan(xi)+(wb(m)*tan(xi))^2+wd^2))/wd. phi2=atan2(wn. ’ ). Notice the way by which %the extraordinarily long expressions for the constants %are broken into parts. Aden2=wd*Z2. ’ ). Z2=(zeta*wnwb(m)*tan(xi)sqrt((zeta*wn)^2+2*zeta* . %These constants are what produces the two possible %solutions discussed above. zeta*wb(m)*wn)^2))*wn*y0. Z1=(zeta*wnwb(m)*tan(xi)+sqrt((zeta*wn)^2+2*zeta* . using the %equations obtained from MAPLE. th2=2*atan(Z2).(wn^2wb(m)^2)).. Also.*sin(wd*t+th2).
num2str(wn)]).1)==xp(3. ’and wn=’ . seconds’ ) .43 end %This portion solves the steadystate response.x(i.. end for i=1:3 subplot(3.1.i) plot(t.:)) ylabel(’ Response x’ ).(2*zeta*wb(j))). for j=1:3 A=sqrt((wn^2+(2*zeta*wb(j))^2)/((wn^2wb(j)^2)^2+(2*zeta* . . end if (xp(1.:)=wn*y0*A*cos(wb(j)*tphi1phi2)..1)==xp(2. wn*wb(j))^2)).1)+y1(2. else x=xp+y2. phi2=atan2(wn.1)+y1(3. phi1=atan2(2*zeta*wn*wb(j). title([’ Base Excitation with wb=’ .1)==0) x=xp+y1..(wn^2wb(j)^2)). xp(j.. grid end xlabel(’ Time.num2str(wb(i)).1)+y1(1.
wn*wb)^2))..*sin(wd*t+th2). error(’ Damping ratio not in acceptable range!’ ) end wn=4. t=0:tf/1000:tf..44 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS Program 62: varyyobe.(wn^2wb^2)).:)=A1*exp(zeta*wn*t). phi1=atan2(2*zeta*wn*wb. y2(m. phi2=atan2(wn. phi2=atan2(wn. phi1=atan2(2*zeta*wn*wb. for k=1:3 y0(k)=input(’ Enter a base excitation magnitude.(wn^2wb^2)).. the %program tests three di¤erent base amplitudes.2*zeta*wb). ’ ). end for j=1:3 A=sqrt((wn^2+(2*zeta*wb)^2)/((wn^2wb^2)^2+(2*zeta* .. ’ ).m %This program solves the base excitation problem. xp(j. ’ ). Z2=(zeta*wnwb*tan(xi)sqrt((zeta*wn)^2+2*zeta* . %Notice that the natural frequency is now given as %a set variable.. % wb=input(’ Enter the base excitation frequency.(2*zeta*wb)). zeta=input(’ Enter the damping ratio (zeta). Bnum1=(wd*cos(xi)+Z1*zeta*wn*cos(xi)+Z1*wb*sin(xi)).*sin(wd*t+th1). end for m=1:3 wd=wn*sqrt(1zeta^2).:)=A2*exp(zeta*wn*t). Bnum2=(wd*cos(xi)+Z2*zeta*wn*cos(xi)+Z2*wb*sin(xi)). if (zeta<0 j zeta>=1) % The usual test on damping ratio. Anum=sqrt((wn^2+(2*zeta*wb)^2)/((wn^2wb^2)^2+(2* . end .. tf=10. A1=Anum*Bnum1/Aden1. y1(m. Aden1=wd*Z1. xi=phi1+phi2. th2=2*atan(Z2). A2=Anum*Bnum2/Aden2. wn*wb*tan(xi)+(wb*tan(xi))^2+wd^2))/wd. Aden2=wd*Z2. wn*wb*tan(xi)+(wb*tan(xi))^2+wd^2))/wd. The %code assumes a sinusoidal base function.. zeta*wb*wn)^2))*wn*y0(m). and the variable ’ y0’is a userinput matrix.. Z1=(zeta*wnwb*tan(xi)+sqrt((zeta*wn)^2+2*zeta* . th1=2*atan(Z1). Also.:)=wn*y0(j)*A*cos(wb*tphi1phi2).
.num2str(wb).1)+y1(1. title([’ Base Excitation with wb=’ .x(i..num2str(y0(i))]). seconds’ ) .’ and y0=’ .i) plot(t.:)) ylabel(’ Response x’ ). grid end xlabel(’ Time.1)+y1(2. .1)+y1(3.45 if (xp(1. ’ wn=’ .1. .1)==xp(3. .num2str(wn).1)==0) x=xp+y1. end for i=1:3 subplot(3.1)==xp(2. else x=xp+y2.
Aden2=wd*Z2. th2=2*atan(Z2). t=0:tf/1000:tf.(wn^2wb^2)). phi2=atan2(wn. The %code assumes a sinusoidal base function. if (zeta(k)<0 j zeta(k)>=1) % The usual test on damping ratio..:)=A2*exp(zeta(m)*wn*t).. Also. end for j=1:3 A=sqrt((wn^2+(2*zeta(j)*wb)^2)/((wn^2wb^2)^2+(2*zeta(j)* . % y0=input(’ Enter the base excitation magnitude.m %This program solves the base excitation problem.. the %program tests three di¤erent damping ratios. Bnum1=(wd*cos(xi)+Z1*zeta(m)*wn*cos(xi)+Z1*wb*sin(xi)). wn*wb*tan(xi)+(wb*tan(xi))^2+wd^2))/wd. Bnum2=(wd*cos(xi)+Z2*zeta(m)*wn*cos(xi)+Z2*wb*sin(xi)). wn*wb*tan(xi)+(wb*tan(xi))^2+wd^2))/wd. Z2=(zeta(m)*wnwb*tan(xi)sqrt((zeta(m)*wn)^2+2*zeta(m)* . y1(m. error(’ Damping ratio not in acceptable range!’ ) end end for m=1:3 wd=wn*sqrt(1zeta(m)^2).*sin(wd*t+th2). wn=4.. Aden1=wd*Z1.2*zeta(m)*wb).(2*zeta(j)*wb)). for k=1:3 zeta(k)=input(’ Enter a damping ratio (zeta). th1=2*atan(Z1).. zeta(m)*wb*wn)^2))*wn*y0. wb=input(’ Enter the base excitation frequency. xp(j. end . ’ ). A2=Anum*Bnum2/Aden2. Again.. tf=10. y2(m. Anum=sqrt((wn^2+(2*zeta(m)*wb)^2)/((wn^2wb^2)^2+(2* . Z1=(zeta(m)*wnwb*tan(xi)+sqrt((zeta(m)*wn)^2+2*zeta(m)* .:)=A1*exp(zeta(m)*wn*t).. A1=Anum*Bnum1/Aden1. xi=phi1+phi2. phi1=atan2(2*zeta(m)*wn*wb. phi1=atan2(2*zeta(j)*wn*wb. wn*wb)^2)). ’ ).:)=wn*y0*A*cos(wb*tphi1phi2).*sin(wd*t+th1)..46 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS Program 63: varyzbe. note %the changes between this program and the previous one. ’ ).(wn^2wb^2)). phi2=atan2(wn.
i) plot(t.1)==xp(2.num2str(zeta(i))]).47 if (xp(1.1)+y1(3.1)+y1(2.. title([’ Base Excitation with wb=’ ..x(i. .:)) ylabel(’ Response x’ ). grid end xlabel(’ Time.num2str(wb). seconds’ ) . else x=xp+y2.1)+y1(1. ’and zeta=’ . end for i=1:3 subplot(3.1.1)==xp(3.1)==0) x=xp+y1.
48 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS Base Excitation with wb=2 and wn=4 10 Response x 0 10 0 1 2 3 4 5 6 7 8 9 10 Base Excitation with wb=6 and wn=4 10 Response x 0 10 0 1 2 3 4 5 6 7 8 9 10 Base Excitation with wb=10 and wn=4 4 Response x 2 0 2 0 1 2 3 4 5 6 Time.2: Response of a baseexcited system subject to three di¤erent excitation frequencies. . seconds 7 8 9 10 Figure 7.
seconds 7 8 9 10 Figure 7.3: Results obtained for three di¤erent base excitation magnitudes. and y0=7 20 Response x 0 20 0 1 2 3 4 5 6 7 8 9 10 Base Excitation with wb=6.49 Base Excitation with wb=6. . wn=4. wn=4. and y0=3 5 Response x 0 5 0 1 2 3 4 5 6 7 8 9 10 Base Excitation with wb=6. wn=4. and y0=11 20 Response x 0 20 0 1 2 3 4 5 6 Time.
3 5 Response x 0 5 0 1 2 3 4 5 6 Time. seconds 7 8 9 10 Figure 7. .05 10 Response x 0 10 0 1 2 3 4 5 6 7 8 9 10 Base Excitation with wb=6 and zeta=0.4: Response of a baseexcited system for di¤erent damping ratios.1 10 Response x 0 10 0 1 2 3 4 5 6 7 8 9 10 Base Excitation with wb=6 and zeta=0.50 CHAPTER 7 BASE EXCITATION OF SDOF SYSTEMS Base Excitation with wb=6 and zeta=0.
y(t) = e cos ! r t: (8. we can then construct the equations of motion. and dividing by the system mass gives the …nal equation of motion: 51 .Chapter 8 SDOF Systems with a Rotating Unbalance A rotating unbalance is depicted in Figure 8. then the circle it de…nes can be described parametrically as: x(t) = e sin ! r t. x is vertical. we need an expression for the motion of the rotating unbalance in terms of x: If the mass rotates with a constant angular velocity ! r . Having this expression for x. we get: (m or mo ) x + mo :: d2 (x + e sin ! r t) = dt2 kx cx. : (8.3) Finally.1. The radius e is measured from the center of mass of the mass m: To construct the equation of motion. The position coordinate of the rotating unbalance is x + sin ! r t. Assume that the guides are frictionless. moving the sine term to the other side of the expression. :: The acceleration of the mass without the unbalance is x.1) Note that the sine de…nes the x coordinate because in our chosen coordinates. and the acceleration is the second derivative of this expression with respect to time. collecting x and its derivatives.2) (m mo ) x + mo x :: :: e! 2 sin ! r t = r kx cx: : (8. Adding in the e¤ects of the sti¤ness and damper.
except that now our force is in the form of a sine rather than a cosine.1: Schematic of the system in question (note the coordinate axes chosen). (8. the initial conditions were assumed to be zero.52CHAPTER 8 SDOF SYSTEMS WITH A ROTATING UNBALANCE Figure 8. the homogenous solution for this expression is: mo e q m (1 r2 2 r2 ) . the particular solution is of the form: xp (t) = X sin(! r t where. Then. with r = ! r =! n .4) Note that this is identical to the harmonic forcing function case we encountered earlier. ).5) X= As before.7) where A and are determined from the initial conditions. MAPLE was used to solve the resulting initial . x + 2 ! n x + ! 2 x = mo e! 2 sin ! r t: n r :: : (8. The …nal solution is then x(t) = xp (t) + xh (t): For the purpose of creating a program in MATLAB.6) xh (t) = Ae !n t sin(! d t + ). For that reason. + (2 r) 2 = tan 1 1 2 r : r2 (8. (8.
the system damping is varied.4 shows the variation of vibration with increasing system mass.2 through 8.53 value problem. if the machine can be designed to have a much higher natural frequency than the oscillating mass. as would be predicted from the expression we have derived for the parameter X. This consideration is important in the design of machinery. Notice how the amplitude of the vibration decreases with increasing mass. m = 7. The result is that the transient portion (the portion with the curve that looks like the sum of sinusoids) becomes smaller. to the point where it disappears at = 0:3: A di¤erence in the magnitude of oscillation. due to the complexity of the expression. the motion is the sum of two sinusoids. The MATLAB code that follows contains the expression (in a few parts) for the constants in question. In Figure 8. the solution for A and depend on the solution to a quadratic equation. . This is because the natural frequency of the system is too high to be excited by the relatively slow rotation frequencies. the oscillation occurs along a single sinusoid. and e = 0:1: For Figure 8. the natural frequency was varied while holding all other parameters constant.4 show di¤erent varying parameter sets for the system. The …rst two plots have natural frequencies small enough to be excited by the slow rotation of the eccentric mass. so does the amplitude of vibration. Figures 8. then the level of damping can be made low without increasing the amplitude past acceptable levels. Finally. is not present because the frequency ratio we are testing is in the range where oscillation magnitude shows little variation with damping ratio. The solution to this is not reproduced here. mo = 3. this is due to the dependence of X on mo =m: As the mass ratio decreases.3. where ! n = 2: For the highest natural frequency tested. Notice how. Figure 8. Unless otherwise speci…ed.2. this is shown best by the top plot. when ! n is not a multiple of ! r .
% mo=3.. xp(j. Z1=(zeta*wn(j)+wr*cot(phi))/wd(j).num2str(zeta)]). grid end xlabel(’ Time. xh(j.(1r^2)). wr=4. e=0. Aden=Z*wd(j). seconds’ ) .k) plot(t.1. A=Anum/Aden. %The equations of motion were derived using MAPLE and %are valid only for zero initial conditions.’and zeta=’ .:)=A*exp(zeta*wn(j)*t).num2str(wr)..*sin(wd(j)*t+theta). ’ ).54CHAPTER 8 SDOF SYSTEMS WITH A ROTATING UNBALANCE Program 71: vrywnrot. theta=2*atan(Z).m %This program solves for the response of a single %degree of freedom system having a rotating unbalance.’wn=’ . end x=xp+xh. m=7. Z=Z1+Z2. tf=10. num2str(wn(k)). t=0:tf/1000:tf.1.05. for k=1:3 subplot(3.:)) title([’ Rotating Unbalance with wr=’ . ..x(k. Z2=sqrt((zeta*wn(j))^22*zeta*wn(j)*wr*cot(phi)+ . phi=atan2(2*zeta*r. zeta=0. (wr*cot(phi))^2+wd(j)^2)/wd(j). for i=1:3 wn(i)=input(’ Enter a natural frequency. Anum=X*(wd(j)*sin(phi)Z*zeta*wn(j)*sin(phi)+Z*wr*cos(phi)).:)=X*sin(wr*tphi). wd(i)=wn(i)*sqrt(1zeta^2). X=mo*e/m*(r^2/sqrt((1r^2)^2+(2*zeta*r)^2)). end for j=1:3 r=wr/wn(j)..
:)) title([’ Rotating Unbalance with wr=’ ..:)=X*sin(wr*tphi). Aden=Z*wd. wn=12. Z1=(zeta(j)*wn+wr*cot(phi))/wd. %The equations of motion were derived using MAPLE and %are valid only for zero initial conditions.’wn=’ .’and zeta=’ . e=0. Z=Z1+Z2. seconds’ ) .(1r^2)). .num2str(zeta(k))]). Z2=sqrt((zeta(j)*wn)^22*zeta(j)*wn*wr*cot(phi)+ .55 Program 72: vryzrot. ylabel(’ Response x’ ) grid end xlabel(’ Time.:)=A*exp(zeta(j)*wn*t).x(k. num2str(wn).1. end x=xp+xh. m=7..*sin(wd*t+theta). tf=10.. phi=atan2(2*zeta(j)*r. wr=4. theta=2*atan(Z). (wr*cot(phi))^2+wd^2)/wd. X=mo*e/m*(r^2/sqrt((1r^2)^2+(2*zeta(j)*r)^2)). end for j=1:3 wd=wn*sqrt(1zeta(j)^2). A=Anum/Aden.1. t=0:tf/1000:tf. for k=1:3 subplot(3.m %This program solves for the response of a single %degree of freedom system having a rotating unbalance. xp(j. ’ )..num2str(wr). r=wr/wn. Anum=X*(wd*sin(phi)Z*zeta(j)*wn*sin(phi)+Z*wr*cos(phi)). xh(j.k) plot(t. % mo=3. for i=1:3 zeta(i)=input(’ Enter a damping ratio (zeta).
. for i=1:3 m(i)=input(’ Enter a system mass. Z=Z1+Z2. X=mo*e/m(j)*(r^2/sqrt((1r^2)^2+(2*zeta*r)^2)). Z2=sqrt((zeta*wn)^22*zeta*wn*wr*cot(phi)+ . num2str(wn). (wr*cot(phi))^2+wd^2)/wd. num2str(mo)]). phi=atan2(2*zeta*r. r=wr/wn. wr=4.1.. ..m %This program solves for the response of a single %degree of freedom system having a rotating unbalance.num2str(wr). grid end xlabel(’ Time.:)) title([’ Rotating Unbalance with wr=’ ..num2str(m(k)). A=Anum/Aden. seconds’ ) .1. xp(j.x(k.*sin(wd*t+theta). . theta=2*atan(Z).05. xh(j. % mo=3.:)=A*exp(zeta*wn*t). Z1=(zeta*wn+wr*cot(phi))/wd. t=0:tf/1000:tf. zeta=0. end x=xp+xh. Aden=Z*wd.k) plot(t. . e=0.:)=X*sin(wr*tphi). for k=1:3 subplot(3. Anum=X*(wd*sin(phi)Z*zeta*wn*sin(phi)+Z*wr*cos(phi)). .(1r^2)). ’ )..56CHAPTER 8 SDOF SYSTEMS WITH A ROTATING UNBALANCE Program 73: vrymrot. end for j=1:3 wd=wn*sqrt(1zeta^2).’ wn=’ .. .’ and rotating mass=’ . wn=12.’ mass=’ . tf=10. %The equations of motion were derived using MAPLE and %are valid only for zero initial conditions.
seconds 7 8 9 10 Figure 8.05 0 0. .05 0 1 2 3 4 5 6 7 8 9 10 Rotating Unbalance with wr=4 wn=12 and zeta=0.2: Response of systems with di¤erent natural frequencies to a rotating unbalance.05 0.01 0 0.57 Rotating Unbalance with wr=4 wn=2 and zeta=0.2 0 1 2 3 4 5 6 7 8 9 10 Rotating Unbalance with wr=4 wn=6 and zeta=0.05 0.05 0.2 0 0.01 0 1 2 3 4 5 6 Time.
01 Response x 0 0. seconds 7 8 9 10 Figure 8.05 0.58CHAPTER 8 SDOF SYSTEMS WITH A ROTATING UNBALANCE Rotating Unbalance with wr=4 wn=12 and zeta=0.01 0 1 2 3 4 5 6 Time.1 0.01 0 1 2 3 4 5 6 7 8 9 10 Rotating Unbalance with wr=4 wn=12 and zeta=0.01 0 1 2 3 4 5 6 7 8 9 10 Rotating Unbalance with wr=4 wn=12 and zeta=0. .3: Response with varied damping ratios.01 Response x 0 0.01 Response x 0 0.3 0.
. wn=12. wn=12.01 0 0.05 0 0. mass=1.02 0 1 2 3 4 5 6 7 8 9 10 Rotating Unbalance with wr=4.05 0 1 2 3 4 5 6 7 8 9 10 Rotating Unbalance with wr=4. seconds 7 8 9 10 Figure 8. and rotating mass=3 0.02 0 0. mass=3.4: E¤ects of varying system mass. wn=12.01 0 1 2 3 4 5 6 Time. and rotating mass=3 0. mass=6.59 Rotating Unbalance with wr=4. and rotating mass=3 0.
.
then the average value is Fo =2 : So. it is Fo =2 : Using the de…nition of impulse as force multiplied by time. The simplest of these is the impulse response. within the interval. (9. then it is applied from t to t + : If the force has a total value of Fo . 61 . this problem reduces to a single degree of freedom free vibration with zero initial displacement and initial velocity equal to Fo =m: Recall that for a damped oscillator. and it is vo after the impulse. the value of the impulse is 0. In the following examples. the response is of the form: x(t) = Ae Since !t sin(! d t + ): (9. we will examine the e¤ects of nonsinusoidal inputs on single degree of freedom systems. So.1) where vo is the initial velocity of the system. The period over which the impulse is applied is assumed to be 2 : If the impulse is centered about time t. and noting that impulse is the change in momentum.Chapter 9 Impulse Response of SDOF Systems In the previous few examples. This is because the velocity of the system before the impulse is zero. we see that: (Fo =2 ) 2 = mvo . for all time except the interval around t. = tan 1 (xo ! d = (vo + !xo )) . An impulse is a force which is applied over a very short time when compared to the period of vibration. we have discussed the response of single degree of freedom systems to di¤erent forms of sinusoidal inputs.2) p A = (vo + !xo )2 + (xo ! d )2 =! d .
" substituting the value entered for td : Superscripts. by plotting the function over a speci…ed time interval. . Notice the results when the program is run. One more item of note is the “ndelta” in the ylabel function call. and equal to one for the speci…ed time. which is usable inside of a MATLAB string. such as several of the unwieldy constants we derived for some of our earlier examples. A subfunction is called just like any other MATLAB function. Thus. if we tried to use the variable “int” in the main code of Program 82. subscripts. for an impulse around a given time and with a given total time interval.3) This response. they are not introduced to the MATLAB workspace. as noted above. For that reason. The variables used inside the subfunction stay in the subfunction. is simply a single degree of freedom oscillator subject to an initial velocity. Greek characters. This is more handy for singleuse functions. Program 82 gives an example of how this delta function can be used inside of another program. Equation 9. a program and plots for this situation are not included. The behavior with changing Fo is similar to changing vo in a single degree of freedom oscillator. and is internal to the code. That is a LaTEX tag. we would generate an error. they would be the same as those in Example 2. Thus. A = vo =! d . This program makes use of subfunctions as well. for xo = 0. and other useful e¤ects are available in this manner. and x(t) = Fo e !d !t sin(! d t): (9. The program simply takes the entire interval and sets the function equal to zero for all times other than the one speci…ed. Included in this example is a program which simulates the Dirac delta function (an impulse with Fo = 1).62 CHAPTER 9 IMPULSE RESPONSE OF SDOF SYSTEMS = 0. The subfunction is written after the main code.2 becomes we note that. “help latex” at the MATLAB prompt can give you a start on using these. the yaxis reads “ (td ) .
%The user must input the time at which the %nonzero value is desired. The strategy is to subdivide %the interval into at least 500 steps (this ensures the %interval over which the function is nonzero is small). %The variable int ensures that a value in the time vector %will match the desired time.63 Program 81: delta. end t=0:tf/int:tf. % int=tf*td. % while int<500 int=int*10. end end .tf) %This function simulates the delta function. and the ending time. td. for i=1:int if t(i)==td delta(i)=1.m function delta=delta(td. tf. else delta(i)=0.
t=linspace(0. plot(t. and has the same number of points % as the vector y (else we will get a plotting % error).64 CHAPTER 9 IMPULSE RESPONSE OF SDOF SYSTEMS %Program 82: subdemo.’ ]). % we need to create a time vector that goes from % zero to tf. If we were to % write Program 82 as a script (like most of % our m…les to this point). we use the “max” and % “size” commands. % “size” returns the vector [nrows ncols]. . the delta function % would have to be external. )’ xlabel(’ Time. % Note that subfunctions cannot be used % inside of script m…les. td. seconds’ ). Taking the % maximum will return the longer dimension.tf) % This function is Program 81. ylabel([’ ndelta(’ . % y=subdelta(td. tf. This will generate % a vector with len equallyspaced elements between % 0 and tf. % Note that a subfunction is included % with a “function” call. grid function delta=subdelta(td. % and the overall timespan.m function [t. len=max(size(y)).y) title(’ Delta Function Sample’ ).y]=subdemo(td. % Now that we have the value of the delta function.tf). % making use of the delta function as an example.tf) % % A simple routine to demonstrate use of subfunctions. For this.num2str(td). % Calling the subfunction version “subdelta” % guarantees we’ be calling the subfunction.tf. % “linspace” is much more natural a command for this % instance than the colon operator. while int<500 int=int*10. and is a % shortcut usable for both row and column vectors. just like an % external function.len). corresponding % to the number of rows and columns in y. ll % not the function from Program 81. int=tf*td. % Inputs are the time of the delta function.
else delta(i)=0.65 end t=0:tf/int:tf. end end . for i=1:int if t(i)==td delta(i)=1.
.
We assume the system is underdamped and will have zero initial conditions. We already know the equation of motion. The impulse response. If a force of this sort is plotted versus time. This is essentially an onfunction. So then. The …rst fundamental theorem of calculus then allows the in…nite series to be treated as the integral given above. but it will be sustained out to in…nity. x + 2 ! n x + ! 2 x = F (t)=m.1) In order to solve the di¤erential equation.Chapter 10 Step Response of a SDOF System In this example. (10. the behavior of the system under this type of load is considered the step response of the single degree of freedom system. the force looks like a step up. we will use the convolution integral Z t :F : (10. n where F (t) = 8 <0 if 0 < t < to o :: : (10.3) 0 Recall that the convolution integral is derived by treating the force as an in…nite series of impulse forces.2) if t to x(t) = F ( )g(t )d : (10. the force is assumed to be applied instantaneously.4) 67 . given by x(t) = Fo e m! d !n t sin ! d t = Fo g(t). just discussed.
for t < to .6) 0 Now. the rate of exponential decrease in the response (the e¤ect of damping) is increased. the oscillation frequency decreases. we vary the natural frequency. the magnitude of the response is directly proportional to the magnitude of the external force. we can substitute our F (t) into Equation 10.5) 1 e x(t) = m! d !n t Z t F ( )e !n sin ! d (t )d : (10. Instead.2.6 to give: Z Z 1 e x(t) = m! d to t !n t (0)e !n sin ! d (t )d + Fo e !n sin ! d (t )d (10.68 CHAPTER 10 STEP RESPONSE OF A SDOF SYSTEM where we know that g(t) = Therefore. . For that reason. Second. we must evaluate the second integral (by parts): ( ) Fo x(t) = k where 1 1 = tan p p 1 1 1 2 2 e ! n (t to ) cos [! d (t to ) ] . The value of this center point is also dependent on the magnitude of the external force (from the term 1 in the Equation 10.8). it is not centered around zero. the response of the system is zero. To …nd the response for all other times. since we have a general expression for x(t). That is. that is. the only di¤erence that results from changing the magnitude of the external force is that the magnitude of the response changes. Figure 10. the response is zero before application of the force. The magnitude of the external force also causes a second di¤erence: note that when the oscillatory motion begins. As might be expected.t to . the response stabilizes more quickly. the mass oscillates around a displacement greater than zero. (10. This causes two changes in the response.1 shows the variation of the response with the force magnitude. First. since the natural frequency also dictates the damped frequency. 1 e m! d !t sin ! d t: (10.7) : 0 to Note that the …rst term inside the braces is zero. In Figure 10.8) : It is important to remember that this equation is only valid for the time after the force is applied.
the amount of time to damp out all vibration decreases. the timedependent part of all three responses is independent of the forcing parameters. for more complicated calculations. In MATLAB. the damping is su¢ cient to allow no oscillation around the new center point (x = 1:5). In Fortran or C programming. For the third ratio tested.3 shows the changes caused by changing the damping ratio. The answer is “yes. Thus. We could then create a matrix that has the time response in each row. and use array multiplication to include the forcedependent parameters. note …rst that the parameters phi and wd are calculated outside the loop. These quantities are constant for all forces. A second result.) . this process is called vectorization of code. Figure 10. we would be forced to use a loop to compare whether the time at each point of the time vector exceeded the step time.69 Finally. the greaterthan operator applied to a vector will produce a vector with zeros where the relation is false. thus. (This is the algorithm for the reader exercise described above. = 0:3.) The three programs used for this example follow below. Using the calculation below as an example. which is not immediately evident from the …gure but follows from the mathematics. The way in which the force array is created in Program 91 illustrates the convenience a¤orded the programmer by MATLAB. and ones where it is true. The for loop is one of the more timeconsuming constructions inside MATLAB. So if we create a matrix having the results of t > to in each row. is that the phase angle changes with the damping ratio (note that is a function of only . With increasing damping ratio. we will produce a matrix having step forcing in each row of the appropriate magnitude.”and the programming is left to the reader. and arraymultiply this matrix by the threebynpts force matrix. and then adjust the force vector appropriately. activated at t = to : The reader may then wonder if the loop calculating the response could have been removed in a similar manner. it is advantageous to remove these loops from the code.
% The force matrix. for n=1:3 A=Fo(n. % and make a 3bynpts matrix of the result. %The program assumes a system mass of 1. wn=12. npts=1000. wd=wn*sqrt(1zeta^2).qtest]. .num2str(wn).tf.:)/k.m %This program calculates the step response %of a single degree of freedom system. % zeta=0. end Fint=Fm*ones(1. to=2. B=Fo(n. This %version tests three di¤erent force magnitudes.:)=AB. .*cos(wd*tphi). phi=atan2(zeta.npts). % % Now.:)/(k*sqrt(1zeta^2)).x(l. ’ % Forcing Fm to be a ). .*fmult. . % Three rows of qtest.qtest. % Fint is thus 3bynpts. we perform the logical operation t>to.:)) title([’ Response for wn=’ .’ Fmax=’ .l) plot(t. t=linspace(0.’ and time=’ num2str(to)]). end for l=1:3 subplot(3. x(n.*exp(zeta*wn*t).npts). % qtest=t>to. Fo=Fint. ylabel(’ Response x’ ) grid end xlabel(’ Time.1)=input(’ Enter a force magnitude. seconds’ ) . fmult=[qtest. column vector.1..05. for i=1:3 Fm(i. tf=10. num2str(Fm(l)). k=(wn)^2.70 CHAPTER 10 STEP RESPONSE OF A SDOF SYSTEM Program 91: stepfm.sqrt(1zeta^2))..
k(i)=wn(i)^2. num2str(Fm).1. % Fm=5.. % Only one force vector here. zeta=0.05. B=Fo/(k(n)*sqrt(1zeta^2)).num2str(wn(l)). This %version tests three di¤erent natural frequencies. end for l=1:3 subplot(3. t=linspace(0.’ Fmax=’ . ylabel(’ Response x’ ) grid end xlabel(’ Time. x(n. seconds’ ) .tf.l) plot(t. . Fo=Fm*qtest. .:)=AB.71 Program 92: stepwn.npts). for i=1:3 wn(i)=input(’ Enter a natural frequency.’ and time=’ num2str(to)]).:)) title([’ Response for wn=’ . . ’ ). . % Scalar Fm * 1bynpts vector. to=2.*cos(wd*tphi).m %This program calculates the step response %of a single degree of freedom system. end % % This could also be vectorized. A=Fo/k(n).x(l.. qtest=t>to. % for n=1:3 wd=wn(n)*sqrt(1zeta^2). phi=atan2(zeta. so we can do this here. tf=10. npts=1000. %The program assumes a system mass of 1.*exp(zeta*wn(n)*t).sqrt(1zeta^2)).
72 CHAPTER 10 STEP RESPONSE OF A SDOF SYSTEM Program 93: stepzeta. . .sqrt(1zeta(n)^2)). num2str(zeta(l)). . tf=10. for i=1:3 zeta(i)=input(’ Enter a damping ratio (zeta). % npts=1000.:)) title([’ Response for wn=’ . B=Fo/(k*sqrt(1zeta(n)^2)). end % % This could also be vectorized. qtest=t>to. t=linspace(0. Fm=5.. ’ ).:)=AB.num2str(wn).tf. end for l=1:3 subplot(3. phi=atan2(zeta(n). to=2. ylabel(’ Response x’ ) grid end xlabel(’ Time.1. seconds’ ) . % for n=1:3 wd=wn*sqrt(1zeta(n)^2).’ zeta=’ .. Fo=Fm*qtest. wn=12. A=Fo/k.x(l.m %This program calculates the step response %of a single degree of freedom system.*exp(zeta(n)*wn*t).npts). k=(wn)^2.*cos(wd*tphi). %The program assumes a system mass of 1.’ and time=’ num2str(to)]). This %version tests three di¤erent natural frequencies. .l) plot(t. x(n.
and time=2 0. Fmax=11. Fmax=7. and time=2 0.01 0 0 1 2 3 4 5 6 7 8 9 10 Response for wn=12. seconds 7 8 9 10 Figure 10.02 0. .1 Response x 0. and time=2 0.05 0 0 1 2 3 4 5 6 7 8 9 10 Response for wn=12.73 Response for wn=12. Fmax=3.05 0 0 1 2 3 4 5 6 Time.1 Response x 0.1: Step response of a single degree of freedom system to di¤erent step magnitudes.03 Response x 0.
Fmax=5. and time=2 0. .04 0.1 0 0 1 2 3 4 5 6 7 8 9 10 Response for wn=12.2: Step response of single degree of freedom systems having di¤erent natural frequencies. and time=2 Response x 0. and time=2 Response x 0.74 CHAPTER 10 STEP RESPONSE OF A SDOF SYSTEM Response for wn=4. seconds 7 8 9 10 Figure 10.5 0 0 1 2 3 4 5 6 7 8 9 10 Response for wn=7. Fmax=5.06 Response x 0. Fmax=5.02 0 0 1 2 3 4 5 6 Time.
3: Step response of a single degree of freedom system to di¤erent levels of damping.04 Response x 0. and time=2 0. seconds 7 8 9 10 Figure 10. and time=2 0.02 0 0 1 2 3 4 5 6 7 8 9 10 Response for wn=12.04 0. zeta=0.3.75 Response for wn=12.05. .06 Response x 0.02 0 0 1 2 3 4 5 6 Time.1. and time=2 0. zeta=0. zeta=0.02 0 0 1 2 3 4 5 6 7 8 9 10 Response for wn=12.04 Response x 0.
.
(11. we …nd that: p 1 1 2 e ! n (t to ) cos [! d (t to ) ] . the total response is the sum of the response of the system to each step input. To analyze the response of systems to a square wave input.t ) to .Chapter 11 Response of SDOF Systems to Square Pulse Inputs A square pulse is a single pulse of constant magnitude and …nite duration.1) Fo x1 (t) = k and ( 1 p 1 1 2 e !t cos [! d t ] . and add to it at time t1 a step input of magnitude Fo: By superposition. denoting the response of the system to the input at time t = 0 as x1 (t) and the response to the input at time t = t1 as x2 (t). Recall that the response of a single degree of freedom system to a step input of magnitude Fm applied at time to is: Fm x(t) = k ( 1 p 2 where = arctan = 1 : If we now consider the two step inputs separately. t ) 0 (11.2) 77 . we begin with a step input of magnitude Fo from time t = 0. To simulate the wave using step inputs. Let us assume that the magnitude of the square wave is Fo . The time interval between application of the step inputs is the duration of the square wave. we will treat the square wave as the sum of two equal and opposite step inputs applied at di¤erent times. and its duration is t1 seconds.
Assume.5. the oscillation is centered around zero. the addition of the two responses has removed this term entirely. call it F1 : In this case. for the time interval after t1 . we would know the expression is incorrect. This is because a discontinuous expression would imply that the mass moved from one point to another nonadjacent point without passing through the points in between. the \1 " term caused the oscillation to be about a new equilibrium (i.1 is that the change in Fo causes the magnitude of the oscillations to increase. which tests three di¤erent values of Fo : The oscillation begins about a center point at x = Fo =k: When the square wave ends. perform the superposition used to obtain Equation 11. Notice that a transition point occurs when the second step input is added. the response no longer includes a \1 " term. we can infer that the approach is correct. (11.78CHAPTER 11 RESPONSE OF SDOF SYSTEMS TO SQUARE PULSE INPUTS x2 (t) = Fo k ( 1 The total response is then: ( ) p 1 1 2 e !(t t1 ) cos [! d (t t1 ) ] . that the magnitude of the second step is not equal to that of the …rst.3 demonstrates the response behavior for three di¤erent damping ratios. t t1 : (11.5. t ) t1 : (11. a physically impossible situation. as would be expected from Equation 11. Finally. Again recalling a previous example. x = Fo =k). the center point returns to zero. above (remember that F1 is negative!). since we have a piecewise expression for x(t): But note that while the transition becomes more abrupt as the natural frequency increases.2 shows the e¤ects of changing the natural frequency. A constant term will remain.e. The movement of the center point of the oscillation is best shown in Figure 11. the center point of the oscillation after adding the second step input would be at x = (Fo F1 ) =k: To prove this to yourself. if we had obtained a discontinuity in the motion. 0 t < t1 . when the equal and opposite step is added. it is never discontinuous.3) Fo x(t) = k 1 p e 1 1 2 e !n t cos [! d t ] . Now.5) . so that the mass is practically at rest Fo e x(t) = p k 1 !n t 2 ! n t1 cos [! d (t t1 ) ] cos (! d t ) .4) Notice how. Since the motion of the mass remains continuous.. Again. for a moment. since the term has disappeared. and this term will be equal to (Fo F1 ) =k: Another result which is evident from Figure 10. Figure 11.1. or. Figure 11. The sudden shift in vibration characteristics is expected. notice how the high damping ratio ( = 0:3) causes all of the vibration to be damped out quickly.
and so the s code is faster when handling one matrix calculation instead of many scalar calculations. . the di¤erence is that MATLAB’ vector/matrix calculations are highly optimized. Often. and see the results. this is a disadvantage from a debugging perspective. For a vector b. the output of a = b(:) is a column vector for any vector b: Another interesting consequence of this use of the colon operator is the result for a matrix b: The colon operator would return a column vector a consisting of the rows of b stacked on top of each other. Additionally. taking the number of points in the time vector as inputs? How would we modify the code then? The advantage would be that all the variables from the function would not become part of our workspace. if we wish to be certain whether a vector we are working with is a column vector. MATLAB will return a column vector a that is equal to a column vector b or the transpose of a row vector b: That is. what would we do if we wanted to force a to be a row vector? Finally. where the ones correspond to times before to : Then the MATLAB “not” operator (the tilde. The MATLAB code to produce these …gures demonstrates the vectorization discussed in the previous example. what if we wished to make these script instead functions.79 when the second step input is applied. ~) is used to arrive at times after to : The reader is encouraged to rewrite the vectorized calculation as a loop (in any of the three codes) and see for himself the di¤erence in time expenditure as the number of points is increased by a few orders of magnitude. Note how the logical operation t < to is used to create a matrix of zeros and ones. Again. While there are no fewer actual calculations performed in the vectorized code. has a particular meaning in MATLAB. the statement a = b(:). The reader is encouraged to try this. One more di¤erence between these codes and the previous is that we’ ve inserted another use of the colon operator. As explained in Program 101. but is very nice to have in working code. then we can use the colon operator in this manner to force it to be so. we see that the transient period decreases with increasing damping ratio.
% we’ need a wn. Fm=5. % We need a sti¤ness for each force/time point. q=sqrt(1zeta^2). zeta=0.npts). wn=wn(:). end % Demonstrating another use of the colon operator. we need a similar sized matrix for the force magnitude. % % To use the logical operators. and leaves it as % a column vector if it was one already. % The wave is assumed to begin at t=0.m % This program …nds the response of a single % degree of freedom system to a square wave input. and wd for each point in time and each ll % di¤erent value. t=linspace(0.qtest]. % 3bynpts matrix. k(i)=sqrt(wn(i)). we need to create a vector % that is one for t<to. k=k(:). for i=1:3 wn(i)=input(’ Enter a natural frequency. wn(:) turns wn into a column % vector if it was a row vector. % And a 3bynpts time matrix. phi=atan2(zeta.tf.qtest. we know the result will be a column vector wn. x1=A. tmat=[t. % wd=wn*q.*tmat).npts). ’ ). % 3by1 matrix. % qtest=t<to.q). Fo=Fm*ones(3.t.npts). % Now.80CHAPTER 11 RESPONSE OF SDOF SYSTEMS TO SQUARE PULSE INPUTS % Program 101: sqrewn. again. wnmat=wn*ones(1.*tmatphi)/q). tf=10. and lasts until % t=to. and turn it into a matrix. to=3. k. The system mass is again assumed to be equal to 1.*(1exp(zeta*wnmat. That can be done by multiplying the % 3by1 matrices we get from our input and calculation % by ones(1. . qpiece=[qtest.05. kmat=k*ones(1. % In order to calculate the response in a vectorized manner. % 3bynpts. A=Fm. % In this sense. Either % way.t].npts).npts). % npts=1000./kmat. wdmat=wd*ones(1.npts).*cos(wdmat.
seconds’ ) . % “not” qpiece.’.*(tmatto)phi)cos(wdmat. ’ to=’ .*to). .l) plot(t. for l=1:3 subplot(3... .*qpiece+x2.81 x2=A. ylabel(’ Response x’ ) grid end xlabel(’ Time.num2str(to).*(exp(zeta*wnmat.*tmat).and Fm=’ num2str(Fm)]) .x(l.*cos(wdmat.*(~qpiece).:)) title([’ Square Wave Response for wn=’ num2str(wn(l)). . x=x1.*exp(zeta*wnmat.*tmatphi))/q.1.
t=linspace(0. % Since solution is piecewise.q). q=sqrt(1zeta^2).npts). The system mass is again assumed to be equal to 1. end Fm=Fm(:). % npts=1000. % 3bynpts matrix.t.*(1exp(zeta*wn*tmat). % One row for each Fm value. when % the square wave begins at t=t1 and ends at % t=t2. % See above.. % ~is the “not” operator. % This code demonstrates vectorization of this % piecewise expression. wn=11. ’ ).:)) title([’ Square Wave Response for wn=’ num2str(wn). % Again. We’ be making use of ll % the qtest vector above to tell the code when % to activate each solution.*cos(wd*(tmatto)phi)cos(wd*tmatphi))/q. a simpler % statement is valid: qtest=(t<to). . Fo=Fm*ones(1. for l=1:3 subplot(3. x=x1.*cos(wd*tmatphi)/q). % qpiece=[qtest. .82CHAPTER 11 RESPONSE OF SDOF SYSTEMS TO SQUARE PULSE INPUTS %Program 102: sqrefm.*exp(zeta*wn*tmat). and lasts until %t=to. .qtest].05.*qpiece+x2. tf=10. % Solution for t<to. phi=atan2(zeta. we need Fm throughout.*(~qpiece). k=(wn)^2. to=3.tf. % we can use MATLAB’ logical operators to s % create a piecewise function without resorting % to a loop.qtest. x2=A.*(exp(zeta*wn*to). 3bynpts. A=Fo/k. zeta=0. % As with the step response example earlier.1.x(l.t]. %The wave is assumed to begin at t=0. This can be done with the % statement: qtest=(t>t1)(t>t2). x1=A.m %This program …nds the response of a single %degree of freedom system to a square wave input.l) plot(t.. for i=1:3 Fm(i)=input(’ Enter a force magnitude. tmat=[t. For the case of t1=0.npts). wd=wn*q.
seconds’ ) .’.83 ’ to=’ . ylabel(’ Response x’ ) grid end xlabel(’ Time.num2str(to). .and Fm=’ num2str(Fm(l))]) .
x=x1. % 3bynpts. % Once more. zmat=zeta*ones(1. and lasts until % t=to.l) plot(t. k=(wn)^2. ylabel(’ Response x’ ) grid end xlabel(’ Time.*(tmatto)phi)cos(wd.tf. seconds’ ) .m % This program …nds the response of a single % degree of freedom system to a square wave input.*(~qpiece). wn=11.*tmat).npts). x2=A*exp(zmat*wn. .and zeta=’ num2str(zeta(l))]) . for i=1:3 zeta(i)=input(’ Enter a damping ratio (zeta). phi=atan2(zmat.q).1)*t.84CHAPTER 11 RESPONSE OF SDOF SYSTEMS TO SQUARE PULSE INPUTS % Program 103: sqrez.:)) title([’ Square Wave Response for wn=’ num2str(wn).*qpiece+x2. t=linspace(0. A=Fm/k. We will need matrices for any % quantities derived from the damping ratio.’. end zeta=zeta(:). % Again we will vectorize the code by using the logical operators % on t and to./q). and for time.*cos(wd. for l=1:3 subplot(3..1. % npts=1000. Note the array square operator. .x(l.*tmatphi). to=3. . This time it will be somewhat easier. wd=wn*q. % qtest=t<to. The system mass is again assumed to be equal to 1. x1=A*(1exp(zmat*wn.num2str(to). % wd is 3bynpts.*cos(wd.*(exp(zmat*wn*to).^2). % MATLAB will handle this on an elementbyelement basis. since the % sti¤ness and force are scalar.*tmat)./q. q=sqrt(1zmat. qpiece=ones(3. % The wave is assumed to begin at t=0. % Scalar.1)*qtest. tmat=ones(3. ’ ). % 3bynpts.*tmatphi)). tf=10. % Another way to create the matrix..npts). ’ to=’ . Fm=7.
05 0 1 2 3 4 5 6 7 8 9 10 Square Wave Response for wn=11. to=3 .2 Response x 0 0 1 2 3 4 5 6 7 8 9 10 Square Wave Response for wn=11.and Fm=3 0.and Fm=11 0.85 Square Wave Response for wn=11. seconds 7 8 9 10 Figure 11.2 Response x 0 0 1 2 3 4 5 6 Time. .and Fm=7 0. to=3 .1: Plot of responses for three di¤erent force magnitudes. to=3 .05 Response x 0 0.
2: Square wave response variation with di¤erent natural frequencies.and Fm=5 4 Response x 2 0 2 0 1 2 3 4 5 6 Time.and Fm=5 4 Response x 2 0 2 0 1 2 3 4 5 6 7 8 9 10 Square Wave Response for wn=12. to=3 .86CHAPTER 11 RESPONSE OF SDOF SYSTEMS TO SQUARE PULSE INPUTS Square Wave Response for wn=4. . seconds 7 8 9 10 Figure 11. to=3 .and Fm=5 5 Response x 0 5 0 1 2 3 4 5 6 7 8 9 10 Square Wave Response for wn=8. to=3 .
and zeta=0.05 0.3 0.and zeta=0. seconds 7 8 9 10 Figure 11.87 Square Wave Response for wn=11.and zeta=0. to=3 .2 Response x 0 0 1 2 3 4 5 6 7 8 9 10 Square Wave Response for wn=11.1 Response x 0 0 1 2 3 4 5 6 Time.1 0.2 Response x 0 0 1 2 3 4 5 6 7 8 9 10 Square Wave Response for wn=11.3: E¤ects of changing damping ratio on the square wave response. . to=3 . to=3 .
.
Chapter 12 Response of SDOF System to Ramp Input Another common form of input encountered in real applications is the ramp input. To examine the response of a single degree of freedom system to this sort of input. we must again apply the convolution integral. Assuming that the load is increased uniformly at a rate of fo per second and reaches its maximum at time td .1) o d Substituting the expression for F (t) into the convolution integral yields: 8 < : x(t) = fo m! d e fo m! d e !n t !n t Rt e h0 R td 0 !n sin ! d (t sin ! d (t )d )d + td Rt td e !n e !n sin ! d (t )d for t (12. td : This expression is best evaluated using MAPLE or a table of integrals. . x(t) = fo e m! d !n t 2 1 !2 + !2 n d 2 2 !d e !n t t 2 ! 2 + t! 2 n d 2 ! n + 2 ! n ! d cos(! d t) + !2 n ! 2 sin (! d t) . td : (12.2) i for 0 t < td . then the expression for the external force is: 8 <f t o F (t) = :f t for 0 for t t < td . 0 d 89 t < td .
Notice how the system is oscillating during this period. until the load is fully applied. we use vector multiplication to construct two solution matrices over the entire time interval. Figure 12. we make use of Matlab’ logical operators to assemble the full piecewise s solution.2 shows that this is not the case. Also. This shows that the ramp response does have a subtle di¤erence from the step response. The Matlab code below follows the same general structure we have seen previously. Notice how the response seems to be nonexistent for the …rst few seconds. around a constantly increasing equilibrium. the ramp response has less de‡ ection at the point in time that the full load is applied than the step response. as in the step response. as it was in the step and square wave responses. Finally.3) Note that k represents the system sti¤ness. one would infer that the transition to the new equilibrium of vibration is discontinuous. This solution is re‡ ected in the MATLAB code that follows. This …gure only shows the response during the transient loading period. . Note that both portions of the piecewise solution for x(t) are multiplied by the same constant factor. it is reasonable to assume that the ramp response and step response of a single degree of freedom system are similar.90CHAPTER 12 RESPONSE OF SDOF SYSTEM TO RAMP INPUT x(t) = fo e m! d !n t 2 1 !2 n + 2 !2 d !d e !n t t 2 ! 2 + t! 2 n d 2 ! n + 2 ! n ! d cos(! d t) + 2 !2 n ! 2 sin (! d t) + d fo t d k f t po d k 1 2 e ! n (t td ) cos(! d (t td ) ). the result would be a line of positive slope. We vectorize the code. So. avoiding the slower loops. we initialize the variable a1 in Program 101 once. until after the input has levelled o¤. That is. at this point. An important note about the solution for this expression is that there is no equilibrium position. so that we apply Matlab’ strength (vector s math) to the problem. This is because the constant that creates the new center point is the result of an integration that does not start at zero. and no such integration exists in this solution until after td : From Figure 12. t td : (12. if a line was drawn through the identical point on each period of the sinusoid. and then begins oscillating. as seen for the step and square wave responses. However. Thus.1.
and %is assumed to last for te seconds.npts). q=sqrt(1zeta^2). num1=t*(zeta*wn)^2+t*wd^22*zeta*wn. tf=10. The external %force is assumed of the form F(t)=fo*t.npts). for i=1:3 subplot(3.qtest2]. a1=fo/(k*(zeta^2*wn^2+wd^2)^2). %Again. so we must vectorize this. zeta=.qtest1. wn=5. % Force fo to be a column vector. we need two conditional matrices. after which %it levels o¤ at F=fo*te until in…nity. % The solution for t<te. % This constant is used for both parts. ((zeta*wn)^2wd^2)*sin(wd*t)).1.. x1=a1*(num1+num2).*cos(wd*(tte)phi)). x2=r+s..05. npts=1000. t=linspace(0.qtest1]. % This time. % Now. qtest2=t>te.q).*amult2. qtest1=t<te.*amult1+x2. wd=wn*sqrt(1zeta^2). % (3by1)*(1bynpts)=(3bynpts). the solution for t>te. x=x1. amult1=[qtest1. te=4. % num3 and num4 are scalars.qtest2. ’ )..tf..i) . for kr=1:3 fo(kr)=input(’ Enter a force magnitude (fo). phi=atan2(zeta.m %This program solves the ramp response of a %single degree of freedom system. amult2=[qtest2. ((zeta*wn)^2wd^2)*sin(wd*te)). r=a/q*(1exp(zeta*wn*(tte)). num3=te*(zeta*wn)^2+te*wd^22*zeta*wn. k=wn^2. % This gives a matrix of three 1bynpts solution vectors. end fo=fo(:). num4=exp(zeta*wn*te)*(2*zeta*wd*wn*cos(wd*te)+ . a unit system mass is assumed. a=fo*te/k. num2=exp(zeta*wn*t).91 % Program 111: rampfo.*(2*zeta*wd*wn*cos(wd*t)+ . s=a1*(num3+num4)*ones(1.
num2str(wn).’ fo=’ . seconds’ ) . num2str(fo(i)). .. ..x(i.92CHAPTER 12 RESPONSE OF SDOF SYSTEM TO RAMP INPUT plot(t.’zeta=’ .:)) title([’ Response for wn=’ .num2str(zeta)]) ylabel(’ Response x’ ) grid end xlabel(’ Time.
fo=3 zeta=0.5 0 0.5 0 1 2 3 4 5 6 7 8 9 10 Response for wn=5. seconds 7 8 9 10 Figure 12. . fo=26 zeta=0.93 Response for wn=5.05 10 Response x 5 0 5 0 1 2 3 4 5 6 Time.05 4 Response x 2 0 0 1 2 3 4 5 6 7 8 9 10 Response for wn=5.1: Response of a single degree of freedom system to di¤erent rates of loading.05 1 Response x 0. fo=7 zeta=0.
5 4 Figure 12.05 0.5 2 2. fo=7 zeta=0.05 Response x 0 0 0.5 3 3. seconds 3 3.94CHAPTER 12 RESPONSE OF SDOF SYSTEM TO RAMP INPUT Response for wn=5.5 4 Response for wn=5.5 1 1.5 1 1.5 2 2.5 1 1.2: Focusing on the …rst few seconds of oscillation.2 Response x 0 0 0.05 2 Response x 1 0 1 0 0.5 3 3. fo=26 zeta=0.5 Time.5 4 Response for wn=5. . showing that the system does oscillate during the transient period.5 2 2. fo=3 zeta=0.
and ! T = 2 : The coe¢ cients are obtained T by using the orthogonality properties of harmonic functions: Z an = 2 T 2 T T F (t) cos n! T tdt. : T =2 if m = n. 2. .Chapter 13 Response of SDOF Systems to Arbitrary Periodic Input An arbitrary periodic input can be thought of as any periodic input that cannot be expressed as a single sine or cosine function. n = 0. 1. 2 n=1 1 (13. a sum of sines and cosines is an arbitrary periodic input.1) where T is the period of the function. For example. 2. n = 1. ::: 0 bn = Z T F (t) sin n! T tdt. :::: 0 These coe¢ cients can be easily evaluated using the wellknown integrals: 8 <0 Z T sin n! T t sin m! T tdt = 0 95 if m 6= n. The most straightforward method to analyze the response to a periodic input is the Fourier series. A Fourier series representation of an arbitrary periodic function can take the form: F (t) = ao X + (an cos n! T t + bn sin n! T t) .
6 0.5 2 2.2 0.8 0.5 1 1.5 3 Time.96CHAPTER 13 SDOF RESPONSE TO ARBITRARY PERIODIC INPUT Sawtooth Wave 1 0.2 F(t) 0 0.4 0.5 5 Figure 13.6 0. Seconds 3. .8 1 0 0.1: Sawtooth wave to be de…ned by a Fourier series.5 4 4.4 0. One period is shown.
: T =2 if m = n. we obtain: bn = n n2 2 1 = 0: n The only nonzero terms that describe this wave are the an terms: (Z ) 2 an = T or T =2 0 4 t T 1 cos n! T t dt + Z T 1 T =2 4 T t T 2 cos n! T t dt . .3) Using Maple. we …nd that this reduces to: bn = 4 sin(n ) 2 sin(2n ) + n cos(2n ) n2 2 1 . sin(n ) = sin(2n ) = 0. As a demonstration. the evaluation of the Fourier coe¢ cients will become reasonable. T cos n! T t sin m! T tdt = 0: 0 Using these relationships. n where n is an integer. and cos(2n ) = 1: Thus.97 Z T cos n! T t cos m! T tdt = 0 8 <0 Z if m 6= n.1 shows a plot of the sawtooth wave for T = 5: The wave is de…ned by: 8 < F (t) = 4 T t 4 T 1 t T 2 for 0 for T 2 t t T 2 .2) T: 2 bn = T T =2 0 4 t T 1 sin n! T t dt + Z T 1 T =2 4 T t T 2 sin n! T t dt : (13. The Fourier coe¢ cients which de…ne this function are a0 = 0. (Z ) :1 (13. Figure 13.
5) To evaluate this expression using Matlab.4) Note that since n is an integer.m % This function returns the % Fourier representation for % a sawtooth wave having nterm % number of nonzero Fourier coe¢ cients. This program is written as a function. First. we would need to solve the vibrating system for each term of the in…nite series and superpose these results. The time span is presumed to be 5 seconds. sin(2n ) = 0 for all n: For even n. we plot the results for several numbers of terms to show the convergence. Then. To get di¤erent sawtooth waves. F=F+(8/pi^2)*cos(2*pi*n/T*t)/n^2. we would need to perform two simple steps. end . the program needed to perform this would be too long.2. This process is not compatible with Matlab. In Figure 13.500). if nterm<1 error(’ Number of terms must be a positive integer!’ ) end for i=1:nterm n=2*i1.F]=foursaw(nterm) % Program 1: foursaw. % Period of 5 seconds. an = 8=n2 2 : Therefore. an = 0: However. function [t. no such program is included here. one would have to either change T (to get a di¤erent period) or add a premultiplying factor (to change the amplitude). The program below shows that a few terms of the in…nite series can provide a very close approximation to the total series. to our desired level of accuracy. we would need to …nd a point where the terms of the series become negligible. For this reason. F (t) = 8 2 cos 2 1 6 1 10 t + cos t+ cos t + ::: : T 9 T 25 T (13.98CHAPTER 13 SDOF RESPONSE TO ARBITRARY PERIODIC INPUT an = 4 cos n 2 cos 2n n2 n sin 2n 2 2 : (13.5. F=zeros(size(t)). taking as input the desired number of terms in the Fourier series. % Getting odd values only. Such improvements are left to the reader. % as well as a corresponding time % vector (for ease in plotting). for odd n. % t=linspace(0. T=5.
6 0.5 5 Figure 13.5 2 2.4 0.8 0.99 1 1 term 3 terms 5 terms 10 terms 0.4 Sawtooth approximation 0.5 1 1. seconds 3 3.2 0.2 0 0.6 0. .5 Time.8 1 0 0. Note that 10 terms provide a very good approximation to the actual function.5 4 4.2: Four sawtooth approximations.
.
Then. the problem would reduce to two single degree of freedom Figure 14. of course. 101 . Assume that the system is as pictured in Figure 14.Chapter 14 Free Vibration of MDOF Systems The simplest multidegree of freedom system is. Applying Newton’ second law to s s each mass results in two governing equations m1 x1 + (k1 + k2 )x1 :: k2 x2 = 0 (14. for which we will consider free vibration in this example. the two degree of freedom system. it would be advantageous if we could …nd a coordinate system in which the equations were not coupled. To solve these equations.2) The motion of the masses are coupled.1: Typical two degree of freedom free oscillator. Note that we need two coordinates to de…ne this system’ motion.1.1) m 2 x2 :: k2 x1 + (k2 + k3 ) x2 = 0: (14.
From the solution of the motion in the decoupled modal coordinates. the initial displacement of each degree of freedom is 1.4 from 2 to n. we arrive at: :x . solving the eigenvalue problem) and normalizing the eigenvectors with respect to the mass matrix are unchanged.. For the …rst three …gures. the second mode is vibrating along a single sinusoid.3) :x . Let this matrix of eigenvectors be U .3. The following program. is capable of solving n degree of freedom free vibration through the modal analysis procedure outlined above. m1 = 1. Again. . Since the masses and sti¤nesses are not changing.4) The main bene…t of this procedure (from a MATLAB standpoint) is that it is easily extended to n degrees of freedom by changing the limit of the summation in Equation 14. and ! 2 = 1:700: For Figure 14. k1 = k3 = 10. and k2 = 2.2.e. : Let us denote the matrix multiplying x(t) = 2 X i=1 fugi fugi M x(0) cos ! i t + T 1 : T fugi M x(0) sin ! i t !i (14. since the . and x = 8 9 :: <x = 1 2 5 x = 0: (14. where ! i is the natural i frequency of mode i: 3. but the procedures for …nding them (i. Of course. As validation for this assertion. and initial conditions on the motion. The procedure of decoupling can be shown in matrix notation: 2 8 9 <x = 1 2 4 m1 0 0 m2 :: 3 5x + 4 :: :: 2 k1 + k2 k2 k2 k2 + k3 3 where x = :: x by M (the mass matrix) and the matrix multiplying x by K. and denote its columns (the eigenvectors) by fugi : 2. This is due to the di¤erence in mass between the two degrees of freedom. Find the eigenvalues and matrix of eigenvectors for the matrix K M. sti¤nesses. look at Figure 14. Recall that this is free vibration. modfree. which we have already solved. it looks like a single sinusoid. Notice how the second mode of vibration seems to show little evidence of the …rst mode. the natural frequencies for these cases will be identical: ! 1 = 3:480.102 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS systems. The modal analysis procedure may then be summarized as follows: 1. fugi K fugi = ! 2 = i . remember that the second mass is four times the …rst. This …gure has zero initial velocity as well.m. Normalize the eigenvectors with respect to the mass matrix through the T T products fugi M fugi = 1. we would also have n natural frequencies and eigenvectors. m2 = 4. instead of a sum of sinusoids. but the initial displacements are now 3 and – respec2. tively. The following …ve …gures show the results of di¤erent masses. zero initial conditions will lead to zero motion.
3 2 Figure 14. the initial velocity a¤ects the slope of the response curve at the starting point. we would expect the system to vibrate in both modes. but has no e¤ect on the qualitative aspects of the mode shapes. and the next is about 0. Finally. and the second is a sum. Note that both initial displacements were again 1. the maximum amplitude of vibration is increased for both modes. at least in the second degree of freedom. Figure 14.5.7 shows the result of changing the mass matrix to m = 4 3 0 5: 0 9 As a result.5.8 is readily apparent. the mass of 4 units is in the …rst degree of freedom. the symmetric behavior would no longer exist. the di¤erence between Figure 14.2. The natural frequencies become ! 1 = 2:150. This …gure was created by interchanging the masses. Notice how the …rst mode shape is now a single sinusoid. and k2 to 3 units. the mode behavior is as well. If we eliminated an initial displacement from the second degree of freedom. the di¤erence is 1 to less than 0. and ! 2 = 0:6154: Again.6 shows the e¤ects of adding an initial velocity to the system. However. the response of the …rst mode in Figure 14. that is. one peak reaches 1.7.2 matches that of the second mode in Figure 14. In Figure 14.8 shows the result of changing k1 and k3 to 1 unit. or on the natural frequencies.103 mass ratio is unchanged.2 and Figure 14.2. Also. . not a sum like the …rst shape. As Figure 14. this is the case. The curves look a little more “spread out” than those in Figure 14. This is due to the symmetric sti¤ness matrix. Figure 14. when compared to Figure 14. As a …nal proof of the e¤ects of the mass on the mode shapes.2. this is because the displacement of the second mass and its velocity are too small to impart any appreciable force on the …rst mass. As expected from a single degree of freedom system. and vice versa. the second mode shape is still a single sinusoid. and the mass of 1 unit is in the second.4 shows. the curves of Figure 14. Notice that the …rst mode only vibrates in one frequency this time. A peculiarity to this case is that the system is symmetric. look at Figure 14. A peculiarity that develops is that the …rst mass’ vibration comes in more s distinct peaks. and ! 2 = 1:131: These reduced natural frequencies are re‡ ected in the …gure.5. ! 1 = 2:014.7 have a lower frequency. If we change the value of either k1 or k3 .
*t)+u(:. end qu=0.q)). % clear.l]=eig(K.183. x=x+xt. if n~=o then error(’ matrix must be square!’ K ).104 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS Program 131: modfree.j)’ *M*x0*cos(w(j). if n~=o then error(’ matrix must be square!’ M ).*t)). t=0:0. x=zeros(size(n.m % This code solves ndegree of freedom free % vibration using the modal analysis techniques % of Section 7..1. % We need to scale them with respect to M.1:tf. % The output from “eig” gives unitlength eigenvectors.o]=size(K). end % Plotting the modes in a subplot format.s)/alfa. % for j=1:n w(j)=sqrt(l(j. tf=input(’ Enter the …nal time: ’ ).M).o]=size(M).s)’ *M*u(:..j)*(u(:. M=input(’ Enter the mass matrix: ’ ). the plots will become nearly % unreadable. % Using “eig” in this way allows us to subtract M*w^2 % from K. . instead of I*w^2 (where I is the n by n identity % matrix). [u. xt=u(:.s)). % Note that. [n. end K=input(’ Enter the sti¤ness matrix: ’ ). u(:.s)=u(:. % for s=1:n alfa=sqrt(u(:.j)). for more than 3 or 4 degrees % of freedom.j)’ *M*xd0/.1. xd0=input(’ Enter the initial velocity column vector: ’ ). [n. w(j)*sin(w(j).6. q=tf/0. end x0=input(’ Enter the initial displacement column vector: ’ ). % Applying Equation 7.
1.x(r.num2str(r)]).r) plot(t.:)) xlabel(’ Time. ylabel([’ Response x’ . seconds’ ). end .105 % for r=1:n subplot(n.
5 0 0. m 0. . seconds 20 25 30 Figure 14. m 1 0 1 2 0 5 10 15 Time.106 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS Response x1 1 Displacement.2: Response to initial displacement vector of [1 1].5 1 0 5 10 15 Response x2 20 25 30 2 Displacement.
seconds 20 25 30 Figure 14. m 2 0 2 4 0 5 10 15 Response x2 20 25 30 2 Displacement. . m 1 0 1 2 0 5 10 15 Time.3: Response after changing initial displacement to [3 – 2].107 Response x1 4 Displacement.
m 0.5 0 0.2 0 5 10 15 Time.4: Response after changing initial displacement to [1 0].2 Displacement.1 0 0.5 1 0 5 10 15 Response x2 20 25 30 0. seconds 20 25 30 Figure 14. m 0.108 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS Response x1 1 Displacement. .1 0.
m 1 0 1 2 0 5 10 15 Response x2 20 25 30 1 Displacement. .5 0 0. seconds 20 25 30 Figure 14.109 Response x1 2 Displacement.5 1 0 5 10 15 Time.5: Response after interchanging system masses. m 0.
m 1 0 1 2 0 5 10 15 Response x2 20 25 30 2 Displacement. m 1 0 1 2 0 5 10 15 Time. seconds 20 25 30 Figure 14.6: Response with initial velocity [4 2] and initial displacement [1 1]. .110 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS Response x1 2 Displacement.
7: Response with increased system masses. m 1 0 1 2 0 5 10 15 Time. .111 Response x1 1 Displacement.5 1 0 5 10 15 Response x2 20 25 30 2 Displacement. m 0. seconds 20 25 30 Figure 14.5 0 0.
8: Response with reduced system sti¤nesses.5 0 0.112 CHAPTER 14 FREE VIBRATION OF MDOF SYSTEMS Response x1 1 Displacement. m 0. . seconds 20 25 30 Figure 14.5 1 0 5 10 15 Response x2 20 25 30 2 Displacement. m 1 0 1 2 0 5 10 15 Time.
it is possible to follow the previous decoupling procedure. While proportional damping is something of a savior for modal analysis. as shown in Figure 15. it presents a headache when programming. The equations of motion become: m1 x1 + (c1 + c2 ) x1 :: : c2 x2 + (k2 + k1 ) x1 : k2 x2 = 0 (15. a scalar multiplied by M or K will also be diagonalized. there is no guarantee that the equations will decouple by the procedure used earlier. K = 4 1 where M = 4 0 m2 c2 c2 k2 :: : k2 k2 3 5. and we will examine the changes caused by this addition.2) M x + C x + Kx = 0. This is because both K and M are diagonalized through the matrix of eigenvectors U . viscous damping is added to the system. The only way to assure decoupled equations in a program is to specify Cm and Ck instead of entering the matrix 113 . However. C = 4 5. As we know.1) m2 x1 + c2 x2 In matrix form. Now.1. the free response of systems having more than one degree of freedom was discussed.e. i. with damping present.Chapter 15 Damping of MDOF Systems In the previous example. 3 2 3 2 2 m1 0 c1 + c2 c2 k + k2 5. for proportional damping.. C = Cm M + Ck K. we obtain: :: : x1 + k2 (x2 : x1 ) = 0: (15. Thus. and the sum of two diagonal matrices is also diagonal.
2. the equations of motion in the modal coordinates become: q i + 2 i ! i q i + ! 2 qi = 0. and ! i represent the natural frequencies of each mode.3) where q is the modal coordinate variable. : : : . the modal damping ratios are automatically decoupled. the most e¢ cient way to handle damping is through the modal damping ratios (though the program given below retains some ‡ exibility by allowing entry of the modal damping ratios or the factors Cm and Ck ). when programming.1: Two degree of freedom damped oscillator under consideration here. This is the same as for the damped single degree of freedom oscillator. So. whose solution was: qi (t) = Ai e i !i t sin(! di t + i ). the program may run through a signi…cant amount of calculation to deduce that the given data is invalid. where i is the number of the mode being examined. The modal damping ratios are simply an analogue for the damping ratios we saw earlier in our study of single degree of freedom systems. This wastes time and e¤ort. and then check it for diagonality.4) q 1 2 i ). For the second algorithm. Calling the modal damping ratios i . or to take the matrix C.114 CHAPTER 15 DAMPING OF MDOF SYSTEMS C into the program. Both of these methods have ‡ aws. the person using the program may not know Cm and Ck at all. i = 1. where ! di is the damped natural frequency of that mode (! i " #1=2 and Ai = q io + : 2 i ! di qio !2 di + (qio ! di ) 2 (15. . (15. go through the …rst two steps of modal analysis with it. i :: : (15. in the …rst case.5) Figure 15. They are called modal damping ratios because they are applied independently to each modal (decoupled) equation. and they may be di¢ cult to calculate. especially if the data is invalid due to an error in entry of values.
. demonstrates this approach. due to the smaller damping ratios. note that both responses show the e¤ects of multiple sinusoids. Having obtained the solution for q(t). 1 = 0:05. In Figure 15.4 removes the velocity and changes the initial displacement to [2 1]. k1 = 24. Finally. and so the smaller mass can e¤ectively transfer its momentum to the larger. Finally. and the result is no increase in the transient period (as expected). but the same length of transient period as Figure 15. used to generate the …gures that follow. Figure 15. the response gradually dies out.3.2 through 15.2 is that here the responses have a greater amplitude and a larger transient period. Figures 15. we then use the last step of the modal analysis procedure to …nd x(t): Note that this method uses the entire modal analysis procedure as if damping did not exist.115 i : = tan 1 qio ! di . and then adds in the damping when solving for qi (t): The program at the end of this example. but an increase in amplitude.4 use m1 = 9. and the results show the e¤ect of the damping. : q io + i ! di qio (15. Figure 15. respectively. and the result is a greater amplitude. even though the …rst mass is much greater than the second.3.6) noting that qio and q io refer to the initial displacement and velocity in the modal coordinate. this sti¤ness keeps the mass from gaining too much velocity. and 2 = 0:1: Figure 15. an initial velocity of [3 2] is added. k2 = 3. m2 = 1.2 uses an initial displacement vector of x0 = [1 0]. This is because the …rst sti¤ness is very large.5 changes the damping ratios to 1 = 0:07 and 2 = 0:03: The di¤erence between this …gure and Figure 15. In all three …gures.
Cm=input(’ Enter the factor Cm: ’ ). end % Giving the option to input damping via % modal damping ratios or through the multiplying % factors Cm and Ck. end qu=0. if n~=o error(’ matrix must be square!’ K ). xd0=input(’ Enter the initial velocity column vector: ’ ).o]=size(M). ’ ). tf=input(’ Enter the …nal time: ’ ). [n.o]=size(K). if qz==1 for iz=1:n zeta(iz)=input([’ Enter the damping for mode ’ .116 CHAPTER 15 DAMPING OF MDOF SYSTEMS Program 141: moddamp.s)’ *M*u(:.num2str(iz). instead of I*w^2 (where I is the n by n identity % matrix). % We need to scale them with respect to M. ’ ) qz=input(’ anything else to enter Cm and Ck. % clear. M=input(’ Enter the mass matrix: ’ ). end else fprintf(’ Given that [c]=Cm[M]+Ck[K]. [u.l]=eig(K. ’ or ).m % This code solves ndegree of freedom damped % vibration using the modal analysis techniques % of Section 7. Ck=input(’ Enter the factor Ck: ’ ). % fprintf(’ Press 1 to enter modal damping ratios.M). end x0=input(’ Enter the initial displacement column vector: ’ ). % for s=1:n alfa=sqrt(u(:. .6. % Using “eig” in this way allows us to subtract M*w^2 % from K.’ ’ : ]).s)). % The output from “eig” gives unitlength eigenvectors.s)=u(:. u(:.3. if n~=o error(’ matrix must be square!’ M ). [n. end K=input(’ Enter the sti¤ness matrix: ’ ).s)/alfa.
end wd(j)=w(j)*sqrt(1zeta(j)^2). % If modal damping ratios were entered.5*(Cm/w(j)+Ck*w(j)).117 t=0:0.:)=x(i.*exp(zeta(i)*w(i). xt=u(:.x(r.j)).*t). If not. q=tf/0..j)’ *M*x0*cos(w(j). we already have % a zeta vector..j)’ *M*xd0/.q)). seconds’ ).r) plot(t.*t)/wd(j)). % if qz~=1 zeta(j)=0. x=zeros(size(n. ylabel([’ Response x’ .1. w(j)*sin(w(j).j)*(u(:. we need to calculate from Cm % and Ck. end for r=1:n subplot(n.:)) xlabel(’ Time.:).1:tf. for j=1:n w(j)=sqrt(l(j. x=x+xt.*t)/sqrt(1zeta(j)^2)+u(:. end for i=1:n x(i.1.num2str(r)]). end .
5 1 0 5 10 15 Response x2 20 25 30 2 Displacement. . m 1 0 1 2 0 5 10 15 Time.2: Damped response of a two degree of freedom system. seconds 20 25 30 Figure 15.118 CHAPTER 15 DAMPING OF MDOF SYSTEMS Response x1 1 Displacement. m 0.5 0 0.
m 1 0 1 2 0 5 10 15 Response x2 20 25 30 4 Displacement. m 2 0 2 4 6 0 5 10 15 Time.119 Response x1 2 Displacement. .3: Response of a damped 2DOF oscillator after adding an initial velocity. seconds 20 25 30 Figure 15.
4: Response of the same system to a di¤erent initial displacement.120 CHAPTER 15 DAMPING OF MDOF SYSTEMS Response x1 2 Displacement. m 1 0 1 2 0 5 10 15 Response x2 20 25 30 4 Displacement. seconds 20 25 30 Figure 15. . m 2 0 2 4 0 5 10 15 Time.
121 Response x1 1 Displacement.5 0 0. . seconds 20 25 30 Figure 15. m 0.5 1 0 5 10 15 Response x2 20 25 30 2 Displacement. m 1 0 1 2 0 5 10 15 Time.5: Response of the 2DOF system with di¤erent modal damping ratios.
.
and can represent any number of degrees of freedom. Additionally. the matrices cannot be created beforehand. because the clear statement will remove some variable that will be needed later. While this method is e¤ective. This line assigns a variable to the number of degrees of freedom. no matter what the forcing function or number of degrees of freedom. MATLAB will think the mass matrix is to be 2 by 2. This way. The …fth element entered would set o¤ an error 123 . The …rst major step in achieving this goal is the …rst line of the code. it is not e¢ cient by any stretch of the imagination. We need a general program to be as modular as possible so that any changes that need to be made between runs of the program (like changing the masses or the sti¤nesses) can be done without editing the code. demonstrates this method.Chapter 16 A Universal Vibration Solver The next logical step in this sequence of examples would now be to introduce forcing functions of di¤erent types (as seen earlier with the single degree of freedom cases). This is done in lieu of a clear statement. the user need only enter the variable name. MATLAB will think the variables are to be the size that they are already. ndofold. The best way to proceed from here would be to create a program that solves all vibration cases. sti¤ness. Some techniques used in this program demonstrate ways to make a program modular.m. The tradeo¤ in not using clear is that MATLAB must be told how large the matrices are to be. and other matrices. The simplest way to go about this is to begin with a general program that does not include the external force. If clear is used. not the entire matrix. in any loops or assignment statements made afterward. when the program prompts for these later. not using the clear command has the advantage of allowing the user to assign variable names to the desired mass. The next several lines initialize the variables needed later. Program 1. if these sizes are not speci…ed. and we had just previously solved a 2DOF system. and create several di¤erent programs. If we are now solving a three degree of freedom problem. this variable can be referred to. This way.
The program does not automatically print the graphs because they may be incorrect or uninteresting. to a …le. ’ or ). a loop could be created at the beginning of the program to allow the user to specify whether output goes to the screen only. modifying the program to specify printing would take a few seconds (replace pause with print in the code). The command used …lls each matrix with zeros. imagine the headache that would be involved if the program had not prompted for n earlier. to the printer. a change would have to be made to allow a di¤erent number of degrees of freedom to be analyzed. the program prompts for each matrix that will be needed. or 3!!!’ ) %Direct and to the point. Having the necessary information. Note how the variable n is used throughout this portion. This maintains the generality of the program. After the initialization section. So. % if outp~=1&outp~=2&outp~=3 %Translation: “If outp isn’ equal to 1. or to a combination of the three. outp=8. and you will understand why a subplot cannot be guaranteed. 2. A sample of such a loop follows here: %This loop allows the user to specify the nature of the output. nn’ ) outp=input(’ 3 to print to the printer. .” t %“~” means “not” for a MATLAB logical statement. %Also. Each time an n appears. and %to thwart those who love to crash programs. %Notice how the text was split across two lines by using %the fprintf statement. and prints out the output. This allows the text for input %statements to be as long as needed. %Notice how the loop assumes that the user will enter the %wrong response. allowing the user to specify with the …rst input how large the matrices will be. the program initializes the variable right before the loop %to the value necessary to continue the loop.124 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER message. 2 to print to a …le. %and the ampersand (&) is “and” as usual. 2. %This is where we let the user know he’ made a mistake. Note how each calculation is done in loops that run from 1 to n. Notice also that the plots are put up one at a time. This is done because there is no way to guarantee a subplot of any number of columns will be readable. . the pause command is implemented after each plot to allow the user to examine each plot to his satisfaction and to get a printout of the plot before the next one comes up (a printout can be obtained from the graphics window in MATLAB for Windows only). this is a harmless way to initialize variables. the program then solves the system by modal analysis. while outp==8 fprintf(’ Enter 1 to print to the screen only. and to print them in such a case would be a waste of time and paper. or 3. this is to correct for any mistakes. s fprintf(’ Enter 1. Imagine a forty degree of freedom system. Also. However.
The problem of order is really not a di¢ culty at all. there’ the loop! It’ not long (without the comments). there is a method by which a secondorder di¤erential equation can be transformed into a system of 2 …rstorder equations. you need to put the following into the printout loop (where the pause is now): if outp==2 %“==” in MATLAB is “equals” to you and me. we need to go back to the drawing board and …nd a simpler method. MATLAB has …le transfer protocols. %A common mistake is to leave one out. and it’ e¤ective.) So. Also. and then %MATLAB tells you that it came to the end of the %…le in the middle of a loop. print dps …le1. the user would have to create his own function M…le each time. Now. So. . This task. % outp=8. these di¤erential equations must be …rstorder. which solves di¤erential equations numerically for a given time interval and initial conditions. since we need the loop to continue. end end %One “end” for the “if” and one for the “for” . needing its own end. unless a general M…le can be created. Another common mistake. this command requires that the di¤erential equations exist in a function M…le which de…nes the system of di¤erential equations. if” as a new if statement. Fortunately. possibly not. So then where would be the use of a program? The answer lies in automating the process of creating an M…le. like any other programming language. possibly coupled. One more thing: to get this to work. which would then be used for ode45.ps elseif outp==3 print elseif outp==1 pause end Note that if you type “else if” instead of “elseif” MATLAB reads the “else . The …rst thing to realize is that the di¤erences among the several possible vibration cases occur in solving the di¤erential equations. Unfortunately. (Not a pleasant feeling. However. We can write a program that tells MATLAB to create a speci…c M…le from a general procedure .125 %Now. outp is reset to the value needed to continue the %loop. Every problem in vibrations begins as a set of secondorder di¤erential equations. is nearly impossible to do in a general way with the algorithm selected. s s s It can be expanded as much as necessary to allow for any combination of printing options. MATLAB has the ode45 command. it’ just a matter of adding forcing functions to the mix. s however.
and the inputs are obtained. Now that the program has the original values of the mass. This can be done because the damping ratio vector that the user enters is related to the diagonal of the decoupled damping coe¢ cient matrix. it is possible to use the value of a variable in an fprintf statement. the functions de…ning the external forces on each degree of freedom are entered individually. This loop changes the damping ratios into damping coe¢ cients. After this. we would have no way to access it. or how many elements the matrix would have. and damping coe¢ cient matrices. this is because. Since this damping coe¢ cient matrix is decoupled. and the read/write privilege desired (‘ w+’means ’ write and overwrite.’which allows a user of this program to make several runs in succession without erasing the M…le previously created. if the brackets are not included. but not as text.126 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER we write into the program. so that MATLAB knows to write the text to the …le speci…ed earlier. if all the external forces were entered at once. Each statement begins with the …le identi…cation number. MATLAB thinks the statement ends when the quotes are closed. and then solve the resulting system of di¤erential equations with ode45. The method used in the program avoids these di¢ culties. Note that to use the num2str command. the program uses an fclose statement to tell MATLAB that nothing . and no way to write to the …le. Finally. The reason that we need this identi…cation number is shown by the fprintf statements that follow the fopen command. The next set of commands are initiated if a damping ratio matrix was entered. we know that these can be decoupled. If the …le identi…cation number was not set equal to a variable. Again. the text to be printed must be within brackets as well as parentheses. The fopen command is set equal to a variable because the command speci…es an arbitrary number by which MATLAB identi…es the …le. the M…le can be created. This command allows the value of a variable to be used in a text statement as text. ndof. not to the screen. the program begins by specifying the number of degrees of freedom for the run. The strings in parentheses by the command specify the …lename. So. Notice the use of the num2str command within the fprintf statements. there would be no way of telling how long the force variable would be. so that this number will be stored in an accessible place. performs this task. Program 2. and will produce an error instead of including the desired value of the variable. by reversing the modal analysis procedure. sti¤ness. The program …rst opens the …le with the fopen command. the previous M…le is lost). in order to …nd the natural frequencies. This is necessary because a text string entered into a MATLAB variable is stored one character per matrix element. The only way to get this number is by setting fopen equal to a variable. it can be transformed from the modal coordinate system (the decoupled coordinate) back to the original coordinate system by applying the reverse of the modal analysis procedure. the program performs the …rst few steps of modal analysis. Next.m. We can do this because the natural frequencies only depend on the mass and sti¤ness matrices. The necessary matrices are initialized.
m2 = 1. and then settles into a steadystate response based on the single forcing function. verify that the program works. The plots come printed individually. and solves. So. The natural frequencies calculated by the program are ! 1 = 1:41 and ! 2 = 2:00. k2 = 3. c1 = 2:7. Now. the responses of each mode are found through manual calculation to be: x1 (t) = 0:2451 cos(2t + 0:1974) 0:6249 sin(2t) (16.1 and 16. F2 = 3 cos 2t: Notice how each degree of freedom shows the transient response over the …rst two seconds.2) Looking at the maximum magnitudes of the responses shown in Figures 16.1) x2 (t) = 0:7354 cos(2t + 0:1974) + 1:8749 sin(2t): (16. because MATLAB indicates a successful write transfer through the fclose statement. c2 = 0:3. Each …gure represents a degree of freedom of the system. as we would expect.127 else is to be entered into the …le. we see that they are approximately equal to the sum of the coe¢ cients of the sine and cosine terms in the expression above. Figures 16. more importantly. a print loop similar to the one described above can be inserted into this code to allow printing to a printer or to …les. we see the power of the program and. This is set equal to a variable. which match those calculated by hand. Also. whose parameters are as follows: m1 = 9.m.2. the program takes initial values necessary for ode45.1 and 16. from this example. k1 = 27.2 show the results of using ndof. F1 = 0. a user can tell if the …le was written successfully by seeing the value of this variable. .
’ ).128 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER Program 161: ndofold. r(k.(rp0(k)+zeta(k)*w(k.m %This program calculates the damped response of %multidegree of freedom systems without external forcing.k)*r0(k). ’ ). wd=zeros(size(w)). tf=input(’ Enter the …nal time. ac=zeros(1.b2). si=inv(s).n). rp0=zeros(n. l=zeros(n. x=zeros(n. w=sqrt(l). end %Note that the same loop control variable can be used for %every loop. s=zeros(n. [p. t=ti:(tfti)/1000.b2). ti=input(’ Enter the initial time.k)^2*r0(k)^2+(rp0(k)+zeta(k)*w(k. %The user must enter the modal damping ratios.k)*r0(k))^2)/wd(k. ’ ). p=zeros(n. r=zeros(n.k)*sqrt(1zeta(k)^2). m=zeros(n. phi(k)=atan2(wd(k.*sin(wd(k. phi=zeros(1.n).1). s=a*p.k)*t+phi(k)). for k=1:n wd(k. so long as the loops are not nested within %each other. for k=1:n ac(k)=sqrt(wd(k.n). m=input(’ Enter the mass matrix.k).b2]=size(t). rp0=si*xp0’ .:)=ac(k)*exp(zeta(k)*w(k.k)*t). ’ ). k=zeros(n. ’ ). r0=si*x0’ .n). r0=zeros(n. ’ ). zeta=input(’ Enter the damping ratio (zeta) matrix.k)*r0(k))). ko=input(’ Enter the sti¤ness matrix. n=input(’ How many degrees of freedom are present? ’ ).n). end . no other %method of describing damping is supported.l]=eig(kt).1). a=m^(1/2). x0=input(’ Enter the initial displacements.k)=w(k.n). xp0=input(’ Enter the initial velocities.tf. ’ ). kt=a*ko*a.n). [b1.
’ ). aw=2. else fprintf(’ Please enter 0 or 1.zt).5).n). This algorithm allows %any external force combination to be examined. while aw==2 fprintf(’ Press 0 to enter a damping coe¢ cient matrix.2*n). m=input(’ Enter the mass matrix. end end k=input(’ Enter the sti¤ness matrix. or’ ) aw=input(’ press 1 to enter a damping ratio (zeta) matrix. ’ ). %and also allows the external force to be %a userde…ned function.zt)=zeta(zt)*2*omega(zt. omega=sqrt(q).k)) end Program 162: ndof. ’ ).m %This program. a=m^(0. writes its own %M…le to use in ode45. elseif aw==1 zeta=input(’ Enter the damping ratio matrix. title([’ Response x’ .k. as stated above.q]=eig(kt). ’ ). ’ ). [p. if aw==0 c=input(’ Enter the damping coe¢ cient matrix. kt=a*k*a.’ ) aw=2. x=zeros(1. n=input(’ How many degrees of freedom are present? ’ ).o]) xlabel(’ Time.x(k. .w(k. clg for k=1:n plot(t. ct=zeros(n.129 x=s*r. seconds’ ) ylabel(’ Displacement’ ) grid …gure(gcf) pause end for k=1:n fprintf(’ Natural frequency w%g=%g nn’ .:)) o=num2str(k). if aw==1 for zt=1:n ct(zt.
tf.’ ]).num2str(i2).i)).[’ pdx(’ .kl+n).l)) end .ny(:.num2str(i2+n).’ ]). end for i2=1:n fprintf(…d.x0].nn’ ]).’ )=x(’ . c=af*ct*af.130 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER end af=a^(1). for i=1:n fprintf(…d. ’ ).num2str(i). for j=1:n if k(i.omega(l. )’ end if c(i. init=[v0. m’ ).j)==0 else fprintf(…d.num2str(c(i.’ ))/(’ . x0=input(’ Enter the initial displacements as a row vector. end status=fclose(…d).’ ). . seconds’ ).’ ).num2str(j+n). ti=input(’ What is your initial time? ’ ).num2str(k(i.ti.num2str(i). grid …gure(gcf) pause end for l=1:n fprintf(’ Natural frequency w%g=%g.ny]=ode45(’ pdx’ .nn’ ]).[’ pdx(’ .init). )’ end end f=input([’ Enter F’ . fprintf(…d.[’ )+(’ . nn’ .j)==0 else fprintf(…d. ’ )=((’ ]).num2str(kl)]). v0=input(’ Enter the initial velocities as a row vector.l.x)nn’ ). ]). tf=input(’ What is your …nal time? ’ ).num2str(m(i.’ ).’ (’ )*x(’ . for kl=1:n plot(t.j)). [t.num2str(j). b’ title([’ Response x’ . ’ ). ’ in quotes.’ function pdx=pdx(t. end …d=fopen(’ pdx.num2str(f).[’ .m’ ’ ). w+’ fprintf(…d. ylabel(’ Displacement. like ‘ (t) 3*cos(2*t)‘ ’ .j)). xlabel(’ Time.’ +(’ )*x(’ .[’ .
131 Response x1 0. .1: Response of the …rst mode.6 0. m 0.6 0.4 0.2 0 0.8 0.8 0 2 4 6 8 10 12 Time.4 Displacement.2 0. seconds 14 16 18 20 Figure 16.
5 0 2 4 6 8 10 12 Time.5 2 1.5 0 0. m 0.5 2 2.5 1 Displacement. seconds 14 16 18 20 Figure 16.5 1 1. .2: Response of the second mode.132 CHAPTER 16 A UNIVERSAL VIBRATION SOLVER Response x2 2.
and so is an attractive (and necessary) feature of the model.Chapter 17 Modeling a van der Pol Oscillator The next several examples will examine how we can use Matlab to solve for more realworld vibratory systems. we will not be able to arrive at an analytic solution. Examples of such structures include the support pylons of o¤shore oil platforms and antennae attached to the exterior surfaces of aircraft. _ e>0 (17. What we will be forced to do. instead • of removing it.1) as a model for the motion of such a structure. we must solve the nonlinear ordinary di¤erential equation given above. when jxj > 1. This impression is correct.2. given the positive parameter e. when the only 133 . Why would we use a program that was designed for a general case. then. Unfortunately. in Section 2. The …rst such system we will look at is the oscillatory motion of a structure surrounded by a ‡ uid. At …rst glance. These structures exhibit vibratory motion due to the creation of vortices in the ‡ by viscous interaction between uid the structure and the particles comprising the ‡ uid. as we did with several of the earlier problems we examined.4.) We will demonstrate how we can use Matlab to help us visualize the solution to such a problem. having many varied inputs. x + e x2 • 1 x + x = 0. the damping term would add energy to the system. the term multiplying x will become negative. If we were to _ solve for x. then. This negative damping approximates some of the phenomena observed in such ‡ uidstructure interactions. but to use such a program would be wasteful. is to integrate the equation analytically over a particular time interval. it appears that we should be able to use a program like the general solver in the previous example. First. (The text gives a brief discussion of this problem as well. Several investigators have applied the van der Pol equation. exhibits the usual form of damping when jxj < 1: However. Note that this equation.
the initial conditions. Global variables should be used with caution. Program 1 is the main function. To assign these default values. but that would uneccessarily clutter the workspace with variables. we test the value of nargin three times. one at the start of the main function. (We will explain why we do not simply make e into a global variable in a moment. as they allow parameters inside of a function to be changed transparently (for example. we allow as few as zero inputs to be passed to the function. and the time step? The trouble then becomes. and Program 2 is the function used by ode45 to solve the equation. Also note that there are no semicolons at the end of these statements. so that it can be passed freely between the main function and the function evaluating the van der Pol equation. we could write Program 2 to adjust the value of e. We de…ne the function to take three inputs. why did we go to the trouble of introducing a spare parameter e_g to . and is considered poor technique. The reader is invited to recast the nargin processing portion of this program to use the switch operator. the function uses only the default time span. but by using nargin. If the number of arguments is two. and not in the parent function. we need not remember to pass in the same initial conditions and time span. We can use the default values provided by the function in each case. and one at the beginning of the function used by ode45. e¤ectively defeating the input value). We could de…ne every variable we use as global. Note that there are two global statements in the programs below. if we’ re only interested in looking at the e¤ects of changing the parameter e. evaluating how many input arguments have been passed into it (you can think of it as Number of ARGuments INput). We also introduce the nargin statement with this program. This allows our function to be quite ‡ exible. (Experienced C programmers may be wondering why we chose three if statements instead of a switch statement. and see how the program changes. the three if statements provide all of the default input data. there is no output to suppress. providing default values for each input parameter. adding in an extraneous third parameter will lead to errors. so semicolons are unnecessary. If this value is zero. We will make e_g into a global variable. not even the global variable e_g remains in the workspace after function termination. We are then able to use e_g in the subfunction as if it was assigned there.) This is illustrated in the code below. If it is one. how are we going to allow the parameter e to be dynamically assigned to the function in question? Our answer will come from Matlab’ global variable capability. The bene…t of creating this van der Pol solver as a function is that the only variables created in the workspace are the outputs t and x. so we can demonstrate another useful technique to generalize Matlab functions.134 CHAPTER 17 MODELING A VAN DER POL OSCILLATOR parameters we will have to use here are the parameter e. the function uses the default values for the initial state and the time span.) Our trick to make this function work is to declare the parameter e_g as global. This command reads the input to the function. after initializing e_g to the value of e: This construction is needed because the function to be evaluated by ode45 must be a function of the state and the time. We will also de…ne our van der Pol s oscillator solver as a function. Now.
and not by the initial conditions. so it is not periodic s in the same regular way as the sine or cosine function. then the velocity is described by y = cos (t) : If we were to plot this result in phase space. The reader is encouraged to try di¤erent initial conditions to see that the limit cycle is indeed a universal of the system. generating the Matlab warning. in spite of the di¤erent initial conditions. thus. and the …nal point by a triangle. we would arrive at a circle.” like in the program below. these functions x (t) . we will set apart our global variables with a trailing “g. which are plots with the velocity on the yaxis and displacement on the xaxis. However.2 1 Also 2 However. this initial point ([ 1. Thus. and then sees the same variable declared as global later. However. This limit cycle behavior is similar to a phenomenon seen in the vibration of structures in a moving ‡ uid. That means that our global variables will not be used before they are declared. changing the parameter e will certainly change the form of the limit cycle in . [ 1.135 be our global variable? The answer comes from how Matlab handles its global variables. The other two …gures that follow are phase diagrams 1 . Figure 17. Note that the initial location is denoted by a circle. it will repeat the same sets of positions and velocities.” This is because Matlab sees the variable e that is input to the function as a variable local to the function.” this author thinks it prudent to write his code in a way that will be forwardcompatible. the motion settles into the same limit cycle. we see oscillatory behavior. Since the tail end of the warning includes the ominous statement “Future versions of Matlab will require that you declare a variable to be global before you use that variable. The two …gures below show some results for the default case (as de…ned in Program 1). y (t) are parametric equations for a circle. the limit cycle is determined by the parameter e. x] = solvevdp (0:5. you would …nd no trouble for the default case (no input arguments). and the …nal state by a triangle. We can prove to ourselves that a closed loop in phase space corresponds to an oscillating response by considering the function x = sin (t) : If we take this (obviously oscillating) function as our displacement.2 is the closed loop. called phase portraits by some authors. Matlab would print a warning statement saying that the value of your local variable (e) “may have been changed to match the global. Note that. In general.1 shows a simple comparison of displacement versus time. where possible. 5]) : Again. since they can clearly show the e¤ects of initial conditions on the response. The van der Pol oscillator’ loop is not precisely circular. we used the command [t. The key feature of Figure 17. 5]) is denoted by a circle. These diagrams are often used in studies of nonlinear and chaotic systems. The curious reader is encouraged to rewrite the code to use e as a global parameter. The closed loop means that the van der Pol system eventually settled down into oscillatory behavior. several investigators have used the van der Pol equation to describe these systems. If you were to change e_g to e in the given code. Figure 17. if you called the function with a speci…c value of e.3 is the same default system with di¤erent initial conditions.
% dx(1. Our state vector x consists of % the variable x and its time derivative.tspan) % Program 1: solvevdp.x]=solvevdp(e.tspan.x]=ode45(’ dxvdp’ . where primes denote % di¤erentiation in time. function dx=dxvdp(t. The function % will automatically assume x(0)=1. dx(2. end if nargin<3 tspan=[0 30]. phase space. We need to set up the % secondorder di¤erential equation as a system of two % …rstorder equations. x’ (0)=0 % and a thirtysecond time interval (tspan=[0 30]) % if these values are not provided. Also. global e_g if nargin<1 e=0. a % value of e=0.5.1)=(e_g*(x(1)^21)*x(2)+x(1)). end e_g=e. if nargin<2 x0=[1 0].m % This function takes in a value for e in the % van der Pol oscillator expression. % x” +e(x^21)x’ +x=0.x). global e_g % Program 2: dxvdp.136 CHAPTER 17 MODELING A VAN DER POL OSCILLATOR function [t.1)=x(2). .x0. % [t. end % An “if” statement on a single line. % % O¤ to the ode solver.5 is assumed if none is given.m % This is the function called on by ode45 to provide the % derivative of our state vector x.x0).
5 0 5 10 15 Time 20 25 30 Figure 17.5 2 1.137 2.5 Displacement 0 0.5 1 1.5 2 2.5 1 0.1: Displacement vs. . time curve for the van der Pol oscillator under the default conditions of Program 1.
5 0 Displacement 0.5 2 1.5 Figure 17.5 1 1.5 1 1.5 2 2. .5 1 0.5 2.2: Phase diagram for the van der Pol equation.5 2 1.5 1 0.138 CHAPTER 17 MODELING A VAN DER POL OSCILLATOR 2. Note the closed limit cycle.5 2 2.5 Velocity 0 0.
139 6 5 4 3 Velocity 2 1 0 1 2 3 3 2 1 0 1 Displacement 2 3 4 Figure 17. .3: Phase portrait of the same van der Pol oscillator with di¤erent initial conditions.
.
or both? If we are modeling a given physical system. That is. That is. let us have a look at the distributions available inside Matlab. let us look at a sinusoidal forcing input of the form F (t) = A cos (!t) : We …rst need to determine how we will introduce randomness to this system. we will not be looking for the response statistics at this time. Our aim here is to show how Matlab can be used as an aid in modeling random processes. a random frequency. a Gaussian distribution. we may have derived the power spectral density of a typical input to our system. which we will later use to arrive at the response statistics numerically. 2 In general. will we apply a random force amplitude. we will …nd that this question often answers itself. will we use a uniform distribution.2 Having determined the parameter we will consider to be random. we will arrive at sample response realizations. we would also have a random phase angle associated with this forcing. we could then (as a …rst approximation) treat the forcing frequency as deterministic. For example. 1 Following the example of the textbook. For this case.1 The logical starting point for this e¤ort is to show how we can create random forcing histories to apply to a deterministic model.Chapter 18 Random Vibration and Matlab The focus in the text is probabilistic modeling of forces in vibrating systems. We omit the phase angle here for simplicity of analysis. we need to arrive at a probability density function for our this parameter. we will limit ourselves mainly to random forcing of deterministic systems. and thus in visualizing the response of systems subjected to random forcing. and found that the vast majority of the energy input to the system comes at one particular frequency. Unlike the problems posed in the text. To illustrate some of the challenges associated with a random forcing input. or some other description? Before we decide this. contrasting the analytic approach taken in the chapter. and use a random distribution for the amplitude. instead. 141 .
and initialize the state to sum(100*clock). two of which produce sparse matrices. This will reset the random number generator based on the current time. Note that Matlab’ random numbers are actually s “pseudorandom” that is. or 1000 elements if the input tspan is shorter. let us look at the system described by x + 2 ! n x + ! 2 x = F (t) • _ n (18. For some .0]. we will solve for the steadystate response only.4 Both methods are useful for di¤erent cases. . we will interpolate linearly between neighboring values of A corresponding to the two elements 3 There also exist three other commands. Recall from the last example that we used less than statements instead of a switch expression to de…ne parameters. while the third gives a vector with a random permutation of the …rst n integers. containing the current year. We can use the results of the analysis we did earlier. This is because expression cases of a switch in Matlab do not require a break statement to end each expression set. We’ do the latter in this case. neglecting the transient response. month. the values of t that it will test are not necessarily the same as the values in tspan: Thus. (This also eliminates the need to specify initial conditions.3 Typing a=rand(n) at the Matlab prompt will return an n n array of randomlygenerated numbers in a. minute. respectively. or we can use the numerical integration routines. like we could in C. Thus. we cannot allow cases for lower numbers of input arguments to “fall through”to higher numbers. When Matlab integrates our di¤erential equation.1. we use the nargin function to allow any number of input parameters from zero to the maximum of …ve. giving an analytic solution. and to show how we can handle the discrete datapoint set. We also set the length of the amplitude vector A to be the same as the length of the tspan vector. the clock command returns a sixelement vector. We do this to make interpolation of A based on values of t simpler.142 CHAPTER 18 RANDOM VIBRATION AND MATLAB The uniform and Gaussian distributions are built into Matlab through the rand and randn commands. using a uniform distribution on the interval [0. For instances like this. applications.8.) We can solve for the steadystate response in two ways using Matlab. Thus.0. Any other probability distributions would have to be derived from the two described above or created from scratch by the user. Following the lead of Section 4. unlike the C analogue. These are not useful to us here. we can use the suggestion available in the Matlab help for rand. The randn command returns a random number from a Gaussian distribution having a mean of zero and standard deviation of one. If we want to ensure that we get a di¤erent realization each time. to ll show how we can transport the amplitude values back and forth where they are needed. hour. 4 Speci…cally. day. we can use the state of the random number generator to subject each comparison case to the same realization of the random loading process. Again.1) where we will take F (t) to be the sinusoid above having random amplitude A (t) : It will be convenient for us to apply the condition of ergodicity to this system. we will want to compare the results of several di¤erent systems to a random loading. they depend on an initial state vector. and second.
Figure 18. ag We are confronted with one more problem if we wish to use the di¤erential equation solver.omega).3) are: .5) This is easily coded into Matlab. What we must do is solve the di¤erential equation at time t = t0 . The coding for this is left to the reader. since the position and velocity imparted by the forcing function at time zero are not necessarily zero.x.A]=randamp(tspan.2.143 of tspan that surround the current time value t:5 In order to ensure that the amplitude is always greater than zero. where: xh (t) = Ah e !t sin(! d t + ). We could improve our odds of not getting negative values for A by changing the standard deviation such that 3 in each direction is positive. The plot only shows the …rst …ve seconds to give a‡ avor for the variations in the force. showing that x (t) = xp (t) + xh (t) . The error expression in the default (otherwise) case of our switch expression will print the message in quotes to the screen. That is. The reader is welcome to devise other re…nements. we multiply each element of A by its sign. (18. how do we remove the transient response? It is not as simple as setting the initial conditions to zero. The oscillation remains periodic even with the random forcing amplitude. function [t. informing the user of the function that the allowed values of the ‡ are zero and one. using the initial value of the force amplitude in the random array A: We neglect the time derivative of the randomlyvarying amplitude A as a …rst approximation. % Program 1: randamp. albeit with an irregular amplitude.1 is the displacement versus time curve for the oscillation. (18. to be sure. of course. to solve for the initial position and velocity required to match the forced response. = tan 1 2 !n ! : !2 !2 n (18.dist‡ ag.2) and xp (t) = A0 (t) cos(!t where we found that the constants A0 and A0 = q A (t) (! 2 n ! 2 ) + (2 ! n !) 2 ).zeta.wn. but has the bene…t of being simple to implement. and then substitute into the relation the values of the forcing and the forced response at that time. This leads to a distribution that is not rigorously Gaussian. eliminating the transient response xh (t) : This is as straightforward as specifying x (t0 ) = xp (t0 ) and x (t0 ) = xp (t0 ) . . or: _ _ x (t0 ) = A0 (t0 ) cos (!t0 x (t0 ) = _ !A0 (t0 ) sin (!t0 ) ): (18. Recall our earlier analysis. The force amplitude is shown in Figure 18.m % This program solves a single degree 5 This is a coarse approximation.4) We need to specify the initial conditions x (t0 ) and x (t0 ) so that we can have _ Ah = 0.
case 1 A=2. A=A.t(m). between 0 and 5 for % the uniform distribution.05. % where A is a random variable. end if nargin<4 dist‡ ag=0.5. % One standard deviation will span [1.30. if m<1000 tspan=linspace(t(1). % global A_g tspan_g zeta_g wn_g omega_g phi_g % needed by the ode de…nition. end if nargin<2 wn=1. we de…ne the amplitude A. We will force A>=0. We’ say that if ve ll % tspan has fewer than 1000 elements.5 for the Gaussian. we need to be speci…c % about how many time steps we’ been given.1000). phi_g=0.5].*sign(A). % so the Gaussian distribution will need a little % bit of tweaking (and it won’ be rigorously Gaussian). % Since we’ got to have an amplitude for each ve % time step (ease of interpolation). omega_g=omega. if nargin<1 tspan=linspace(0. end % % Now.144 CHAPTER 18 RANDOM VIBRATION AND MATLAB % of freedom oscillator given an % input of the form F(t)=Acos(omega*t+phi). then we make % it a 1000element vector.1000). m=max(size(tspan)).5+randn(size(tspan)). % Multiplying A by the signum function of itself. end if nargin<3 zeta=0. % tspan_g=tspan.5. wn_g=wn. end % % Next. t % switch dist‡ ag case 0 A=5*rand(size(tspan)). % dist‡ should be zero for uniform. % Zero phase angle. % A now has a range from 0 to 5. % . zeta_g=zeta. end if nargin<5 omega=3.3.’ ag ). and as a distribution with % mean of 2. ag % and 1 for Gaussian distribution. end % % Assigning global values. we de…ne the initial conditions to remove transients. otherwise error(’ Distribution ‡ must be zero or one.
1).x]=ode45(’ randdx’ . x0=A(1)*cos(omega*tspan(1)phi). re % [t. dx(2.xd0]. At=interp1(tspan_g.tspan.1)=x(2. % % Storing A in the global value. % A_g=A.x) % % Program 2: randdx.1)+wn^2*x(1.1)=At*cos(omega*tphi)(2*zeta*wn*x(2. function dx=randdx(t.xv0). % interp1 is a builtin function. % Finding the correct value of A. % global A_g tspan_g zeta_g wn_g omega_g phi_g % Need these for the interpolation. .t). xd0=A(1)*omega*sin(omega*tspan(1)phi). % % Now we’ ready to solve the ODE.A_g. % dx(1.145 phi=atan(2*zeta*omega*wn/(wn^2omega^2)). xv0=[x0.m % Di¤erential equation de…nition for % the randomlyvaried amplitude case.1)).
146 CHAPTER 18 RANDOM VIBRATION AND MATLAB 1.5 1 0.5 Displacement 0 0. seconds 20 25 30 Figure 18.1: Displacement versus time plot for the random Du¢ ng oscillator.5 1 0 5 10 15 Time. .
5 2 2. seconds 3 3. .5 5 Figure 18.147 5 4. to show variations.5 4 4.5 2 1.5 4 3.5 3 Amplitude 2.5 Time.5 1 1.5 1 0.2: Amplitude versus time curve for …ve seconds.5 0 0 0.
.
1 if x is positive. the spring gains sti¤ness in extension over the purely linear case. where the magnitude of the shift depends on the relative values of k and ": 1 Recall from an earlier example that sgn(x) is the signum function. if we choose the parameter " > 0 and select g (x) = x2 . we would expect roughly oscillatory motion for small amplitudes x. Conversely.1 If " < 0.1) where the parameters c and k are assumed to be positive. This equation allows us to choose the parameter " and the function g (x) to model nearlylinear springs. these smallamplitude oscillations would reduce to zero. and that if we further introduce a small damping coe¢ cient c. and j"j 1: Note that " is not restricted to solely positive nor negative values. If we assume a function g (x) such that sgn(g (x)) = sgn(x). We could call upon the van der Pol oscillator of a few examples ago. if we take " > 0. but instead we will introduce the Du¢ ng equation: x + cx + kx + "g (x) = A cos !t • _ (19. in that now we will apply a random forcing input to a nonlinear oscillator. Of course. then the sign of the parameter " determines the character of the sti¤ness element being modeled. which returns is negative.Chapter 19 RandomlyExcited Du¢ ng Oscillator This example expands on some of the ideas of the previous. this equation retains some attractive quasilinear qualities. if we set A = 0 and c = 0. 1 if x 149 . we then get a net restoring force kx + "g (x) that is negative for x < 0 and positive for x > 0: In other words. and is called a hard spring. Also. meaning that the center of oscillation (equilibrium point) will be shifted slightly away from zero. the spring will be soft in extension but hard in compression. For example. for example. we are not limited to the class of functions g (x) described above. Speci…cally. then we see that the restoring force will be smaller in extension. and arrive at a soft spring. and 0 if x is zero.
the state vector x.2). It happened that we got lucky (or unlucky. providing default values via nargin.) We use the uniform distribution generator inside Matlab to provide a forcing amplitude between zero and 5. our next step is to introduce a random forcing function. Of special note is the third run in Figure 19. or to take them as function inputs. (The reader is encouraged to rewrite the function to take the time increment. The phase diagram in Figure 19. but by no means closed. we see a nearlyresonant condition in this undamped oscillator. and then type the following at the Matlab prompt: for i=1:max(size(x)) plot(x(i. meaning that the mean point of the oscillation does not move one way or the other. it is stationary at zero. the random amplitude A. Unlike the previous example (and in preparation for the next) we will select a random forcing frequency and amplitude. and also makes for a useful check on our random solution. Also. depending on the point of view) on this run. the time span and initial conditions are …xed inside the code. The interested reader is encouraged to look at this behavior for himself. we leave the time interval and initial conditions de…ned within the function. we will not need to write a new program to provide the di¤erential equation. and !: The function uses g (x) = x2 . This implementation is given in Program 3 below. along with the random frequency and amplitude used. we will send the same set of global variables. The response traces out arcs in the phase plane that are circular.x(i. we can run our deterministic solver (Program 1) using the default values for e. Examining the plot point by point shows that the oscillation travels back and forth through the phase plane. and got a random forcing frequency very close to the system’ natural frequency s of one. and a forcing frequency between zero and 2 : Note that the function returns four arrays: the time vector t. If we design this function properly. Knowing the values of A and w used by the code. Program 1 can be quickly edited to take a di¤erent time increment or initial conditions. ". to keep the number of inputs manageable. and you . and the random values for A and w: The results for a few default runs are plotted below. given the input values of c.1). A simple way to accomplish this is to run the Du¢ ng oscillator function with the given parameters.4 corresponds to this run. Again. Figure shows the results of the hardcoded default case. c and k. A. Hence.150CHAPTER 19 RANDOMLYEXCITED DUFFING OSCILLATOR Let us use the Du¢ ng oscillator as a model for response to a harmonic input. Programs 1 and 2 below use the di¤erential equation solver suite inside Matlab to calculate a numerical solution to a Du¢ ng equation. Having arrived at a solution for the Du¢ ng equation. initial conditions.3. and the random frequency w: This is for ease of comparison between runs. k. or both as inputs. this can be readily changed by editing the di¤erential equation de…nition function (Program 2). which will remain constant for the duration of the oscillation.’ ) o’ hold on pause end Matlab will execute this loop as if it was inside a function or script.
function [t. .151 will be able to track the movement in the phase plane.1)=A_g*cos(w_g*t)(c_g*x(2. xinit=[0 0]’ .m % Function to set up and implement the ode45 % solution of a Du¢ ng oscillator.x) % Program 2: du¤dx. function dx=du¤dx(t.xinit). end % w chosen to prevent resonance.1)=x(2. % global c_g k_g e_g A_g w_g g=x(1.05. Both values % are taken from a uniform distribution.k) % % Program 3: randdu¤.0].01.1)+k_g*x(1. and the initial conditions % set to [0.01.x. end if nargin<2 c=0.1)^2.1)+e_g*g).tspan. end if nargin<3 k=1. tspan=[0 30]. end 2 You may also have to sit through many pauses. end if nargin<5 w=2.c. if nargin<1 e=0.05.A.m % This function provides random force amplitude % and frequency to a Du¢ ng oscillator. end if nargin<4 A=3. Also. the x array we computed was 2by457.30]. % Since we stated g(x) above.w) % Program 1: simpdu¤.2 function [t. tspan=[0 30]. xinit=[0 0]’ . [t. we need % only change that one line of code above to use % a di¤erent function g(x). % The customary nargin check.k. dx(2.m % Function to return the updated state % vector for a Du¢ ng oscillator.1). the equation for x” % looks like the Du¢ ng equation. if nargin<1 e=0. end if nargin<2 c=0. % Explicitly stating g(x). The % time increment is hardcoded to be % [0.A.x]=ode45(’ du¤dx’ .w]=randdu¤(e. % global e_g c_g k_g A_g w_g % Tagging these with “_g” for consistency. % global c_g k_g e_g A_g w_g % Will be used in ode solution.x]=simpdu¤(e.7. dx(1.c.
end rand(’ state’ . c_g=c. % Resetting random generator state. e_g=e. [t. w_g=w. . k_g=k.sum(clock*100)).tspan. w=2*pi*rand(1). A=5*rand(1).x]=ode45(’ du¤dx’ .152CHAPTER 19 RANDOMLYEXCITED DUFFING OSCILLATOR if nargin<3 k=1.xinit). A_g=A.
153
0.6
0.4
0.2
Amplitude
0
0.2
0.4
0.6
0.8
0
5
10
15 Time, seconds
20
25
30
Figure 19.1: Response of the randomlyexcited Du¢ ng oscillator with ! = 3:7960 and A = 3:7999:
154CHAPTER 19 RANDOMLYEXCITED DUFFING OSCILLATOR
4
3
2
1
Amplitude
0
1
2
3
4
0
5
10
15 Time, seconds
20
25
30
Figure 19.2: Response of the Du¢ ng oscillator to amplitude A = 4:4531 and forcing frequency ! = 1:7404:
155
10
5
0
Amplitude
5
10
15
0
5
10
15 Time, seconds
20
25
30
Figure 19.3: Response to A = 1:0062 and ! = 1:0115:
2 0.2 0 0.5 1 1.5 0 0.4 0.5 2 2.5 1 0.5 2 1.5 1 0.4 0.4: Phase plot for the nearlyresonant case above.8 Figure 19. .156CHAPTER 19 RANDOMLYEXCITED DUFFING OSCILLATOR 2.6 0.6 0.8 0.
In general.1) where the parameters A and ! are random variables. where the excitation is of the form: F (t) = A cos (!t) . Mann. !2 (20. one can apply perturbation theory to a nonlinear system to estimate the response.1 To approximate the statistics of our nonlinear system. that is: A1 !1 A ! A2 . where we again have a harmonicallyexcited single degree of freedom oscillating system. ! 1 . E. One approach would be to model the results with A and ! at mean values. and the 1 In addition to the numerical approach presented here. where actual random variable distributions are available. the Monte Carlo method has two forms: the probabilistic form. using a normal or uniform distribution. which could form a good basis to estimate the behavior of a linear system. where we modeled the amplitude of a harmonic input force as a timevarying random process. Jr.2) where A1. so we need an alternate method to arrive at some response statistics. or A First Look at Perturbation Theory. by J. However. There is no longer a guarantee that the mean values for the inputs will correspond to the mean values of the response. developed systematically by Metropolis and Ulam (1949).W. (Dover Books). we choose to employ the Monte Carlo methodology. Jordan and P. we looked at a system under random excitation. A2. G. ! 2 are known constants. by D. As with the previous analysis.Chapter 20 Monte Carlo Simulation of a Random System In the previous example. Smith (Oxford University Press). we assume that the forcing will be applied in a certain range. 157 . For more. see Nonlinear Ordinary Di¤ erential Equations. such as the Du¢ ng oscillator from the previous example. Consider now a related problem. let us address the more interesting (and di¢ cult) problem of estimating the behavior of a nonlinear system. Simmonds and J. (20.
with the manner in which we have chosen to specify global variables. this means that we need to determine which output quantities interest us. we can set the value of the global amplitude and frequency right before calling for the ODE solution.7% of the randomlygenerated values would fall between the prescribed extreme values. In this way. we follow a deterministic algorithm. Thus. we set up 2 A word of warning. where such distributions are unknown. It can. or they can be computed in advance. a code that will run several realizations and return our desired quantities. We could also use a Gaussian distribution. Our initial value for this parameter was 0.158CHAPTER 20 MONTE CARLO SIMULATION OF A RANDOM SYSTEM deterministic form. Our standard deviation would then be selected so the endpoint values given correspond to three standard deviations from the mean value in either direction.05. Of course. In order to solve the deterministic problem. about 99. We choose the former for our demonstration. (The reader may be wondering if this calculation can be vectorized. These values can either be computed as needed. using for the mean the midpoint of the given ranges. but a simple demonstration will capture the spirit of the Monte Carlo methodology. however: Reduce the value of the damping coe¢ cient c at your own risk. we will again de…ne the system initial conditions so that the transients are removed. and leave the Gaussian distribution as an exercise for the reader. Here. Since we have ranges over which we presume the random variables A and ! will vary. The method in both of its forms can be broken down into three steps: 1. 3. we will track the maximum displacement and maximum velocity for each realization. like we did with our …rst example of a random forcing input. right before sending to the ODE solver.2 We will only arrive at useful statistics for our system if we can apply the conditions of ergodicity to the system. The reader is encouraged to modify the given code to add whatever complication he wishes. we could retain the entire history of oscillation for each realization. We specify the random variables as row vectors (arbitrarily) and we force them to lie on the desired domains. 2. we can describe both as uniformlydistributed between their extreme values. For the purpose of demonstration. If it was necessary. we will use the di¤erential equations de…nition function we presented in the previous example. Solution of the deterministic problem for a large number of random variable realizations. Statistical analysis of results. and the integrator did not complete any attempted run of the code at that value of c: . the programming is left as an exercise. Then. We will demonstrate the procedure for uniformlydistributed variables.) Also. though adaptation of the method as described here to its probabilistic form is a matter of substituting the known random distributions for the ones we will presume here. Simulation of the random variable(s). We have already performed most of the work for the …rst step above. What we need to create is a separate driver for this function.
The di¤erence in number of occurences for the most and least common frequency was also around 30 out of 1000.tspan) % % Program 1: montdu¤.e.wout]=montdu¤(nruns. we could use the displacement and velocity information to derive the maximum stress at some point in the beam for each run. function [xout. are not uniformly distributed. 3 A test performed with 1.3 Our results. % global c_g k_g A_g w_g e_g % For compatibility with the existing du¤dx. The four histograms below show the variations in several parameters for a set of 100 random realizations of the Du¢ ng oscillator. Figure 20. if we had a nonlinear model for. . The possible applications of this analysis are limited only by the systems we wish to apply it to. however. the maximum displacement and velocity is found and stored. and the time span used. The shape of the distribution is akin to a onesided Gaussian distribution.xdout.3 shows the variation of maximum displacement values. For a larger sample size. we would expect these numbers to reduce on a percentage basis.m. we expect the number of values in each range to be about the same. if we wanted to have 90% certainty of a displacement less than 10. a vibrating beam. These values can be changed % by editing the code.1 is the histogram of force amplitudes. and Figure 20. After the ode solution is found. or 3%. solving for the appropriate initial displacement and velocity for each.m % This code performs a Monte Carlo simulation of the % Du¢ ng oscillator. We may then perform whatever statistical analyses we wish on this data. Since we chose uniform distributions for both of these quantities. we would see that the default system is inadequate. the di¤erence between the most and least common force amplitude range is eight occurrences. This is the case.2 is the set of forcing frequencies. presumed to be % described by uniform distributions. The vast majority (65%) had maximum displacement under 10. as are the input amplitude and frequency. implying that our normallydistributed inputs led to Gaussian output. The reader is invited to rewrite the routine to return all of the displacement and velocity histories (hint: threedimensional matrices will be helpful). say.159 a for loop to run the ODE solver the speci…ed number of times. with 85% of the resulting maximum velocities falling under 10.4 also shows a onesided Gaussian distribution. the % sti¤ness is presumed to be one and the damping % presumed to be 0.1. One can readily see how this information could be applied to a design procedure. Also. and the di¤erence between the most and least common frequency range is ten occurrences. The random parameters are the % forcing amplitude and frequency. Also.Aout. Figure 20. Figure 20.000 simulations showed that the di¤erence in amplitude occurences was 30 of 1000 between most and least common. It is also possible to do more complicated analyses involving other aspects of the data.
This is why we want % to specify the length of the time vector. w_g=w(1. xinit=[x0. xdout=zeros(1. wlo=0. % Extreme values for the amplitude.nruns). end if nargin<3 tspan=[0 30]. Ahi=10. % The run. A=Alo+(AhiAlo)*rand(1. xd0=A_g*w_g*sin(w_g*tspan(1)). xout(1. end wout=w.i)=max(xrecv(:. end % % Sti¤ness and damping coe¢ cient. % if nargin<1 nruns=50. % c_g=0.1)).2)).xinit). . % Choose initial conditions to remove transient.i). Aout=A. w=wlo+(whiwlo)*rand(1. % Extreme values for the frequency.xrecv]=ode45(’ du¤dx’ . end if nargin<2 e=0.01.1. % Here we could perform a more complex analysis xdout(1.160CHAPTER 20 MONTE CARLO SIMULATION OF A RANDOM SYSTEM % Parameter check. whi=2*pi. e_g=e.tspan. Alo=0. x0=A_g*cos(w_g*tspan(1)).nruns). xd0]. for i=1:nruns A_g=A(1. [trecv.i)=max(xrecv(:.i). % Set global parameters. % of our data.1. % xout=zeros(1.nruns).nruns). % % Initializing the t and x vectors. k_g=1.
1: Histogram showing the force magnitudes among the 100 random runs. .161 16 14 12 Number of Occurences 10 8 6 4 2 0 0 1 2 3 4 5 6 Force Amplitudes 7 8 9 10 Figure 20.
.162CHAPTER 20 MONTE CARLO SIMULATION OF A RANDOM SYSTEM 15 10 Number of Occurences 5 0 0 1 2 3 Frequencies 4 5 6 7 Figure 20.2: Histogram showing the various frequencies applied to the Du¢ ng oscillator.
163 70 60 50 Number of Occurences 40 30 20 10 0 0 10 20 30 40 50 Maximum Displacement 60 70 80 Figure 20.3: Histogram of maximum displacement values. .
164CHAPTER 20 MONTE CARLO SIMULATION OF A RANDOM SYSTEM 45 40 35 30 Number of Occurences 25 20 15 10 5 0 0 10 20 30 Maximum Velocity 40 50 60 Figure 20. .4: Histogram showing maximum velocities of the simulated responses.
Best of luck.Chapter 21 Conclusion This primer on MATLAB as applied to vibration problems. 165 . simple and not so simple. The basic elements are here to study a variety of vibration problems and to “play” with the equations and the parameters. You will …nd it interesting and fun doing this. can be an valuable tool to the student and the practitioner.