Application of Math Principles To Engineering PDF
Application of Math Principles To Engineering PDF
Application of Math Principles To Engineering PDF
To Engineering Problems
7th edition
By
Professor David A. Hullender
June 16, 2016
1
Preface
The objectives of this course are to teach solution techniques for solving typical equations
encountered in the analysis and simulation of engineering systems. When obtaining solutions to
equations, it is very beneficial to focus on the common sense details associated with the
performance of the actual engineering system for which the equations are written. Consequently,
throughout this text, equations for actual engineering systems are utilized so that it is possible to
apply common sense to the prediction and approximation of the solution to the equations before
actually solving the equations. Knowing the approximate solution provides confirmation to the
actual solution in the end.
From the very beginning of the course, computer algorithms in MATLAB will be utilized to
obtain and plot solutions for equations. Having taken a MATLAB course prior to this course is
not necessary. This is the course for learning to program in MATLAB by seeing examples and
asking the instructor or TA for assistance with challenges or matters not understood.
At the end of several of the sections, a list of previous quiz, homework, and exam problems are
listed that utilize some of the concepts introduced in that particular section. The solutions to
almost all of the problems are provided; however, it is very important to test your understanding
of the concepts by trying to work each problem without looking at the solution. Then and only
then will you know your weaknesses; it is better to determine your weaknesses prior to an exam
instead of during an exam! Reviewing the solution to a problem before trying to work it without
looking at the solution is a total waste of time; in my opinion, this is the number one mistake
students make when preparing for exams. The second greatest mistake is preparing for an exam
with other students; you are not learning what you dont know and, unfortunately, you will find
out what you dont know during the exam.
Table of Contents
Chapter 1 Basic Math Principles
1.1 Complex Numbers 5
1.2 Notation for Time Derivatives and Use of the D Operator 6
1.2.1 Notation for Time Derivatives 6
1.2.2 Use of the D Operator to convert Differential Eqns to Algebraic Eqns 6
1.3 Eigenvalues of a System 7
1.3.1 General Properties of Eigenvalues 7
1.3.2 Using MATLAB to Compute Eigenvalues 8
1.4 Solving Simultaneous Algebraic Equations 9
1.4.1 Manually Solving Simultaneous Equations 10
1.4.2 Using Symbolic Math in MATLAB to Solve Simultaneous Equations 12
2
Chapter 2. Solving Differential Equations
2.1 Analytical Solutions of Differential Equations Using the Laplace Transform 16
2.1.1 Linearizing Nonlinear Differential Equations 16
2.1.2 The definition of the Laplace Transform 21
2.1.3 Properties of the Laplace Transform 22
2.1.4 Final Value Theorem 22
2.1.5 Initial value theorem 23
2.1.6 Converting Differential Eqns to Algebraic Eqns Using Laplace Transform 24
2.1.7 Common Inputs and Their Laplace transforms 25
2.1.7.1 Step Functions and Constants 25
2.1.7.2 Pulse and Impulse Functions 26
2.1.7.3 Exponential Functions 27
2.1.7.4 Periodic Functions 27
2.1.8 Inverse Laplace Transform 27
2.1.8.1 Inverse Laplace Transform Using Partial Fractions 27
Obtaining Partial Fractions Using MATLAB 30
2.1.8.2 Inverse Laplace Transform Using the Residue Theorem 30
Shortcut for Complex Poles 32
2.1.8.3 Using MATLAB to Plot the Inverse Laplace Transform without
Getting an Equation for the Inverse Laplace Transform 35
2.1.9 Modes of a System 36
2.2 Numerical Solutions to Differential Equations Using MATLAB 38
2.2.1 General Considerations 38
2.2.2 Using the impulse command in MATLAB 38
2.2.3 Using the step command in MATLAB 39
Obtaining DC Gain using dcgain command 39
2.2.4 Using the Command lsim 40
Pulse Series input 40
2.2.5 Using the Command initial 42
2.3 Using MATLAB to Get the System Response Using Numerical Integration 43
2.3.1 Example Problems using ode45 in MATLAB 43 41
2.3.2 Example Simulation Using Options and Event Functions with ode45 45
2.4 Using MATLAB to Get the System Steady State Response for Periodic Inputs 47
2.4.1 Frequency Response Analysis 47
2.4.2 Examples of Frequency Response Function Plots 48
2.5 Using MATLAB to Get Lower Order Approximations for Transfer Functions 52
2.5.1 Examples of Modal Approximation 52
2.5.2 Transfer Function Approximations using Inverse Freq. Domain Analysis 55
2.6 Converting Linear Continuous Differential Eqns to Discrete Time Eqns 67
2.6.1 Converting 1st Order Differential Eqns Using Inverse Laplace transform 67
2.6.2 Conversion Using the Continuous-to-discrete MATLAB command, c2d 68
4
Chapter 1 Basic Math Principles
1.1 Complex numbers
y a jb Me j
M a 2 b2
angle (a jb )
Note, the angle is in one of four quadrants. Simple use of the inverse tangent on a calculator
may give the incorrect answer. In MATLAB, the command angle with a complex number
gives the correct answer for any of the four quadrants. Consider the examples below.
imaginary part
M
real part
a
Example:
y 4 j 3 5e j 3.785
M 32 4 2 5
angl ( 4 j 3) tan 1 (3 / 4) 3.785
imaginary part
3.785 rad
-4 real part
-3
5
Example: The solution y(t) to a differential equation is found to be the following:
() = 3 + 25 4 sin(3 + )
where
2 + 3 2 + 3
=| | = ( )
4 + 3 4 + 3
Throughout this book, time derivatives of functions will be denoted with dots over the function.
For example, for the first three time derivatives of function y(t)
2 3
2 3
1.2.2 Use of the D Operator to convert linear Differential Equations to Algebraic
Equations
The D operator is used to express a linear differential equation with an input and with no
initial conditions into an algebraic equation. In D operator format, the first derivative with
respect to time of a function, f(t), is denoted by Df(D) where f(D) denotes the function f(t) in D
operator format. The 2nd derivative of f(t) in D operator format is denoted by D2f(D), etc.
Consider the following 3rd order linear ordinary differential equation for the output y(t) of a
system with input u(t):
+16 + + = + + +
( + + + )() = ( + + )()
Solving for y(D) gives
6
+ +
() = [ ] ()
+ + +
The function of D in the brackets is called the transfer function relating the input u to the output
y. Note that the numerator and denominator polynomial coefficients in the transfer function are
simply the coefficients in the differential equation. The denominator of the transfer function is
called the characteristic polynomial; the poles of the transfer function (roots of the characteristic
polynomial) are called the eigenvalues of the system. Knowing the transfer function and
eigenvalues of a system are very beneficial to analyzing time response dynamics for different
system inputs.
In general if u(t) is a constant, then the solution of the differential equation for y(t) will also
become a constant as time goes to infinity; when y(t) becomes a constant, () will become zero
as will (), (), (), and (). Thus, in the end (as time goes to infinity), the original
differential equation above simplifies to
0 + 0 + 0 + 100 = 0 + 0 + 150
This equation can be solved for the limiting value (also called the final value) of y(t), i.e.
150
= 100
where u is the constant value for the input. For example, if u =4, then the final value of y is 7.
The eigenvalues of a system define the time response characteristics of a system resulting from
an external input or from nonzero initial conditions. The eigenvalues are obtained by factoring
the characteristic polynomial which is the denominator of the transfer function of the system.
Eigenvalues will either be real or complex. The real parts of all of the eigenvalues of the system
must be negative otherwise the solution will go to infinity; that is, a single eigenvalue, real or
complex, with a positive real part will cause the time response of the system to diverge to
infinity.
( + + )( + ) = [( + )2 + 2 ] = 2 + 2 + 2 + 2 = 2 + 2 + 2
where -r is the real part of the eigenvalue, is the imaginary part also called the damped
natural frequency, is the damping ratio, and is the undamped natural frequency. Note
7
that = ; for complex eigenvalues 0 < 1. Also note that eigenvalues have time
1
constants, ; = | |. Time constants determine how long it will take for the time response of
the system to reach a final value and stop changing, that is, reach steady state; it takes
approximately 5 times the largest eigenvalue time constant for the response to be within 1% of
its final value. So, when performing simulations for problems in which the solution becomes
zero or a constant, a rough estimate of the final time should be five times the largest time
constant, i.e.
5
The largest time constant is 0.5; thus, it will take about 5*0.5=2.5 seconds for this system to
return to equilibrium following an input disturbance or nonzero initial condition. Usually,
returning to equilibrium means that the solution to the equations becomes constant.
( + 4 + 3)( + 4 3) = ( + 4)2 + 32 = 2 + 8 + 25
Thus, = 3 , = 25 = 5 , = 0.8
Eigenvalue problems in this text: 4.16, 4.13, 4.16, 4.22, 4.25, 4.26, 4.27, 4.28, 4.29, 4.30, 4.36,
4.37, 4.40, 4.43, 5.6, 5.13, 5.16, 5.22, 5.25, 5.26, 5.27, 5.28, 5.29, 5.30, 5.33, 5.36, 5.37, 5.43,
Q7, Q14, Q18, H3, H5, H9, H12, H13, H20, H21, H24, H25, H28, H34, H35, H43, E1C, E2A,
E2C, E3B, E3D, E4B,E5A, E5C, E6A, E6C
All MATLAB commands are defined using lower case letters. The best way to learn to use any
command is to type help command-name. Using help works for all of the MATLAB
commands. If you dont know the name of a command, type help to get a list of the different
categories of commands. For example, typing help lists elfun for elementary functions. To
see a list of these elementary functions type help elfun.
As mentioned in section 1.2.2, the transfer function defines how the output of a system responds
to the input to that system. Also, the denominator of a transfer function is the characteristic
polynomial and the roots of this polynomial are called the eigenvalues of the system. If the
numerator and denominator polynomials of a transfer function are known, then the transfer
function can be entered into MATLAB. Consider the transfer function found in section 1.2.2:
++
() = [ ] ()
+ ++
8
The procedure for entering the coefficients of polynomials and creating transfer functions is
shown below. Note, putting a semi-colon at the end of a statement stops MATLAB from
echoing the result; this is really important if the result consists of hundreds of numbers. In the
MATLAB commands below, the polynomials are given names num and den; the transfer
function is given the name G:
>> num=[6 28 150]; Entering the numerator polynomial into MATLAB
>> den=[2 16 74 100]; Entering the denominator polynomial into MATLAB
>> G=tf(num,den) Entering the transfer function into MATLAB
+ +
=[ ]
+ + +
The damp command gives the eigenvalues, damping ratios, and undamped natural frequencies.
>> damp(G)
The time constants are computed using one over the absolute value of the real parts of the
eigenvalues. For this example, the time constants are 1/2 and 1/3. Time constants are positive
numbers. Note, MATLAB will incorrectly give values for the damping ratio and frequency for
real eigenvalues. Real eigenvalues do not have a damping ratio and frequency. I have replaced
the numbers with not applicable in the MATLAB response to the damp command.
The eigenvalues can also be obtained from the denominator polynomial using the command
roots, i.e.
>> roots(den)
9
1.4.1 Manually Solving Simultaneous Equations
There are numerous ways to solve simultaneous algebraic equations. For engineering problems,
there is normally only a single variable representing the output of interest. Consequently, it is
suggested that a simple step by step approach be used for simplifying and reducing the
simultaneous equations down to a single equation with the variable representing the output of
interest being the only remaining unknown.
Consider the following three simultaneous algebraic equations with unknowns x, y, and z.
(1)2 + 3 10 = 4
(2) 5 + 2 + 8 = 1
(3)3 4 + 2 = 0
These equations are considered simultaneous because you cant solve for either x, y or z without
using all three equations. Unless the solutions for all three unknowns are needed, an approach
giving solutions for all of the unknowns, such as the matrix inverse approach, may be
computationally burdensome and not necessary.
Suppose x is the output of interest meaning we only want a solution for x. The suggested
approach is to solve for one of the other unknowns in one of the equations and substitute that
solution into the remaining equations; this process will reduce the number of equations by one
and reduce the number of unknowns by one. This process is repeated until only a single equation
remains. For instance, if we solve (1) for z, we get
We now have two equations and two unknowns x and y. Since we want the solution for x, we
can solve (2) for y and substitute the result into (3). This gives
= 5.2353
It is not uncommon for one or more of the equations to contain a symbolic parameter in place of
a numerical value. This is always the case when solving engineering problems with the D
operator or with the Laplace transform variable s. In such cases, the solution will contain this
symbolic variable. For instance, suppose our original three equations contain the D operator,
i.e.
(1)2 + 3 10 = 4
10
(2) 5 + 22 + 8 = 1
(3)3 4 + 2 = 0
If we use the same solution process while treating the symbol D as some numerical value, we get
the following:
8D^2 + 64D + 17
82 + 81
= ---------------------------------------
43 + 302 + 32 49 4D^3 + 62D^2 + 36D +85
Although the step by step solution process is the same, close attention to detail and checking
each step is required to avoid costly errors. Being able to solve simultaneous algebraic equations
is often critical for analyzing and simulating the dynamics of an engineering system.
It is important to note that before starting the solution process, one should always confirm that
the number of unknowns matches the number of equations. If there are more unknowns than
equations, the solution for the output of interest will be obtained in terms of the extra unknowns;
in general, a shortage in the number of equations means the modeling process for the system is
incomplete.
Example:
Consider the mass/spring/damper system shown below; the displacement of the mass is denoted
by y(t) and the input force that moves the mass is denoted by f(t).
y(t)
Spring k
Force Input
Mass f(t)
m
Damper c
An equation for each component can be written using modeling techniques. Assume that the
algebraic equation for the force 1 on the spring in terms of the spring constant k=100 N/m is
1 = 1000
Assume that the differential equation for the force 2 on the damper in terms of the viscous
damping coefficient c = 2 Ns/m is as follows:
2 = 2
Using the D operator, this differential equation can be converted to an algebraic equation, i.e.
2 () = 2()
And finally, the differential equation for the acceleration of the mass m = 44 kg is
= ( 1 2 )/4
11
Converting this differential equation to an algebraic equation gives
2 () = [() 1 () 2 ()]/4
We started with one algebraic equation and two differential equations and used the D operator
to simplify the model to three algebraic equations with three unknowns: 1 (), 2 (), &().
Dont forget, f(D) is the input which will be a known function of time.
Using the step by step reduction process to obtain a single equation, the equation for the output
of interest y(D) is obtained, i.e.
1
() = [ ] ()
42 + 2 + 100
Or
1
() = [ ] ()
2 + +
This single algebraic equation defines how the input force () affects the displacement y(t) of
the mass. Just how to use this equation for analysis purposes is not important at this point.
What is important, however, is that we were able to convert the differential equations to
algebraic equations and then use simple algebraic reduction of the equations to get a single
equation for the output of interest.
For more complex systems consisting of many complex simultaneous equations, we can use
Symbolic Math in MATLAB to obtain the single equation solution.
Problems requiring this concept: 4.3, 4.20, 5.3, 5.21, Q3, Q11, H9, H23, H24, H25, H34, H43,
E1a, E1c, E4a
Symbolic math allows a computer to obtain a solution in terms of symbols that may not have
been assigned numerical values. Type help symbolic to see all the possibilities in MATLAB.
Here we demonstrate how to use one of the symbolic commands solve to get the solution for
the three algebraic equations in section 1.4.1. The symbolic statement below provides the
solution for all three unknowns x, y, and z.
>> H=solve('2*x+3*y-10*z=4','-5*x+2*y+8*z=1','3*x-4*y+2*z=0','x,y,z')
Note that each equation has been entered between single quotation marks in terms of the
variables x, y, and z which are the three unknowns. Also, the three unknowns are listed between
single quotation marks at the end of the statement. The number of unknowns must match the
number of equations to avoid an error message.
Since solve is a symbolic math command, answers will be displayed as a ratio of two whole
numbers. To see the answer in floating point arithmetic, you must first specify the number of
digits to be displayed and then use the command vpa, i.e.
>> digits(5)
>> vpa(H.x)
Ans = 5.2353
Example: It is not uncommon for equations to contain parameters that are symbolic. The first
step is to declare which parameters are to be symbolic. For the mass/spring/damper system in
the section 1.5.1, note that the answer was obtained in terms of m, c, k, and D. Realizing this in
advance alerts us to begin the solution process by declaring these to be symbolic. This is done
with the following MATLAB command where d has been used in place of D to avoid a
conflict since D is used in the symbolic algorithms. The syms command declares that the
listed symbols may not have numerical values
>> syms d m c k
The next step is to use the MATLAB solve command to get the solution. For the
mass/spring/damper example problem, this is done as follows:
>> H=solve(F1=k*y,F2=c*d*y,m*d^2*y=f-F1-F2,y,F1,F2);
Note as before, that each of the equations has been entered between single quotes. Following the
equations, the three unknowns are listed also between single quotes. Executing these two
commands gives the solution H which contains the solution for all three unknowns. The solution
for only y has been stored in the computer memory as H.y; using the pretty command prints
the solution in a more recognizable format, i.e.
>> pretty(H.y)
1
=[ ]
2 + +
Since m, c, and k are symbolic, it is possible to assign numerical values to each. This is done
with the subs command. Note, if the numerical values are not simple integers, the digits and
vpa commands may be needed to make the results presentable. For instance, if m = 4, c=2, and
k=100:
Y=f/(4*d^2+2*d+100)
>> pretty(Y)
1
=
4 2 + 2 + 100
13
Additional commands that are useful when working with symbolic variables are (1) collect for
grouping like powers of a symbol such as d; (2) numden for getting the numerator and
denominator polynomials of a symbolic transfer function; (3) poly2sym for converting a vector
of polynomial coefficients to a symbolic polynomial; (4) sym2poly for converting a symbolic
polynomial to a vector of coefficients; and (5) int8 and int16 for converting and rounding off
numbers with a decimal point to integers. For other useful symbolic commands, type help
symbolic.
F(t) F(t)
m=10 kg
b=5 Ns/m
M z k=1000 N/m
k b
M v
k b
M w
k b
f f
It can be shown that the equations representing this model for displacements z, v, and w defined
to be zero at equilibrium and assuming zero displacement at the bottom end of the pile are as
shown below. The ground force is the force that forces the bottom end of the pile into the
ground. The output of interest to us is the ground force defined in the last equation.
14
mz bz kz bv kv F
mv 2bv 2kv bz kz bw kw
mw 2bw 2kw bv kv
f 3mg bw kw
The 3mg term is the weight of the pile representing a second input to the problem; it will be
neglected since it is relatively small compared to the impact force F(t) and since we are only
wanting the transfer function relating f to the input F.
Use the D operator to convert the differential equations to algebraic equations and then use
symbolic math to get the transfer function relating the ground force f(t) to the input force F(t).
Note, d is used instead of D to avoid conflict with symbolic notation for differentiation.
H=
Note that the answer is in terms of s instead of D. This is because transfer functions in
MATLAB are expressed in terms of the Laplace operator s instead of the D operator. In this
case, it does not matter since there are no initial conditions. Use of the Laplace transform is
addressed in the next section of this notebook.
15
Chapter 2. Solving Differential Equations
2.1 Analytical Solutions of Differential Equations Using the Laplace Transform
Obtaining an analytical solution to a differential equation means getting an equation for the
output of interest as a function of time. Contrast this with getting a numerical solution which
generates a list of numbers or a plot of the output of interest as a function of time. In reality, it
is almost always the case that a plot of the solution is desired in the end; consequently, even if an
equation for the solution is obtained, a computer will be used to plot the equation. So, if only a
plot is desired in the end, it might seem burdensome to first get an equation and then turn around
and plot the equation when the plot could have been obtained numerically in a single step.
When using a computer to obtain solutions to differential equations it is very important, when
possible, to have an estimate of what the plot of the solution should look like in advance. It is a
huge risk to simply believe that the computer solution is correct. Consequently, knowing how to
obtain an analytical solution, even if the solution is not carried out to the very end, provides
insights to what the solution should look like. For this reason, an in-depth coverage on obtaining
analytical solutions is included in this document.
In general, for 2nd or higher order differential equations, obtaining an analytical solution requires
that the differential equation be linear. If not linear, either numerical integration is required
resulting in a numerical solution or, the differential equation must be linearized if an analytical
solution is desired. The following sections of this document pertain to the use of the Laplace
transform to get analytical solutions to linear differential equations.
Quite often differential equations for engineering systems contain nonlinear functions
complicating or making it impossible to get analytical solutions. If an approximate solution is
acceptable, it is often possible to replace a nonlinear function within a differential equation with
a straight line approximation enabling us to use the Laplace transform. The difficulty is not in
getting the straight line approximation but rather determining the best straight line to use for the
approximation.
For example, consider the following nonlinear differential equation for x(t) with initial condition
(0 ) = 1. The minus sign on the zero, 0-, refers to time just before t = 0. Initial conditions are
always found at t = 0-, not at t = 0 or at t = 0+. This is very important to remember.
16
x x 3 8 x(0 ) 1
This equation is nonlinear because of the term. The input to this equation is a constant equal
to 8. It is straight forward to demonstrate that the solution for x will start at the initial condition
of 1 and end at a constant final value since as time goes to infinity, will become zero which
allows for us to solve for () = () = . Thus, a justifiable linearization approach is
obtain a straight line approximation for using the two points = and = ; then replace
in the differential equation with the equation for the straight line. The result is
3 7 6
Substituting for 3 in the differential equation gives a linear approximation for the original
differential equation, i.e.
x (7 x 6) 8 x (0 ) 1
+ 7 = 14
It is advised that the linearized differential equation should always be checked to confirm that the
linearization points are satisfied. Setting = 0 gives 7 = 14 = 2 which is correct. The
initial value theorem (see the section on Laplace transforms) or actual solution () is needed to
check that ()=0 = 1.
So, for differential equations with solutions starting at an initial condition and ending at a
different value, the best straight line to use when linearizing the nonlinear function is a line
between the starting and ending values. On the other hand, it is possible for solutions of
differential equations to always remain close (in the neighborhood) to certain values. For
example, consider the mass spring damper system in Section 1.4.1. Suppose the input force is
generated by hitting the mass with a hammer. Intuitively, the impact will cause the mass to
accelerate to the left but eventually the motion with damp out with the position of the mass in the
original location before the impact. Thus, the starting and ending values of the position of the
mass are the same. In such cases, it may be beneficial to use the point and slope method for
getting the straight line equation approximation for the nonlinear function.
For example, suppose the initial condition to the previous nonlinear differential equation
fluctuates but is always very close (in the neighborhood of) to the final value of 2, e.g.
0.18 (0 ) 2.02.
For such cases, a straight line approximation using the point (x = 2) and slope of the function at
x = 2 is preferred, i.e.
3 3
=2 = 8 [ ] = 3(2)2 = 12
=2
17
3 12 16
Substituting this approximation for x3 into the original differential equation gives
+ 12 = 24
For obtaining straight line approximations, consider the following thought process. Suppose we
want a straight line approximation for a nonlinear function of x, f(x), i.e.
f ( x) cx d
Regardless of the approach, it is beneficial to first sketch the function to be approximated with
your best guess for the location of the line.
(1) The first approach using two points on the function f(x) is shown below.
f (x)
cx d
f ( x2 )
f ( x1 )
x
x1 x2
In this case, solve two equations for the two unknowns c and d, i.e.
(1 ) = 1 +
(2 ) = 2 +
Example: Obtain a linear approximation for 3 using the two point method for points y = 0 and
y = 0.1. Be sure to start by sketching 3 and noting the two points for your straight line. The
two equations are
0 = 0 + 0.13 = 0.1 +
Solving gives c = 0.01 and d = 0. Thus, for 0 0.1,
3 0.01 + 0
18
y3
0.001
y 3 .01 y 0
0 0.1 y
(2) The second approach is to use one point on the function f(x) and the slope at that point.
f (x)
cx d
f ( x1 )
x
x1
In this case, use the truncated Taylor series to getting c and d, i.e.
f ( x) cx d f ( x1 ) f ' ( x1 )[ x x1 ]
where c f ' ( x1 ) is the derivative (slope) of f(x) with respect to x at x x1 and
d f ( x1 ) x1 f ' ( x1 ) .
Example: Obtain a straight line approximation for for values of in the neighborhood of
= . . Note, be sure to sketch an estimate of your straight line before doing the math.
Writing the first two terms of the Taylor series for gives
2
3 0.13 + 3=0.1 ( 0.1) = 0.001 + 0.03( 0.1) = 0.03 0.002
19
y3 y3
y cy d 0.03 y 0.002
0.001
0 0.1 y
Example: Water flows into and out of the water tank shown below. The differential equation
for the height H of the water in the tank is
+ 4 = 12
H
4
3
9 16 H
H H
9 H
Obtain a linear approximation for this differential equation by obtaining straight line
approximations for for the two different sets of initial conditions given below. Note, the
equilibrium height of the water in the tank is found by setting = 0, . .
12
= ( 4 )2 = 9.
This is the height where the flow rate out of the tank equals the flow rate into the tank.
20
(a) Assume the initial height of the water in the tank is 16. The height will start at 16 and
end at 9. So, we want to approximate between the points 16 and 9 using the two
point method.
4 = 16 +
3 = 9 +
Solving for c and d gives 0.14286 + 1.71429. It is wise to check the result.
For H=9, 0.14286*9+1.71429 = 3.00003. For H=16, 0.14286*16+1.71429 = 4.00005.
(b) Assume the initial height of the water in the tank is between 8.99 and 9.01. Since the
equilibrium height is 9, the height of the water will always be in the neighborhood of 9.
Thus, the point and slope method at H = 9 will be used to approximate .
1
9 + ( 9) = 0.16666 + 1.5
29
+ 4( + ) = 12
or
+ 4 = 12 4
Problems utilizing this concept: 4.2, 4.25, 4.26, 5.2, 5.25, 5.26, Q2, Q8, H8, E1c, E3b, E3d
21
2.1.3 Properties of the Laplace Transform
Laplace transform of derivatives considering initial conditions
L[ f (t )] sF ( s ) f (0 )
L( f(t )] s 2 F ( s) sf (0 ) f (0 )
L[ f(t )] s 3 F ( s) s 2 f (0) sf (0 ) f(0 )
Note that the Laplace transform of derivatives gives the same result as using the D operator if
all initial conditions are zero; the only difference is s is used instead of D. Note also that the
Laplace transforms of the derivatives contain initial condition terms at time t = 0-.
f (t )
f (0 )
f (0 )
time, t
0 0 0
It is important to note that a function of time may have different values at times 0+ and 0-.
However, for most engineering problems, there will be no difference in the variables at t = 0- and
0+. Differences are caused by impulse inputs. For example, think of a bat hitting a baseball. At
time t = 0- the speed of the ball may be 100 mph towards the batter; at time t = 0+ the speed of
the ball may be 200 mph away from the batter. The bat hitting the ball is effectively an impulse
force input to the ball instantaneously changing the velocity of the ball. The subject of where to
find the initial conditions is controversial; however, initial conditions for real physical
engineering systems are always found at time t = 0- regardless what you may read in another
book or what someone tells you.
f () lim f (t )t sF (s) s 0
It is important to note that the final value theorem can only be used if none of the poles of F(s)
have positive real parts; otherwise, the final value theorem will give the wrong answer. Consider
the following examples:
+ +
() = ()= = [ ] = . ()=
( + ) + =
22
+ +
() = ()= = [ ] = . ()=
( ) =
+ +
() = ()= = [ ]
( + + )( + ) ( + + )( + ) =
= = ()=
+
+ +
() = ()= = [ ]
( + )( ) ( + )( ) =
= = ()=
() +
Problems associated with the final value: 4.2, 4.4, 4.8, 4.13, 4.16, 4.20, 4.21,4.22, 4.23,
4.24,4.25, 4.26, 4.27, 4.37, 4.40, 4.41, 5.2, 5.4, 5.8, 5.13, 5.16, 5.20, 5.21, 5.22, 5.24, 5.25, 5.27,
5.28, 5.37, 5.40, 5.41, Q1, Q2, Q3, Q4, Q10, Q15, Q18, H5,H8, H9, H20, H26, H27, H28, H35,
H36, H37, H40, E1a, E1b, E1c, E2a, E2b, E2c, E3a, E3b, E3c, E3d, E4a, E4c, E5a, E5b, E5c,
E6a, E6b, E6c.
f (0 ) lim f (t )0 t sF ( s) s
+
Example: () = (+)
04
f () lim f (t ) t sF ( s) s0 2
02
4
3
3s 4
f (0 ) lim f (t )0 t sF ( s ) s s 3
s 2 s 2
1
s s
The final value and initial value theorems are useful for checking the accuracy of Laplace
transforms of differential equations and for checking the accuracy of inverse Laplace transform
solutions.
Problems associated with the initial value: 4.4, 4.8, 4.21, 4.23, 5.4, 5.8, 5.20, 5.21, 5.23, 5.26,
Q4, Q10, H4, H9, H18, H39, E1a, E1b, E2b, E2c, E3d, E5a, E5b, E5c, E6a, E6b, E6c
23
2.1.6 Converting Differential Equations to Algebraic Equations Using Laplace Transform
Consider the following 2nd order linear differential equation for y with initial conditions
(0 ) (0 ); the input to the differential equation is ().
my cy ky bf
Laplace transforming both sides of the equation, considering that m, c and k are constants that
have not yet been assigned numerical values, gives:
b y (0 )( ms c) my (0 )
Y ( s) 2 F ( s )
ms cs k ms 2 cs k
Y ( s) H ( s) F ( s) I ( s)
where H (s) is called the transfer function relating the Laplace transform of the input F (s) to the
Laplace transform of output Y (s) , i.e.
b
H ( s) 2
ms cs k
Note that the transfer function does not contain any of the initial condition terms. Or, more
importantly, if only the transfer function is needed, it doesnt matter what the initial conditions
are and the transfer function can be written simply using the coefficients of the differential
equation skipping the formal process of Laplace transforming the differential equation.
I (s) exists because of the nonzero initial condition terms; if the initial conditions are zero, then
I (s) is zero. F (s) remains a general expression until the input (t) is specified. The Laplace
transform for various common inputs is presented in the next section.
24
2.1.7 Common Inputs and Their Laplace transforms
2.1.7.1 Step Functions and Constants
One of the most common or frequently experienced inputs is a step function.
f (t )
0 time, t
Using the integral definition of the Laplace transform, the Laplace transform for a step function
of magnitude A is found as follows:
F ( s) Ae st dt
0 s
e
A st
0
A
s
0 1 A
s
It is important to note that a constant of A for the input has the same Laplace transform. This is
because the integral for F(s) starts at t = 0; it doesnt matter if the input was 0 or A prior to t=0.
When performing simulations, however, there may be a difference in the simulation results for a
step input and a constant input if the differential equations contain input derivatives.
f (t )
0 time, t
F ( s) Ae st dt
0 s
e
A st
0
A
s
0 1 A
s
Problems with step inputs: 4.9, 4.10, 4.13, 4.16, 4.22, 4.24, 4.25, 4.26, 4.30, 4.36, 4.37, 4.43,
5.9, 5.10, 5.13, 5.16, 5.21, 5.24, 5.25, 5.26, 5.27, 5.30, 5.36, 5.37, 5.40, 5.41, 5.43, Q11, Q12,
Q15, Q18, Q21, H5, H6, H7, H9, H15, H16, H20, H21, H21, H26, H27, H32, H35, H36, H40,
E2a, E2c, E3a, E3b, E3c, E3d, E5b, E5c, E6b, E6c
25
2.1.7.2 Pulse and Impulse Functions
f (t )
A (t )
0 time, t
A simple derivation for the Laplace transform of an impulse function is to consider a pulse with
area A such as shown below
f (t )
A
b
0 b time, t
The Laplace transform for this pulse is obtained using the integral definition, i.e.
F ( s)
0
b A st
b b
e dt 0e st dt
bs
e
A st b
0
bs
A bs
e 1
The limit of f (t ) as b0 is a very high function with a zero width; the area is still equal to A
regardless of the size of b. The limit of F(s) as b0 is found using LHopitals rule to be A, i.e.
[ 1]
()=0 = ( ) =
=0
Problems with impulse inputs: 4.4, 4.6, 4.8, 4.24, 4.26, 4.41, 5.6, 5.8, 5.24, 5.25, 5.26, Q7, Q10,
H4, H5, H9, H10, H11, H12, H15, H16, H19, H20, H21, H27, H36, H38, E3a, E3b, E3d, E4c,
E5c, E6c,
26
2.1.7.3 Exponential Functions
bt
The Laplace transform for an exponential input, shown below and denoted by f (t ) ae is
a
F (s) .
sb
f (t )
ae bt
0 time, t
Periodic functions repeat themselves in a finite period of time. Equations can be obtained for
periodic functions using the Fourier series which is a finite sum of sine and cosine terms. See
sections 2.2.4 and 2.4.1.
If () = Asin() () = 2 +2. If () = Acos() () = 2 +2
The use of partial fractions to get an inverse Laplace transform is preferred if a computer is
available to factor the denominator and then compute the partial fractions. Note, if the
denominator is not already factored, then a computer will definitely be required to factor any
polynomial 3rd or higher order. An M-file pfract has been written for generating partial
fractions; see Chapter 9. For cases where the denominator is already factored, a much more
efficient method for getting the inverse Laplace is by means of the residue theorem which will be
explained in section 2.1.8.2.
Any Laplace transform with numerator order not greater than the denominator order can be
expressed as the sum of its partial fractions. If the numerator order is not greater than the
denominator order and there are no repeated poles, each partial fraction will be one of three
possible forms. In general, the partial fractions for some general Laplace transform H(s) may
include a constant K, 2nd order partial fractions for complex poles, and 1st order partial fractions
for real poles, i.e.
a1 s b1 a2 s b2 C1 C2
H ( s) K ... ...
( s r1 ) 1 ( s r2 ) 2
2 2 2 2
s p1 s p2
27
The constant K only occurs if the order of the numerator polynomial equals the order of the
denominator polynomial.
For example, the partial fractions of the following Laplace transform F(s) contains all three of
the possible partial fraction formats:
Based on the discussion pertaining to inputs in section 2.1.2.6, the first partial fraction, 2,
corresponds to an impulse with area (or magnitude) of 2. The second partial fraction
corresponds to a constant (or step) with magnitude of 3. The third partial fraction corresponds to
5t
an exponential term, 4e . The fourth term can be shown to correspond to a sine wave with an
exponentially decaying amplitude, 9.0588 3 sin(4 + 2.0591).
The general form for a 2nd order partial fraction with complex poles is denoted by
as b
(s d ) 2 2
ce dt sin(t ) ,
where
c a(d j ) b / and = [(( + ) + ].
A sine wave with an exponentially decaying amplitude is shown below
f (t )
ce dt sin(t )
0 time, t
8s 7
So, the inverse Laplace of is 9.0588e3t sin(4t 2.0591). Thus, using
s 6s 25
2
superposition, the total inverse is the sum of the individual partial fraction inverses, i.e.
28
So, if a Laplace transform is expressed in partial fraction format, then these simple formulas can
be used to get the inverse Laplace transform directly without a computer or tables.
2 3
L1[ F ( s )] L1 5 5 ( t ) 2 3e 4 t
s s 4
Consider the mass/spring/damper system shown below. This system was also introduced in
section 1.4.2; however, in 1.4.2, b was equal to 5 and the output of interest was the ground force
f(t). Changing the output of interest to z(t), it can be shown that the Laplace transform Z(s) for
the displacement z(t) for a unit impulse input is given by
100 4 + 43 3 + 74 2 + 65 + 36
() = [ ]
13 6 + 54 5 + 1.16 4 + 1.37 3 + 974 2 + 38 + 19
F(t)
M=10 kg
b=100 Ns/m
M z k=1000 N/m
k b
M v
k b
M w
k b
Using the formula for complex partial fractions above, the inverse Laplace of Z(s) can be shown
to be
z(t ) 0.0125e 0.991t sin(4.34t ) 0.0036e 7.77t sin(9.75t ) 0.0014e 16.2t sin(7.81t )
Some of these examples demonstrate the need to be able to use a computer to compute the partial
fractions if partial fractions are desired. The next section introduces a MATLAB m-file pfract
for computing partial fractions.
29
Obtaining Partial Fractions Using pfract in MATLAB
In general, any Laplace transform can be expressed in partial fraction format. Although it is
possible to obtain the partial fractions manually, a computer will be required to factor the
denominator polynomial if the order is greater than 2. Since a computer is to be used to factor
the denominator, it might as well be used at the same time to obtain the partial fractions. An
M-file named pfract for computing partial fractions has been written and is included in the last
chapter of this document. This program factors the denominator and then computes the partial
fraction numerator coefficients. The program is limited to first order (non-repeated) real or
complex poles. For example, consider the following Laplace transform H(s):
10 3 + 6 2 + 28 + 150
() = 3
2 + 16 2 + 74 + 100
The MATLAB commands for getting the partial fractions and the results are
>> [R]=pfract(num,den)
(1) = 5
1.118
(2) =
+2
38.12 101.5
(3) =
2 + 6 + 25
Note that one of each of the three possible partial fraction formats occur in this example. The
poles are -2 and 3 4. The partial fraction 5 occurs because both the numerator and
denominator are 3rd order.
The residue theorem is the simplest way to get the inverse Laplace transform if you do not
already have the function in partial fraction format and if the denominator is already factored;
the numerator order must be at least one less than the denominator order. For cases where
the numerator order equals the order of the denominator, long division must first be used to get
an appropriate function for the residue theorem. The formula for the inverse Laplace transform
of a general function F(s) is as follows:
30
() = 1 {()} = () ()
( + ) ()=
For example:
2 2 2
L1 ( s 3)e st ( s 5)e st
( s 3)( s 5) ( s 3)( s 5) s 3 ( s 3)( s 5) s 5
e 3t e 5 t
Consider the following Laplace transform with a 1st order pole, a 2nd order pole and a 3rd order
pole.
5
() =
( + 2)( + 4)2 ( + 10)3
The pole -2 is first order; the pole -4 is second order; and the pole -10 is third order.
To get the residue for an nth order pole p in the denominator of F(s), the formula is
1 1 [( + ) () ]
= [ ]
( 1)! 1 =
An example demonstrating the procedure for a 1st order pole at -3 and for a 2nd order pole at 5
is as follows:
2 2e st 1 d 2e st
L1 2
( s 3) 2
( s 5) 2 2
( s 3)( s 5) ( s 3)( s 5) s 3 ( 2 1)! ds ( s 3)( s 5) s 5
0.5e 3t te 5t 0.5e 5t
Note, it is advised to write the denominator in factored format before beginning the residue
process to avoid errors. For example
8 + 16 8 + 16 2 + 4
= =
4 2 + 28 + 40 4( + 2)( + 5) ( + 2)( + 5)
31
Shortcut for Complex Poles, r j
For Laplace transforms F(s) with complex poles, the two residues for a complex pair will
combine and simplify to an exponentially decaying sine wave. Realizing this end result, enables
one to use a shortcut and obtain the resulting combined solution in a single step instead of the
two steps that would be required for each of the two complex conjugates. Consider the
following Laplace transform with a pair of complex poles :
N (s)
F ( s)
(s r j )(s r j ) D(s)
where N(s) is the numerator of F(s) and D(s) is what remains in the denominator of F(s) after
removing this specific complex pair. The sum of the residues for the complex pair of poles can
be shown to simplify to the following expression which we will use for the short cut:
e rt
[residue for r j ] + [residue for r j ]= M sin(t )
where
N ( s)
M [(s r )2 2 ]F ( s) s r j
D( s) s r j
and
N ( s)
angle{[(s r )2 2 ]F ( s) s r j } angle
D( s) s r j
s5 N ( s)
Y ( s)
s( s 2 j3)( s 2 j3) D( s)( s 2 j3)( s 2 j3)
The inverse Laplace of Y(s) consists of the sum of three residues, i.e.
e 2t
y(t ) [residue _ for _ s 0] M sin(3t )
3
32
5 e 2t
y (t ) M sin(3t )
13 3
+ +
=| | = . = ([ ] ) = . .
=+ =+
If any of the poles are complex with a zero real part, then it is important to note that the
exponential term = = ; thus, the multiplier on the sine function does not go to zero
as . This will always happen if the input to a transfer function is a sine or cosine wave
since the denominator of the Laplace transform of sine and cosine functions have a zero real part.
Consider the previous example but with the real part of the complex poles equal to zero.
s5 s5
Y (s) 2 2
s(s 0 j3)(s 0 j3) s(s 3 )
e0t
y(t ) [residue _ for _ s 0] M sin(3t )
3
5 e0t
y(t ) 2 M sin(3t ) 0.556 0.648 sin(3t 2.6)
3 3
+ +
=| | = . = ([ ] ) = . .
=+ =+
For cases of a sine function input to a transfer function, it is not uncommon to be interested in the
inverse Laplace transform of the output after the transient portion of the solution has gone to zero
or only for large values of time (t ). If the poles of the transfer function all have negative
real parts, then the portion of the inverse Laplace transform associated with the poles of the
transfer function will all go to zero as t . Thus, the only thing left will be the portion of the
inverse associated with the input poles which will have zero real part which means this portion
does not go to zero but remains a sine or cosine function forever. For example, suppose we have
( + )
() = ()() = [ ] ()
( + )( + )[( + ) + ]
where the input () = ( )() = + . The transfer function G(s) is the
expression in the brackets; note that all of the poles of G(s) have negative nonzero real parts.
Thus, the portions of the inverse Laplace associated with these poles will go to zero as t .
So, as t , the only portion left will be the portion of the inverse associated with the poles of
the input R(s). Thus,
33
() = + + + |()|=+ ( + ) = |( )| ( + )
( + )
|()| = |[ ]| = |. + . | = .
( + )( + )[( + ) + ]
= (. + . ) = .
() = . ( + . ) = . ( + . )
The main points to be learned are that for a system (transfer function) with a sinusoidal input, the
output will converge to a sinusoidal function at the same frequency as the input with the
amplitude of the output equal to the input amplitude multiplied by the magnitude of the transfer
function using the input frequency; there will be a phase difference in the input and output
calculated using the input frequency. This also applies to cosine inputs.
The following system has r(t) = 4sin(0.3t) for the input. What will be the output y(t) at steady
state conditions (after all transients have died out)? How much greater or smaller is the output
amplitude compared to the input amplitude?
+ . +
() = [ ] ()
+ + +
Problems containing inverse Laplace transforms: 4.6, 4.23, 4.27, 4.30, 4.35, 4.36, 4.37, 4.43,
5.5, 5.6, 5.9, 5.22, 5.23, 5.25, 5.26, 5.27, 5.30, 5.35, 5.36, 5.40, 5.43, Q5, Q6, Q8, Q12, H2, H3,
H4, H6, H10, H12, H13, H19, H26, H27, H37, H38, H39, E2a, E2b, E2c, E3a, E3b, E3c, E3d,
E4B, E4c,E5c,E6C
34
2.1.8.3 Using MATLAB to Plot the Inverse Laplace Transform Without Getting an
Equation for the Inverse Laplace Transform
The previous sections of this document have focused on using the Laplace transform to get an
equation for the solution to a linear ordinary differential equation using the inverse Laplace
transform. This section introduces how to use the Laplace transform and MATLAB to get a plot
of the solution without having to first get an equation for the solution. For cases where only
a plot of the solution is desired, this approach to getting a plot solution represents the ultimate in
simplicity since there is minimum chance for error and minimum effort required to get a plot.
Also, this method can be used for cases with nonzero initial conditions and/or unusual inputs; the
Laplace of the input must be known.
Suppose you have a Laplace transform Y(s). If an equation for the inverse Laplace, y(t), is
desired, then the only options are to use the partial fraction or residue methods mentioned above
and use inverse Laplace to get the equation. If however, an equation is not needed but only a
plot of y(t), then it is very convenient to use the impulse command in MATLAB to get the plot
directly from the Laplace transform. If you pretend that Y(s) is the transfer function for a
system with a unit impulse input, then Y(s)*1 = Y(s) is the Laplace of the output. Thus, entering
Y(s) into MATLAB as a transfer function (pretending that it is a transfer function) and then
using the command impulse(Y) gives a plot of y(t). For example, to get a plot of the inverse of
2
Y ( s) 3
s 13s 55s 75
2
>> Y=tf(2,[1 13 55 75]) %This MATLAB command defines the transfer function above.
>> impulse(Y) %This MATLAB command generates a plot of y(t)
A more versatile use of the impulse command allowing labeling and line width and color control
is as follows:
0.025
0.02
0.015
y
0.01
0.005
0
0 0.5 1 1.5 2 2.5 3
time, sec.
35
For a second example, consider the problem in section 2.1.2.5, i.e.
1 y (0 )(ms c) my (0 )
Y ( s) 2 F ( s )
ms cs k ms2 cs k
If the input is a unit step, then F(s)=1/s; Y(s) becomes
If numerical values are assigned to the initial conditions and the parameters m, c, and k and then
the final expression for Y(s) is entered as transfer function (pretend), then the command
impulse(Y) gives a plot of the inverse of Y(s) which is y(t). Thus, for m=10, c=0.05, k=50,
y(0-)=6, and (0 ) = 2:
This gives us a plot of the solution to the original differential equation even though the input was
not an impulse but rather a step input and for a case of nonzero initial conditions.
Problems utilizing this concept: H4, H5, H10, H11, H12, H15, H16, H19, H20, H27, H36, H38
The way to determine the individual modes is to express the transfer function of the system in
partial fraction format. Each partial fraction represents one of the modes of the system. Modes
may either be first order or second order. The dominant mode usually has the largest eigenvalue
time constant. A complex mode with a small damping ratio may dominate other second order
modes with larger damping ratios depending on the time constants.
The procedure for computing the modes is to use the MATLAB m-file pfract on the numerator
and denominator polynomials of the system transfer function. Consider the mass/spring/damper
system introduced in section 2.1.2.7.
Suppose that the output of interest is the displacement z(t) and the input is the force F(t). It can
be shown that the transfer function H(s) relating Z(s) to F(s) is the following:
36
() = ()()
100 4 + 43 3 + 74 2 + 65 + 36
=[ ] ()
13 6 + 54 5 + 1.16 4 + 1.37 3 + 974 2 + 38 + 19
The following MATLAB commands generate the individual modes of this system:
To determine if any of these modes dominate the response, the damp command is used to
generate the eigenvalues, i.e.
>> damp(H)
Comparing the time constants reveals that the response of the first mode will last approximately
5 seconds which is much greater than the others. Also, according to the damping ratios, the first
mode is significantly under damped compared to the other modes. Thus, according to the
eigenvalues, the first mode appears to dominate the total system response.
Comparing the impulse responses of the individual modes with the total system impulse response
demonstrates the dominance of the first mode. The results of the following MATLAB
commands are shown in the figure below:
Note that the response of the dominate mode is almost identical to the total system response.
37
-3
x 10 Comparing individual mode responses
10
first mode
second mode
third mode
all 3 modes
displacement z per unit of force impulse
-5
0 0.5 1 1.5 2 2.5 3 3.5 4
Time (seconds)
If the differential equation is linear, there are many options depending on the format of the
equation. For example, for a transfer function format or a state variable matrix format with a
step or impulse input, use of the MATLAB commands step or impulse is very straight
forward. Transfer functions and state variable formats with other inputs such as sine waves,
pulses, or other functions of time including random functions are best handled using lsim. For
linear state variable matrix equations with nonzero initial conditions, lsim can be used even if
there is also an input; initial can be used if there are nonzero initial conditions and no input.
38
2.2.3 Using the step command in MATLAB
The command step gives a plot of the solution to a differential equation expressed in transfer
function format or state variable format if the input is a unit step. For example, if G is a transfer
function for a system, a plot of the step response of a step with magnitude 23 is obtained using
the following command:
>> step(23*G)
Repeating the examples in section 2.1.3 for the mass/spring/damper system but this time for a
unit step input gives the following results:
>> step(H1,'r-.',H2,'r:',H3,'k',H,'k.',4)
>> title('Comparing individual mode step responses')
>> ylabel('displacement z per unit of force input, m/N')
>> legend('first mode','second mode','third mode','all 3 modes','Location','NorthEast')
-3
x 10 Comparing individual mode step responses
4.5
first mode
4 second mode
third mode
displacement z per unit of force input, m/N
2.5
1.5
0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4
Time (seconds)
The dc gain for a transfer function can be computed by setting the Laplace variable s to zero.
Notice in the figure above for the step responses of the individual modes, each mode has a
different dc gain; however, the sum of the mode dc gains must and does equal the dc gain of the
39
total transfer function. As a side note, if the input to a transfer function is a constant, then the
transfer function is multiplied by the constant over s to get the Laplace of the output. When
using the Final Value theorem, multiplying by s cancels the s from the input; so, when setting s
equal to zero, you get the same result had you set s equal to zero in the transfer function.
Problems utilizing this concept: 4.43, H5, H20, H31, H28, H36, E2c
F (t ) 2 sin(7t ) 0.5sin(10t )
The following MATLAB code generates 4 seconds of time values every 0.01 seconds and then
generates a value for F at each of the time values. The lsim command generates a numerical
solution for the output variable y corresponding to the system H with input F(t). When using
lsim, you must know how long to run the simulation and a reasonable time increment; these
values can usually be obtained from the system eigenvalues and the input frequencies; the time
increment should be on the order of 1/(10M) where M is either the largest eigenvalue magnitude
or the largest input frequency in rad/sec, whichever one is greater.
>> t=0:.01:4;
>> F=2*sin(7*t)+0.5*sin(10*t);
>> [y]=lsim(H,F,t);
>> plot(t,y)
>> title('Example of a general input function')
>> xlabel('Time (sec)')
>> ylabel('y(t)')
f(t)
T
F
mT t
An m-file for pulse functions is provided with the other m-files at the end of this document and
has been used to generate a pulse series with T=0.25, F=1, and m=6. N=5 where N is the
number of pulses to be generated and NumPPP=10 where NumPPP is the number of data points
per pulse. The period of this pulse series is 1.5 seconds which is the time between pulses. For
the mass/spring/damper system in section 2.1.8.1, 1.5 seconds is approximately equal to the
inverse of the first mode frequency in Hertz (4.34/2).
>>T=0.25;m=6;F=1;N=5;NumPPP=10;
>> [f,t] = PulseSeries (T,m,F,N,NumPPP);
0.8
pulse function amplitude
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7
time, sec.
>> [z]=lsim(H,f,t);
>> plot(t,z,'k','LineWidth',2)
>> xlabel('time, sec.')
>> ylabel('displacement z per unit of pulse amplitude')
>> title('mass/spring/damper response with pulse series input')
41
-3
x 10 mass/spring/damper response with pulse series input
3
2.5
displacement z per unit of pulse amplitude
1.5
0.5
-0.5
-1
-1.5
0 1 2 3 4 5 6 7 8
time,sec.
= + 0 = + 0(0 ) 0
Consider the following example noting that B and D must be defined with some arbitrary values
to enter a state space system:
1.5
1
Amplitude
0.5
-0.5
0 0.5 1 1.5 2 2.5 3
Time (seconds)
42
2.3 Using MATLAB to Get the System Response Using Numerical Integration
There are many numerical integration algorithms available in MATLAB; the selection depends
on the complexity of the differential equations being solved. For 90% of the problems, ode45
with either a variable step or fixed step will suffice. There is a vast amount of documentation
available: help ode45 and help odeset. I prefer the variable step option which is the default
but am required to use the fixed step option if using a generated input data sequence with a fixed
time increment between data points; this is almost always the case for input data that has been
generated prior to the simulation process such as with random or stochastic inputs.
In general, numerical integration algorithms require that the differential equations be expressed
in state variable format. See Chapter 3 for an in-depth coverage on obtaining different state
variable formats depending on the specific problem.
2. Repeat problem 1 above but this time assume that the differential equation has
66v 3 in it instead of 66v . Plot both solutions on the same graph to demonstrate
the effect of the nonlinearity.
[t,xn]=ode45(@ex2diffeqns,[t],[1 .5 .2]);
plot(t,xn(:,1)
function dx=example2(t,x)
dx=zeros(3,1);
dx(1)=x(2);
dx(2)=x(3);
dx(3)=130-65*x(1)-33*x(2)^3-9*x(3);
end
43
Plotting the results of both simulations for comparison
>> plot(t,x(:,1),'r',t,xn(:,1),'.k')
Homework #4
Case 1 Linear
v(t)
Case 2 Nonlinear
1.5
1
0 0.5 1 1.5 2 2.5
time, t sec
3. Repeat Part 2 above but this time change the input to a random input instead of a step
input. See section 8.3.3 for generating random inputs.
% m-file demonstrating how to get and use the random input values
% in the derivative equations
function dx=example3(t,x)
global U step
dx=zeros(3,1);
n=fix(t/step+1); %Determines the current point in time
u=U(n,1); %Defines u as the input amplitude at the current time
dx(1)=x(2);
dx(2)=x(3);
dx(3)=130*u-65*x(1)-33*x(2)^3-9*x(3);
44
function[GY]=dpsd(f)
GY=0.0025/f^2;
end
1.5
0.5
v
-0.5
-1
0 5 10 15 20 25
Time, sec.
2.3.2 Example Simulation Using Options and Event Functions with ode45
Type help odeset and doc odeset to get detail instructions for event functions.
45
For a second example involving events functions, consider the following differential equation.
66v 130v 22u 260u v(0 ) 1 v(0 ) 0.5 v
2v 18v (0 ) 0.2
Putting the differential equation in state variable format (simultaneous 1st order differential
equations):
x1 v
x2 v
x3 v 11u
x1 x2
x2 x3 11u
x3 130u 65 x1 33 x2 9( x3 11u ) 31u 65 x1 33x2 9 x3
Create an m-file named 'StartSim' ; actually, it can be any name you choose. The
simulation is to run from t = 0 to 2.5 sec. Note below how the start and end times for the
simulation are entered as well as how the initial conditions are entered. Also note that it
references the m-file DerEqns where the derivative equations for the state variables have been
entered; the name of this m-file can also be any name you choose.
% StartSim
[t,X]=ode45(@DerEqns,[0 2.5],[1 .5 .2]);% This command returns a vector of t
% values and matrix X which contains the values for the state variables at each t %value.
The first column of X is x(1), the 2nd column of X is x(2), etc.
% You must define the output of interest, y. y=X(:,1);
% This command assigns y to be x(1), all of the values of x in the first column
% If you want a plot of , then y=X(:,2). To plot v
, use y = X(:,3)+11*2;
plot(t,y)
title('Numerical Simulation Example')
xlabel('Time, sec.')
ylabel('v, m')
Note, when computing the product of two variables represented by vectors, the dot
product (term by term multiplication) is required. For example, if the output of
interest is v2, use y=X(:,1).*X(:,1) or y=X(:,1).^2. The dot is also required for dividing
term by term: y=X(:,1)./X(:,2).
function dx=DerEqns(t,x)
N=3; % Number of state variables to be numerically integrated
dx=zeros(N,1); % This tells the computer how many dx equations to look for
dx(1)=x(2);
46
u=2; % Defines the input which can be a function of time t such as u=sin(3*t) or u=exp(-6*t);
dx(2)=x(3)+11*u;
dx(3)=31*u-65*x(1)-33*x(2)-9*x(3);
end;
To stop the simulation for a specified event such as an increasing x(1) reaching a value of 4 , you
need:
options=odeset('events',@StopSim);
[t,x]=ode45(@DerEqns,[0 2.5],[1 .5 .2],options);
plot(t,x(:,1)) % This plots all of the values of x(1). For x(2), use x(:,2).
title('Numerical Simulation Example')
xlabel('Time, sec.')
ylabel('v, m')
2.4 Usi ng MATLAB to Get the System Steady State Response for Periodic Inputs
Recall for a system with output y(t), transfer function H(s), and input F(t), we can write
Y ( s) H ( s) F ( s)
47
F (t ) F0 sin(0t )
Thus,
0
F ( s) F0
s 02
2
and
0
Y ( s) H ( s) F0
s 02
2
Assuming that the poles of H(s) all have negative non-zero real parts, the time response of each
one of the modes corresponding to these poles will go to zero as t . Thus,
angle[ H ( s) s j ]
0
+ 2 + 2
() = ()() = [ 2 ] () = [ 2 ] ()
+ + + 2 + 2
The MATLAB command bode provides both the magnitude and phase plots as a function of
frequency. The magnitude and phase plots for the mass/spring/damper system above are shown
in the figure below for different values of the damping ratio. The magnitude is in decibels (dB)
which is by definition 2010 |(|. The frequency has been normalized by the natural
frequency. Note for the lightly damped case, the peak of the magnitude plot occurs at
approximately the normalized frequency of 1 which corresponds to .
Bode Diagram
10
0
Magnitude (dB)
-10
-20
-30
0
Phase (deg)
-45
For a second frequency response example, consider the mass/spring/damper system shown
below.
F(t)
M=10 kg
c=100 Ns/m
M z k=1000 N/m
k c
M v
k c
M w
k c
Transfer function:
100 s^4 + 4000 s^3 + 70000 s^2 + 600000 s + 3e006
H(s) = ----------------------------------------------------------------------------------
1000 s^6 + 5.e4 s^5 + 1.1e6 s^4 + 1.3e7 s^3 + 9e7 s^2 + 3e8 s + 1e9
49
>> bode(H)
>> bode(H,{1,10})
50
Repeating this example but this time using a much smaller damping:
M=10 kg
F(t)
c=5 Ns/m
k=1000 N/m
M z
k c
M v
k c
M w
k c
>> bode(H)
51
It is of interest to compare the resonant peaks in the magnitude plot with the eigenvalue
frequencies. For lightly damped modes, these peaks occur at approximately the mode
frequencies.
>> damp(H)
Eigenvalue Damping Freq. (rad/s)
-4.95e-002 + 4.45e+000i 1.11e-002 4.45e+000
-4.95e-002 - 4.45e+000i 1.11e-002 4.45e+000
-3.89e-001 + 1.25e+001i 3.12e-002 1.25e+001
-3.89e-001 - 1.25e+001i 3.12e-002 1.25e+001
-8.12e-001 + 1.80e+001i 4.50e-002 1.80e+001
-8.12e-001 - 1.80e+001i 4.50e-002 1.80e+001
Problems utilizing this concept: 4.34, 5.33, H13, H28, H39, E5b, E6b, Section 2.1.8.2B
2.5 Using MATLAB to Get Lower Order Approximations for Transfer Functions
1. Modal Approximations: Drop the least dominant modes and if the original DC gain is a
constant, rescale the transfer function approximation to get the original dc gain.
F(t)
M=10 kg
c=100 Ns/m
M z k=1000 N/m
k c
M v
k c
M w
k c
52
0.05431 0.03493 0.01076
H ( s) 2 2 2
s 1.981s 19.81 s 15.55s 155.5 s 32.47 s 324.7
Dropping the two least significant modes and then rescaling to get the original dc gain of 0.003
gives
0.05431 (0.003)19.81
H ( s) 2
s 1.981s 19.81 0.05431
>> H3
Transfer function:
0.05431
---------------------
s^2 + 1.981 s + 19.81
>> Happ=H3*0.003*19.81/0.05431
Transfer function:
0.05943
---------------------
s^2 + 1.981 s + 19.81
>> dcgain(Happ)
ans =
0.0030
-3
x 10 First mode step response accuracy
4.5
full transfer function
4 rescaled first mode approxiamtion
3.5
displacement z, meters
2.5
1.5
0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4
time, sec.
53
Example 2: Consider the transfer function for the suspension system shown below.
Vehicle Z
Suspension
Suspension
Transfer function:
Remainder
K = []
5 s + 36
----------------
s^2 + 20 s + 244
5s 36 4s 9
G( s) 2 2
s 20s 244 s 4s 13
Approximating G(s) by the dominant of these two modes and then rescaling to make the
approximation have the dc gain of the original transfer function gives
4s 9 13 36 9 4.8525s 10.918
Ga ( s) 2
s 4s 13 9 244 13 s 4s 13
2
54
>> step(G,Ga)
Conclusion: The 2nd order modal approximation gives a fairly accurate step response in
comparison to the step response of the original 4th order suspension model. Modal
approximations dont always work well for systems that dont have dominant modes.
Introduction
There is often the need to approximate the transfer function for a dynamic system by a lower
order linear ordinary differential equation. This is especially true for time domain simulation of
infinite order distributed parameter systems and for control system design problems where the
order of the plant is very high or infinite. This paper introduces an approach for obtaining lower
order rational polynomial transfer function approximations for high or infinite order systems
using MATLAB algorithms for matching the frequency response characteristics of the original
and approximating transfer functions.
The problem of obtaining lower order transfer function approximations has been researched
extensively for many years. For certain classes of problems, the Routh approximation algorithm
[1]1 has been one of the most effective and efficient approaches to this problem. Some of the
more important advantages of the Routh method is that it can be programmed into a digital
computer, it preserves the asymptotic stability properties of the original system, and the initial
and final values of the transfer function approximation are the same as for the original transfer
function. To utilize the Routh approach, the poles and zeros of the original transfer function to
be approximated must be known; for cases such as distributed parameter systems, which may be
infinite order, it is necessary to use series approximations to identify the dominant poles and
zeros. This paper introduces a new approach to obtaining rational polynomial transfer function
approximations that very accurately match the frequency response properties of the original
1
Numbers in brackets refer to publications in the list of references.
55
transfer function over a designated frequency band. Not only are the significant properties of the
original transfer function preserved as with the Routh method, the poles and zeros of the original
transfer function do not have to be known.
Due to increases in digital computer speed and memory, many efficient and effective
algorithms have evolved for system identification from frequency response data [2-12]. This
paper pertains to the application of some of these algorithms to obtain transfer function
approximations. The approach is to match the frequency responses using least squares. Levi [8]
formulated a technique based on a linear least-square criterion to minimize output errors in the
frequency domain between an actual function and a rational polynomial transfer function
approximation. The actual function is represented by frequency response data of the system
taken from measurements or generated directly from an analytical function. The polynomial ratio
is a Laplace domain transfer function with real coefficients. However, as indicated in Levis
work, the original technique was restricted to only systems without poles on the imaginary axis.
Sanathanan and Koerner [12] resolved this problem by introducing an iterative search method
which also eliminates fitting errors occurring at a low frequencies commonly associated with a
least square criteria. Further improvements in the iterative minimization approach were achieved
using the damped Gauss-Newton method [10]. These refined techniques are utilized in an m-file
named invfreqs available in the Signal Processing Toolbox within MATLAB. The algorithm
presented in this paper utilizes this m-file for single input/single output systems. By formulating
the new transfer function in the MATLAB environment, the results are available for further time
domain simulations and analyses.
Two examples are presented in this paper. The first demonstrates the use of the algorithm to
achieve lower order approximations for a linear system transfer function with a finite order
numerator and denominator; the system is a lumped parameter model for the axial vibrations in a
beam. A simple version of the inverse frequency algorithm, tfapprox.m, is used in the first
example which only requires knowledge of the original numerator and denominator, the desired
reduced order of the approximation, and the frequency range of interest to match the frequency
response. The M-file tfapprox.m is particularily useful for reduced order control problems or
reduced order simulation problems where higher frequency modes are relatively insignificant.
The second example pertains to achieving transfer function approximations for a
distributed parameter system with an infinite number of poles and zeros; a somewhat more
comlex version of the inverse frequency algorithm is used which attempts to determine the
necessary frequency range for the desired finite order model. This version of the algorithm is
particularily useful for obtaining an ordinary differential equation model for time domain
simulations from infinite order frequency domain models normally derived from solving a set of
partial differential equations. For these type problems, the importance is placed on time domain
simulation accuracy instead of simply obtaining a reduced order model as in Example 1.
Example 1
Consider the continuous beam shown in figure 1 with input force Fi and output force Fo. The
input force might typically be provided by a pile driver and the output force represents the load
force associated with driving the pile into the ground. This beam has an infinite number of
modal frequencies. However, if the beam model is approximated by five lumped mass-spring-
damper systems as shown in figure 2, then the model is only 10th order.
56
Fi Fo
Figure 1 Schematic of a continuous beam with input force Fi and load force Fo.
ki ki ki ki ki
Fi m mi mi mi mi Fo
i
bi bi bi bi bi
Figure 2 Schematic of a lumped parameter model approximation for the beam in fig. 1.
Using ki=8 N/m, mi=2 Kg, and bi=0.8 Ns/m, the transfer function between the input force and the
output force in terms of the Laplace operator s can be shown to be
A lower order approximation for this transfer function should match the frequency response
of the original transfer function from zero frequency out to some designated maximum
frequency, which would probably be determined by the input frequency. To estimate the
minimum order approximation that will achieve this objective, it is helpful to either know the
modal frequencies of the original transfer function or to examine its frequency response.
Factoring the denominator polynomial of the original transfer function reveals the following
modal frequencies: 0.569, 1.66, 2.60, 3.32, and 3.77 rad/s.
In general, the order of the approximation must be at least two times the number of second
order modes to be matched plus one or two additional orders to allow for a low frequency match
as well as a match at the necessary modes. For cases where the poles and zeros of the original
transfer function are known, the inputs to the MATAB command include the numerator and
denominator of the original transfer function, the desired approximation order, the lower
frequency bound (usually a small frequency but not zero), and the upper frequency bound. The
MATLAB m-file tfapprox.m is provided with the other m-files referenced in this notebook.
This m-file is good for any transfer function to be approximated when the original numerator and
denominator polynomials are known.
For a demonstration of using tfapprox.m, assume it is desired to match as accurately as
possible the first two modes of the original 10th order system represented by (1). A 6th order
approximation is chosen over the frequency range of 0.1 to 2.0; the numerator and denominator
of (1) are denoted by n10 and d10 respectively. The corresponding MATLAB command and the
resulting approximation are as follows:
57
[n6,d6]=tfapprox(n10,d10,6,0.1,2.0)
If it is desired to match only the first mode, then a command and the results for a 4th order
approximation from 0.1 rad/sec out to an upper frequency bound of 1.0 rad/s are given by
[n4,d4]=tfapprox(n10,d10,4,.1,1)
Comparisons of the frequency responses of these two approximations with the original
transfer function are shown in figure 3.
58
It is of interest to note in figure 3, the 4th order approximation is essentially identical to the
original in magnitude and phase out to the specified upper frequency bound of 1.0 rad/s. And,
the 6th order approximation is also identical to the original out to the specified 2.0 rad/s.
A more quantitative method for evaluating the accuracy of the approximations is to compare
the mode frequencies and damping ratios. The comparisons are shown in tables 1 and 2 for both
this least-squares method and for the Routh method. It is of interest to note that the least-squares
curve fit method matches the mode frequencies and damping ratios exactly over the specified
frequency range.
Impulse response comparisons are shown in figure 4 for the least-squares approximation
method. The accuracy of the approximations in the time domain is quite evident.
1 2 3 4 5
4th order 0.572 2.23
Routh
4th order .569 1.54
least-squares
1 2 3 4 5
th
4 order 0.029 0.443
Routh
4th order 0.028 0.070
Approx.
6th order 0.028 0.115 0.422
Routh
6th order 0.028 0.083 0.107
Approx.
10th order 0.028 0.083 0.131 0.168 0.192
Exact
Table 2 Mode damping ratios for original and approximating transfer functions.
59
Figure 4 Impulse response comparisons of the least-squares approximations.
Example 2
The second example pertains to an engineering system with an infinite number of poles and
zeros. Specifically, a pressure transducer is connected by means of a fluid line to a pressure
source to be measured. A schematic of the line and pressure transducer is shown in figure 7
where Ps denotes the pressure source and Pt denotes the pressure at the pressure transducer. The
motivation for this study is to understand the time domain effects of the fluid line on the
recorded data. The availability of a finite order rational polynomial transfer function will make it
possible to determine the time domain distortion in the recorded pressure due to the line fluid
transients. The transfer function approximation of the infinite order system should be accurate
out through the frequency bandwidth of the pressure changes to be measured. For a step change
in the source pressure, the approximation should be accurate to frequencies greater than the
transducer bandwidth. Unlike Example 1, the end result here is not simply a low order linear
transfer function but, instead, an accurate time response for analyzing the effects of the line and
transducer volume.
Pressure
Transducer
Fluid Line Pt
Ps Qt
Figure 5 Schematic of a pressure transducer connected to the source pressure, Ps, to be measured
by a line with fluid transients; Pt is the pressure actually recorded by the transducer which is
distorted due to the transient effects of the line and the volume of the transducer.
60
The equation for the fluid transients in lines is formulated and discussed in Section 5.2. See
also reference [13]. For this example, it can be shown
1 cosh ( s)
Qt ( s) Ps ( s ) Pt ( s) (2)
Z ( s) sinh ( s) Z ( s) sinh ( s)
where for liquids
L (3)
Dn
cr 2
r2 1
( s ) Dn s (4)
1 B
Zo
Z ( s) (5)
1 B
The Bessel function ratio B is as follows:
2 J 1 ( j sr 2 / )
B( s ) (6)
j sr 2 / J o ( j sr 2 / )
where, J o and J1 are zero and first-order Bessel functions of the first kind. Note that the Bessel
functions are functions of complex variables.
The equation for the pressure transducer is assumed to be a lumped fluid capacitance represented
by a fixed volume of fluid. The Laplace transform of the differential equation for pressure
changes in the volume can be shown to be
V
Qt ( s ) sPt ( s ) (7)
Combining (2) and (7) and eliminating Qt (s ) results in the transfer function between the true
pressure changes at the source () and changes in the recorded pressure Pt (s ) , i.e.
1
Pt ( s ) Ps ( s ) (8)
cosh ( s ) Vs Z ( s ) sinh ( s )
The Bessel and hyperbolic functions can be represented by infinite order product series [15];
thus, the transfer function in (8) has an infinite number of poles and zeros. Regardless, it is
straightforward to generate its frequency response and then perform the least-squares curve fit to
obtain a rational polynomial linear system transfer function approximation. As mentioned
above, obtaining a linear transfer function will enable time domain studies to be conducted. The
m-file, PressureTransducer.m, for generating the frequency response of this transducer and line
61
system is listed in the appendix. A 26th order transfer function is desired for a line of length of 3
m and radius 0.00635 m; the volume of the transducer is 3.2e-6 m3.
Since the purpose of this example is to generate a time response, compared to the previous
example where a lower order approximation was desired, a relatively high order transfer function
is desired in this example in order to obtain an accurate time response. The fluid properties are
specified in the m-file.
Executing the M-file PressureTranducer.m gives the eigenvalues for the transfer function
approximation, frequency domain comparisons and the time response for a step change in the
source pressure. The frequency response comparisons, figures 6 and 7, reveal that the transfer
function is very accurate out through eleven second order resonant modes and four first order
modes. The time response for a unit change in the source pressure is shown in fig. 8; the results
show that the response is lightly damped (100% overshoot) with a time delay at the beginning of
>> PressureTransducer
-3.61e+02 2.77e-03
-2.28e+01 + 7.72e+02i 2.96e-02 7.72e+02 4.38e-02
-2.28e+01 - 7.72e+02i 2.96e-02 7.72e+02 4.38e-02
-3.91e+01 + 2.34e+03i 1.67e-02 2.34e+03 2.56e-02
-3.91e+01 - 2.34e+03i 1.67e-02 2.34e+03 2.56e-02
-5.02e+01 + 3.92e+03i 1.28e-02 3.92e+03 1.99e-02
-5.02e+01 - 3.92e+03i 1.28e-02 3.92e+03 1.99e-02
-5.22e+03 1.92e-04
-5.93e+01 + 5.50e+03i 1.08e-02 5.50e+03 1.69e-02
-5.93e+01 - 5.50e+03i 1.08e-02 5.50e+03 1.69e-02
-6.72e+01 + 7.08e+03i 9.49e-03 7.08e+03 1.49e-02
-6.72e+01 - 7.08e+03i 9.49e-03 7.08e+03 1.49e-02
-7.42e+01 + 8.66e+03i 8.57e-03 8.66e+03 1.35e-02
-7.42e+01 - 8.66e+03i 8.57e-03 8.66e+03 1.35e-02
-8.06e+01 + 1.02e+04i 7.87e-03 1.02e+04 1.24e-02
-8.06e+01 - 1.02e+04i 7.87e-03 1.02e+04 1.24e-02
-8.66e+01 + 1.18e+04i 7.32e-03 1.18e+04 1.16e-02
-8.66e+01 - 1.18e+04i 7.32e-03 1.18e+04 1.16e-02
-9.21e+01 + 1.34e+04i 6.87e-03 1.34e+04 1.09e-02
-9.21e+01 - 1.34e+04i 6.87e-03 1.34e+04 1.09e-02
-9.75e+01 + 1.50e+04i 6.51e-03 1.50e+04 1.03e-02
-9.75e+01 - 1.50e+04i 6.51e-03 1.50e+04 1.03e-02
-1.13e+02 + 1.61e+04i 6.98e-03 1.61e+04 8.88e-03
-1.13e+02 - 1.61e+04i 6.98e-03 1.61e+04 8.88e-03
-3.67e+04 2.72e-05
-2.14e+05 4.68e-06
DCGain = 1.0001
62
Magnitude Comparison Plots
30
20
10
Transfer Function Magnitude, dB
-20
-30
-40
2 3 4 5
10 10 10 10
Frequency, rad/sec
Figure 6 Frequency response comparison of the 26th order transfer function approximation of the
infinite order transfer function.
Phase Angle Comparison Plots
200
150
50
-50
-100
-150
-200
2 3 4 5
10 10 10 10
Frequency, rad/sec
Figure 7 Frequency response comparison of the 26th order transfer function with the infinite
order system frequency response
63
Transducer pressure for a unit step change in source pressure
2.5
2
Change in transducer pressure, N/m
2
1.5
0.5
-0.5
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04
Time (seconds)
Figure 8 Unit step response of the normalized recorded pressure in the pressure transducer. If
there was no distortion, the transducer pressure divided by the source pressure would be unity at
all times.
Two examples were presented. The first example demonstrated how to obtain a lower order
approximation of a linear system transfer function starting with the numerator and denominator
polynomials of the the original transfer function. The second example corresponded to an
infinite order transfer function obtained from the solution to a set of partial differential equations
for a distributed parameter system; the objective was to obtain an accurate finite order rational
polynomial transfer function that can be used for time domain analyses. In both cases, the
frequency response of the approximation matched that of the original transfer function very
accurately over the frequency range of interest.
64
Nomenclature
c Speed of sound in fluid, / m/s
L Length of line, 3 m
r Internal radius of fluid line, 0.00635 m
s Laplace operator
V Volume of pressure transducer cavity, 3.2e-6 m3
Zo Characteristic impedance of line, c/r2
Bulk modulus of fluid, 2e9 N/m2
Density of fluid, 855 Kg/m3
Kinematic viscosity of fluid, 50e-6 m2/s
References
1. Hutton, M.F. and Rabins, M.J., Simplification of High-Order Mechanical Systems Using the Routh
Approximation, J. Dynamic Systems, Measurement and Control, v. 97, pp. 383-392, Dec. 1975
2. Ljung, L. Some Results on Identifying Linear Systems Using Frequency Domain, 32 nd IEEE Conference
on Decision and Control, San Antonio, Texas, pp. 3534-3538, 1993.
3. De Vries, D.K. and Van den Hof, P.M.J. Frequency Domain Identification with Generalized Orthonormal
Basis Functions, Proceedings of the 34th IEEE Conference of Decision and Control, New Orleans,
Louisiana, 1995.
4. Bayard, D.S., High-Order Multivariable Transfer Function Curve Fitting: Algorithms, Sparse Matrix
Methods and Experimental Results, Automatica, v. 30, pp. 1439-1444, 1994.
5. Leblond, J. and Olivi, M., Weighted H2 approximation of transfer functions, Mathematics of Control,
Signals, and Systems, v. 11, n 1, pp. 28-39, 1998.
6. Djaferis, T. and Gong, W., Order reduction of real rational functions with error bounds, Proceedings of
the IEEE Conference on Decision and Control, v. 4, pp. 3189-3194, 1993.
7. Bayard, D.S., High-Order Multivariable Transfer Function Curve Fitting: Algorithms, Sparse Matrix
Methods and Experimental Results, Automatica, Vol. 30 pp. 1439-1444, 1994.
8. Levi, E.C., Complex-Curve Fitting, IRE Transactions on Automatic Control, AC-4, pp.37-44, May 1959.
9. Kim, J.-S.; Song, C.-K.; Jeon, B.-S.; Ryu, J.-W.; Jang, Y.-S.; Kim, S.-S.; Lee, S.-H., A frequency domain
identification method using total least squares, IEEE International Symposium on Industrial Electronics, v
3, 2001, p 1855-1859.
10. Spanos, J.T. and Mingori, D.L., Newton algorithm for fitting transfer functions to frequency response
measurements, Journal of Guidance, Control, and Dynamics, v 16, n 1, Jan-Feb, 1993, p 34-39.
11. Shirvani, Mansour; Inagaki, Makoto; Shimizu, Tadaaki, Simplification study on dynamic models of
distributed parameter systems, AIChE Journal, v 41, n 12, Dec, 1995, p 2658-2660.
12. Sanathanan, C.K. and Koerner, J., Transfer Function Synthesis as a Ratio of Two Complex Polynomials,
IRE Transactions on Automatic Control, Vol. AC-8, pp. 56-58, January 1963.
65
13. Goodson, R.E. and Leonard, R.G., A Survey of Modeling Techniques for Fluid Transmission Line
Transients, Journal of Basic Engineering, ASME Transactions, Series D, Vol. 94, June 1972.
14. Wongputorn, P., Hullender, D., Woods, R., and King, J., Application of MATLAB Functions for
Simulation of Systems with Lines with Fluid Transients, accepted for publication in the ASME Journal of
Fluids Engineering, FE-03-1080, 2004
15. Hullender, D. ; Healey, A. J., 1981, Rational Polynomial Approximation for Fluid Transmission Line
Models, Fluid Transmission Lines Dynamics, ASME Special Publication, I, New York.
66
2.6 Converting Linear Continuous Differential Equations to Discrete Time Equations
Most modern real time monitoring and control systems utilize digital computers for computation
and analysis. In addition, estimation and identification algorithms rely on digital data inputs
compatible with discrete differential equations. Consequently, it is important to be able to
convert continuous differential equation models to discrete format and to understand how to
work with discrete time equations.
Or
+1 = + (1 )
where is the value of the constant input at time = . Note that does not need to be the
same constant for all time but constant over each time interval . Thus, is said to be
piecewise constant over time intervals of . The accuracy of this discrete formulation thus
depends on the magnitude of compared to how rapidly is changing if at all. For = 0.1,
the discrete equation above becomes
+1 = 0.9048 + 0.09516
So, one way to convert a first order linear continuous differential equation to discrete format is to
first obtain the solution to the continuous differential equation for a constant input and then
select a time increment that is small enough to be able to assume that the input is
approximately piecewise constant over that small time interval. Then simply replace in the
solution with ( + 1) which will give the solution one time increment after time
which is noted by +1 . The inverse Laplace approach can be used for higher order differential
equations if the state space solution is used (Chapter 3).
67
2.6.2 Conversion Using the continuous-to-discrete MATLAB command, c2d
A second way of converting a linear continuous differential equation to discrete format is to use
the MATLAB command c2d. If the zero-order-hold option in c2d is used, then the input is
assumed to be piecewise constant for time intervals of . The accuracy of this approach may
1
require 10 where is the largest system eigenvalue magnitude.
This MATLAB approach coverts an nth order continuous transfer function in terms of the
Laplace transform into a discrete transfer function in terms of the Z-transform . The discrete
equation is obtained by finding the inverse of the c2d generated Z-transform. By definition of
the z transform, the inverse of () is () = , the inverse of () is ([ + 1]) = +1 ,
the inverse of 2 () is ([ + 2]) = +2 , the inverse of z-1X(z) is ([ 1]) = 1 , etc.
This is best illustrated by means of an example.
The MATLAB commands for the continuous differential equation above with = 10& =
1are
So
0.09516
() = [ ] ()
0.9048
or
() 0.9048() = 0.09516()
which can be inverted to the time domain giving the same result as above:
+1 0.9048 = 0.09516
The MATLAB approach becomes quite advantageous for higher order differential equations.
For example, consider the following differential equation which can be shown to have
eigenvalues of -2 and -5j4
+ 12 + 61 + 82 = 2 + 18 + 492
68
The largest eigenvalue magnitude is 52 + 42 = 6.403. Since should be smaller than 1/64.03
= 0.0156, is selected to be 0.015.
The MATLAB commands are as follows
>> g=tf([2 18 492],[1 12 61 82])
Transfer function:
2 s^2 + 18 s + 492
------------------------
s^3 + 12 s^2 + 61 s + 82
>> G=c2d(g,0.015)
Transfer function:
Note, this discrete differential equation can be rewritten to give the current solution in terms of
past values of and , i.e.
69
Chapter 3. Expressing Differential Equations in State Variable Format
3.1 Representing an nth Order System by n First Order Differential Equations.
Numerical simulation algorithms generally require that the system of equations be expressed in
the format of simultaneous first order differential equations. In addition, many design algorithms
are based on the use of state variable formats for a systems dynamics.
For cases without input derivatives, conversion to state variable format is very simple since
assigning definitions for the state variables does not include the input.
Example: Express the following 2nd order differential equation in the form of two simultaneous
1st order differential equations.
z 4 z 10 z 5u
where u is the input. Note, there are no input derivatives ( , , . ) in this equation.
We must define two new variables, x1 and x 2 , and then write the equations for their
derivatives.
Define x1 and x 2 so that we can easily get equations for their derivatives in terms of only x1 ,
x 2 , and u. For the equation above, the simplest choice is
x1 z
x2 z
x1 x2
x 2 5u 10 x1 4 x2
These two simultaneous 1st order differential equations are equivalent to the original 2nd order
differential equation for z.
In general, before solving these state variable equations, we must define the output variable of
interest which is denoted by y . The definition for y can be any function of 1 , 2 , .
For example, if our output of interest is z , then y z x1 .
, then y z x 2 .
If our output variable of interest is z
If our output variable of interest is 2z 5z u , then y 2x 2 5x1 u .
70
3.2 Simulation Diagram Approach When There are Input Derivatives
For differential equations with input derivatives, the most versatile approach that allows for
nonzero initial conditions, allows for unusual choices for the output-of-interest, and allows for
equal order numerators and denominators is the simulation diagram approach. One can either
draw the diagram for the specific equation or use the tables for an nth order system in general
found in Appendix G of Modeling and Simulation of Dynamic Systems by Robert Woods and
Kent Lawrence. If the input derivatives are no greater than 1st order, the process is very
simple not requiring a diagram or the use of a general set of equations.
The following example and steps demonstrate the process of drawing a simulation diagram.
Consider the following differential equation.
y 12 y 5 y 24 y 3u 2u 6u
The steps for drawing a simulation diagram are (1) Solve for the highest derivative of y and
move all input derivatives to the left side of the equation, (2) Initiate drawing the diagram by
passing the terms on the left side of this equation through an integrator, (3) Introduce a summer
to cancel any non-derivatives of u terms, (4) Pass the remaining terms through a second
integrator, (5) Repeat step 3, (6) Repeat step 4, (7) Continue repeating this process until only y
remains, (8) Introduce a summer at the very beginning and feedback terms needed to get all the
terms on the right side of the equation; note, boot-strapping may be required if a term is not
available because of the presence of input derivatives. (9) Redraw the diagram leaving only
terms with u and assign outputs of the integrators to be the state variables. By definition, the
inputs to the integrators will be the derivatives of the state variables. (10) Using the diagram,
write the equations for the derivatives of the state variables in terms of the state variables and u.
Step 1: y 3u 2u 12 y 5 y 24 y 6u
Steps 2-7:
2u 3u
y 3u 2u y 3u 2u + y 3u y 3u + y y
+ +
71
Step 8:
2u 36u 34u 3u
(36u ) (36u )
6u y 3u 2u y 3u 2u y 3u
+ y 3u + y y
+
__ _ + +
12( y 3u ) 12 y 36u
12
5
24
Step 9:
34u 3u
6u x3 x3 _ x2 x2 + x1 x1
+
__ _ + +
12
5
24
Step 10:
1 = 2 + 3
2 = 3 34
3 = 241 5(2 + 3) 12(3 34) + 6 = 241 52 123 + 399
The general matrix format used in MATLAB and numerous mathematical algorithms assuming y
is the output of interest is as follows:
AX Bu
X
y CX Du
For the example in section 3.1, if the output of interest is y 2z 5z u , then we have the
following:
72
x 1 0 1 x1 0
x 10 4 x 5 u
2 2
x
y 5 2 1 1u
x 2
Thus,
0 1
A
10 4
0
B
5
C 5 2
D 1
3.4 State Variable Equations in Matrix Format if there are Input Derivatives
z 4z 10 z 5u 7u
Since the input derivative is only first order, the process of drawing the simulation diagram will
lead to a simple result that can be achieved without drawing the diagram. The first step of the
simulation diagram approach is essentially all that is necessary.
Solving for z and moving the u term to the left side of the equation gives
z 7u 5u 10 z 4 z
Since z 7u is the derivative of z 7u , a logical choice for one of the state variables is
z 7u because we know we have an equation for its derivative.
Thus, we can define the state variables as follows
x1 z
x2 z 7u
73
Thus, we have the following derivative equations
x1 x2 7u
x 2 5u 10 x1 4( x2 7u )
x1 0 1 x1 7
x 10 4 x 23u
2 2
, then
If the output of interest is z
x
y 0 1 1 7u
x2
3.4.2 Format Options for Input Derivatives Higher than 1st Order
There are an infinite number of ways of defining the state variables for a particular differential
equation (or transfer function). The choice depends on the restrictions. If there are no nonzero
initial conditions and the output of interest is the variable for which the differential equation has
been writer or for which you have the transfer function, the Phase Variable is very simple and
easily applied. However, if there are nonzero initial conditions or if there is an unusual choice
for the output of interest, then the Simulation Diagram approach will most likely be required.
Recall the example in section 3.2. The following Laplace transform comes from the differential
equation for the case of zero initial conditions and y being the output of interest.
3s 2 2s 6
Y ( s) 3 U ( s)
s 12s 5s 24
2
Using the simulation diagram approach, the following formulations are achieved:
x1 y
x 2 y 3u
x3 y 3u 34u
X AX Bu
y CX Du
A? B? C ? D?
74
0 1 0 3
A 0 0 1 B 34 C 1 0 0 D 0
24 5 12 399
This simple approach to getting the state variables is preferred as long as the initial conditions
are zero and the output of interest is the dependent variable in the differential equation or transfer
function which in this case is y. Note that the matrices are different than those for the Simulation
Diagram approach. This difference is due to different definitions for the state variables. The
actual definitions for the Phase Variable state variables are not known; this is why there can be
no nonzero initial conditions.
0 1 0 0
A 0 0 1 B 0 C 6 2 3 D0
24 5 12 1
The following commands in MATLAB are useful for transitioning between transfer functions
and state variables: "tf2ss" and "ss2tf". This method works even if the transfer function
numerator order is equal to the order of the denominator. Consider the following transfer
function:
3s 2 10s 22
Y ( s) 2 U ( s)
s 4s 2
75
4 2
A
1 0
1
B
0
C 2 16
D 3
These matrices will be totally different from Simulation Diagram or Phase Variable matrices.
To confirm the original transfer function,
>> [num,den]=ss2tf(A,B,C,D)
which gives
num = [ 3 10 22] and den = [1 4 2]
Express the following differential equation in state variable format using the three approaches in
sections 3.4.2.1 - 3.4.2.3; note, z is the desired output in each case. Assume all initial
conditions are zero.
(a) Simulation diagram (Note this method is required in general if there are nonzero initial
conditions or if the output of interest is not z)
x1 0 1 0 x1 2
x 0 0 1 x2 4 u
2
x3 123 65 11 x3 160
x1
y 1 0 0 x2 0u
x3
(b) Phase Variables (note, since the order of the numerator of the transfer function for this
differential equation is less than the order of the denominator, the matrix coefficients come
directly from the transfer function coefficients)
76
x1 0 1 0 x1 0
x 0 0 1 x2 0u
2
x3 123 65 11 x3 1
x1
y 246 18 2 x2 0u
x3
(c) MATLAB
x1 11 65 123 x1 1
x 1 0 0 x2 0u
2
x3 0 1 0 x3 0
x1
y 2 18 246 x2 0u
x3
3.4.2.5 Example of Phase Variable Approach when the Numerator and Denominator
Orders are Equal
Use the phase variable approach to express the following differential equation in state variable
format; z is the output of interest. Note, you will need to first do long division to obtain a lower
order numerator transfer function plus a remainder term.
The process is to apply the phase variable approach to the ratio of polynomials and then add the
4u term to the output of interest equation, i.e.
77
x1 0 1 0 x1 0
x 0 0 1 x2 0u
2
x3 123 65 11 x3 1
x1
y z 246 18 2 x2 4u
x3
Use ss2tf in MATLAB to confirm that you did the conversion to state variable format
correctly.
3.5 Maintaining Access to Natural Variables When Creating State Variable Equations
from Block Diagrams
Consider the block diagram below with input r(t). Each of the blocks represents a particular
component in the system; the outputs of the blocks are called the natural variables since they
represent the output of a component which can potentially be observed, measured and/or
recorded. Design of feedback control systems often requires the measurement of these natural
variables for feedback. The inputs to the blocks are also considered to be natural variables.
r e 10( s 5) u v s2 z
+- +-
( s 10) s 3s 100
2
78
(4) Assume that the variable e is the output of interest. Using the equations for the summing
junctions in the block diagram and the state variable derivative and output equations found
in (2) and (3), eliminate variables u, v, and z and obtain the following matrix state variable
equations remembering that = , the output of interest:
= + = + =? =? =? =?
Solution:
(1) The natural variables are z, v, u, and e; the input to the system is r.
(2) Using the Phase Variable approach to getting the state variable equations:
+2 0 1 1 0
=[ 2 ] [ 1 ] = [ ][ ] + [ ]
+ 3 + 100 2 100 3 2 1
1
= [2 1] [ ] + [0]
2
=
(3)
10 + 50 50
=[ ] = [ + 10]
+ 10 + 10
Thus,
3 = 103 + = 503 + 10
=
Thus, the unknowns are 1 , 2 , 3 , , , , and the equations for this system are
1 = 2
2 = 1001 32 +
3 = 103 +
= 21 + 2
= 503 + 10
Eliminating v, u, z, and e gives
79
= + = +
0 1 0 0
= [122 14 50] = [10] = [2 1 0] = [1]
2 1 10 1
3.6 SIMULINK
Simulink is simulation software that runs as part of MATLAB and is included with the student
version of MATLAB. There are numerous reference books and documents ( type doc
simulink)for learning to perform simulations. To start SIMULINK, click on the home tab and
then the Simulink-library tab in the tool bar on the command window. Then, under the file tab,
click on new then click on model. See Homework 32 and its solution for an example.
80
Chapter 4 Example Problems
4.1
A mass sits at equilibrium on top of a spring and damper as shown below.
Mass x
Spring Damper
It can be shown that the differential equation for the position of the mass is given by
2
10 2 + 60 + 80 = 160
(a) What is the dependent variable in the differential equation?_________
(b) What is the independent variable in the differential equation?__________
(c) What is the order of the differential equation?________
(d) Is the differential equation linear or nonlinear? ________
(e) What is the equilibrium value of x? ______
(f) If the mass is disturbed, it will eventually return to the equilibrium position. Why?
4.2
81
4.3
M z
k b
k b
The input (independent variable) to this system is the displacement u. The equations for this
suspension system are
10 + 1 + 2 = 0
1 = 100( )
2 = 5( )
3 = 100( )
4 = 5( )
1 + 2 3 4 = 0
(a) List the unknowns (dependent variables) and confirm that the number of equations matches
the number of unknowns.
(b) Use the "D" operator to convert the differential equations to algebraic equations.
(c) Eliminate 1 , then eliminate 2 , then eliminate 3 , and then eliminate 4 . How many
equations with which unknowns do you have left?
4.4
Laplace transform the following differential equation and solve for the Laplace transform Z(s).
2 + 12 + 36 = 24(0 ) = 0 (0 ) = 4
Note, the answer should be in the format of a numerator polynomial over a denominator polynomial.
Your answer is not complete until it is in this format.
(a) The final value theorem is () = ()0
Apply the final value theorem to your Z(s) and see if it gives the correct final value.
(b) The initial value theorem is (0+ ) = ()
Apply the initial value theorem and see if it gives (0 ); note, (0+ ) should equal (0 ) if there
is no impulse input to create an instantaneous change in z at t = 0.
82
4.5
(a) Solve the following differential equation x(t) using separation of variables if x(0-) =4.
2 + 6 = 0
(b) Confirm that your solution is correct by substituting the solution into the original differential
equation.
4.6
Show that the inverse Laplace of Z(s) will be of the following format:
() = + + sin( + )
=?
=?
=?
=?
=?
=?
2. The equation for Y(s) is written below in terms of the input U(s).
6 2 + 3 + 84
() = [ ] ()
( + 3)[( + 5)2 + 92 ]
4.7
Laplace transform the differential equation below and then solve for Z(s).
3 + 6 + 12 = 18(0 ) = 2 (0 ) = 4
83
4.8
Consider the following Laplace transform:
15 3 + 2 2 + 640
() =
(5 4 + 162 3 + 1424 2 + 3744 + 1280)
What will be the final value of z(t) found using the final value theorem?
What is the initial value of z(t) as determined from the initial value theorem?
What are the MATLAB commands for generating a plot of z(t) using the impulse command.
4.9
Consider the two simultaneous equations below for a mechanical lift system with step input u(t)
with magnitude of 5.
10 + 6 + 3 = 2(0 ) = 0 (0 ) = 5
2 + +10 4 = 2(0 ) = 4
Convert these equations to the Laplace domain by Laplace transforming the equations.
4.10
For the differential equation below, use Eulers numerical integration to compute the first two solution
values of x(t) using a time step of 0.01.
+ 10 = 20(0 ) = 1
4.11
The differential equations for the suspension shown below with input displacement u(t) are
10 + 100 + 1000 = 100 + 1000
100 + 4000 = 100 + 1000 + 3000
(a) Assume all initial conditions are zero and convert the equations above to Laplace domain.
(b) Demonstrate that if you solve for W(s) in the first equation and then substitute this
expression for W(s) into the 2nd equation, when you solve for Z(s) you get
84
3000 + 300
() = [ ] ()
3 + 40 2 + 300 + 3000
4.12
Express the following differential equation with input u in state variable format. What are the initial
conditions for the state variables?
+ 5 + 10 = 20 + 40(0 ) = 3 (0 ) = 0.5(0 ) = 0
4.13
A dynamic system is represented by the differential equation shown below.
+ 7 + 10 = 14 + 20
(a) What is the transfer function of this system?
(d) Suppose the input u(t) is a unit step. What will be the final value of z(t)?
(e) How long will it take for z(t) to be within 1% of this final value?
4.14
1 2 3
(1) = [4 5 6] =
7 8 9
1 2 3 1
(2) = [4 5 6] = [1] =
7 8 9 1
1
(3) [2 4 1] [2 ] =
3
1 2
1
(4) [3 4] [ ] =
2
5 6
1
(5) [2] [4 5 6] =
3
1 1
(6) [2] . [2]
3 3
(b) Express the differential equation below in matrix state variable format, i.e.
= + = +
85
+ 2 + 3 + 8 = 10 = 0.1
4.15
4.16
+ 0.8 + = 0.8 +
(a) Express this differential equation in state variable format assuming y = u -z is the output of
interest.
(b) Enter your state variable equations in MATLAB using the ss command.
(c) Use the eig command to get the eigenvalues? Are these the correct values?
(d) Use the command step to get a plot of y(t) for u(t) a step with magnitude 0.1. Does the plot
start and end at the correct initial and final values?
4.17
4.18
1 = 2
2 = 1001 22
Using the D operator, eliminate 2 and find a single differential equation for 1 .
86
4.19
(a) Express the differential equation shown below in state variable format using matrices, i.e.
= + = + =? =? =? =?
The output of interest is = .
4 + 24 + 40 = 24 + 40(0 ) = 3 (0 ) = 2() =
(b) What are the initial conditions for the state variables, i.e. 1 (0 ) =?, 2 (0 ) =?, .
(c) For an ode45 numerical simulation, what would you specify for the final time (when to stop
the simulation)?
4.20
1. For each differential equation below, answer the following questions:
(a) + 16 + 12 = 5
Is the equation linear?________ What is the order? _______ What is the dependent
variable?_______
What is the input to the differential equation?_____ What is the final value of the dependent
variable?________
(b) 2 + 0.4 + 0.1( )5 + 10 = 24
Is the equation linear?________ What is the order? _______ What is the dependent
variable?_______
What is the input to the differential equation?_____ What is the final value of the dependent
variable?________
2. Before the valve on the water tank shown below is opened, the height H of the water in the
tank is 10 m. Once the valve is opened, water flows out of the tank. The differential equation
for H with water flowing out is as follows
4 + 0.8 = 0
(a) On the sketch below, draw a reasonable estimate of H as a function of time.
H
valve
0 time
flow
Use separation of variables to solve this differential equation for H(t).
Does your equation for H(t) give the correct initial and final values for H?
Equation for H(t) _______________________________
87
Initial value of H from the equation __________
Final value of H from the equation ___________
88
3. A pendulum is attached to a cart as shown below. The system is shown in equilibrium, that
is, nothing is moving.
spring
cart
pendulum
If the cart is rolled to the right or left and released or if the pendulum is raised to the right or left
and then released, the cart will start rolling back and forth compressing and extending the spring
while the pendulum swings back and forth.
z
It can be shown, for small angles, the following two simultaneous equations with unknowns
accurately model the dynamics of this system
+ 3 + 9 = 0.9 (0 ) = (0 ) = 0
7 + 175 = 2(0 ) = 0 (0 ) = 0
Using the Laplace transform, convert these equations to algebraic equations, eliminate , and
finally end up with an equation for ().
4.21
1. Obtain a linear approximation to the following differential equation using the initial and final
values of z.
+ 3 + 6 = 12(0 ) = 1
2. Consider the following Laplace transform for Z(s):
6 2 + 20 + 80
() =
[ 2 + 12 + 40]
(a) Use the final value theorem (FVT) to compute the final value of z(t).
(b) Use the initial value theorem (IVT) to compute the value of z(t) at t = 0+.
(c) What are the poles of Z(s) which are the roots of the denominator polynomial?
89
3. The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 3
402 = 02 (0 ) = 5
1 2 = 250 (0 ) = 0
H1 H2
Q
(b) Demonstrate that if you solve for W(s) in the first equation and then substitute this
expression for W(s) into the 2nd equation, when you solve for Z(s) you get
3000 + 300
() = [ 3 ] ()
+ 40 2 + 300 + 3000
90
(d) Consider the following MATLAB command and results:
>> roots([1 40 300 3000])
ans =
-33.7442
-3.1279 + 8.8950i
-3.1279 - 8.8950i
What are the eigenvalues of this system?
(f) If the input u(t) is a unit step, the general form of the equation for z(t) can be shown to be
() = + + sin( + )
What are a = ? b = ? c = ? d = ? f = ? g = ? h = ? =?
(g) What is the final value of z(t) and how long will it take to get within 1% of this value?
2. Use the residue theorem to solve the following differential equation for y(t).
22 + 44 = 88(0 ) = 5
4.23
Plug t= into your equation for y(t) and see if it gives the same value as the FVT.
91
4.24
(b) Check your equation for y(t) at t = 0 and at t = . Does your equation give the correct
values at t = 0 and at t = ?
(c) Perform two steps of Euler's integration to get y(T) and y(2T). Use 1/10 of the time
constant for T.
2. Consider the hydraulic lift system shown below. Fluid flows, Q, into the bottom of the
hydraulic cylinder. The pressure, P, increases and pushes the mass upwards with velocity v .
The model for the system is represented by the following equations :
1000v 0.05P 9800
P 100000Q
Q 0.05v
Velocity
v
Pressure
P
Flow Rate
Q
(a) We have three equations. What are the three unknowns?
(b) Assuming the initial velocity is zero, Laplace transform the equations and then find a single
equation for the Laplace transform of the pressure P(s).
(c) What is the final value for P(t) and how long does it take for P(t) to reach this final value
within 1 %?
3. Express the following 3rd order differential equation in a format of three simultaneous 1st
order differential equations; that is, state variable format. All initial conditions are zero.
2z 16z 8z 5z 10
92
4. Consider the Laplace transform W(s) shown below. Pretend that W(s) is a transfer function
with the input being a unit impulse. What are the MATLAB commands for getting a plot of w(t)
using the 'impulse' command in MATLAB?
2s 4
W (s) 2
3s 20s 5
4.25
1. Use Laplace transform to solve the following differential equations for z(t):
(a) + 25 = 2 + 15(0 ) = 4 The input u(t) is a step with magnitude 5.
(c) What are MATLAB commands to get a plot of z(t) in part (a) using the impulse command.
2. A vehicle suspension system is defined by the following differential equations with input u(t):
100 + 600 + 2500 = 600 + 2500
200 + 900 + 5000 = 600 + 2500 + 300 + 2500
(a) Define state variables and then find the equations for the derivatives of the state variables.
(b) Express your state variable derivative equations from (a) in state variable matrix format
assuming the output of interest is y = u - v, i.e.
= + = + =? =? =? =?
(b) Find a straight line approximation for 3 for values of in the neighborhood of the
equilibrium value.
(c) Substitute you straight line equation for 3 in the original differential equation to obtain a
linear differential equation.
(d) The equilibrium value of your linear differential equation should be the same as the
equilibrium value for the original differential equation. Is this the case?
(e) What are the eigenvalues of your linearized differential equation? Time constants?
4.26
1. Use Laplace transform to solve the following differential equations for z(t):
(a) 2 + 10 = 4 + 20(0 ) = 3 The input u(t) is a step with magnitude 2.
2. A vehicle suspension system is defined by the following differential equations with input u(t):
93
100 + 600 + 2500 = 600 + 2500
200 + 900 + 5000 = 600 + 2500 + 300 + 2500
(a) Express this system of equations in state variable format.
(b) Express your state variable equations from (a) in state variable matrix format assuming the
output of interest is y = v - w, i.e. = + = + =? =? =
? =?
3. Consider the following non-linear differential equation for v(t):
+ 2.4 + 3 3 = 3000(0 ) = 10.01 (0 ) = 2
(a) What is the equilibrium (final value) of v(t)?
(b) Find a straight line approximation for 3 for values of in the neighborhood of the
equilibrium value.
(c) Substitute you straight line equation for 3 in the original differential equation to obtain a
linear differential equation.
(d) The equilibrium value of your linear differential equation should be the same as the
equilibrium value for the original differential equation. Is this the case?
(e) What are the eigenvalues of your linearized differential equation? Time constants?
4.27
After Laplace transforming a differential equation for y(t) with input u(t), the following result
was achieved:
s 2 11s 30
Y( s ) 2
U( s )
( s 2 )[(s 3 ) 2
4 ]
(a) What is the transfer function for this system? ____________________________
(c) What are the time constants for this system? _____________________________
(g)Suppose u(t) is a unit step input. It can be shown that y(t) will be of the form
4.28 For the differential equation given below, obtain a straight line approximation for x 3 and
use it to obtain an approximation for the eigenvalues.
2x 8x 20x 3 160 x (0 ) 1 x (0 ) 0
4.29 (a) What are the eigenvalues of the suspension system shown below? What is the damping
ratio? What is the undamped natural frequency?
z
M=10
K=90
10 + 90 = 90
(b) It is desired to add a shock absorber (or viscous damper) as shown below so as to improve
the ride quality of the suspension for bumps in the road. Derive a value for the damping
coefficient b that will give an eigenvalue damping ratio of 0.707.
10 + + 90 = + 90
M=10
b=?
K=90
Bump
95
4.30
A system is expressed in the following transfer function format:
2(s 2)(s 8)
Z(s) [ ]U(s)
(s 10)(s 20)(s 2 10s 925)(s 2 24s 2644)
(a) What are the eigenvalues of this system? Note, check you work since the rest of this
problem depends on you getting this part correct!
(d) What are the damping ratios, damped natural frequencies, and undamped natural
frequencies of this system?
(e) We know that if the input u(t) is a step input at time t=0, then z(t) will be of the following
form:
z(t ) C1e r1t C2e r2 t C3e r3 t C4e r4 t sin(1t 1 ) C5e r5 t sin(2t 2 )
What are each of the following:
Estimate how long it will take for the tank to drain by obtaining a straight line approximation for
H and then getting an estimate for the time constant of the draining tank.
Qi
Qo
96
4.32
Express the following differential equation in state variable matrix form; the output of interest
is y=z-u.
z 8z 16z 25u
32u
4.33
The equations for an inverted pendulum are shown below. The force Fi is used to stabilize the
mass Ms in the vertical position using a feedback controller; the input to the controller is .
Assuming small angles, the differential equations for this system are
0.5z 4.9 0
z 0.18 0.09F 0 i
Fi 8Fi 149.6[ 6 ]
Ms
L
z
Fi
Mc
4.34 The differential equation for the roll angle, , of a ship resulting from wave and wind
disturbances, Td, is shown below
97
+ 1.8 + 9 = 106
Td 5000 sin(1.5t )
The roll angle of the ship will also be a sine wave. What will be the steady state amplitude
and frequency of (t ) ?
4.35
The transfer function relating Z(s ) to the input U(s ) is given below.
s5
Z(s) 2 U(s)
s 30s 200
9
Assume that the input u(t) is a sine wave, that is U(s ) .
s 9
2
It can be shown that the inverse Laplace transform of Z(s) is of the form
C1
r1
C2
r2
r3
98
4.36 The transfer function for the output of a system is shown below; R is the input and N(s) is a
rational polynomial such as as2+bs+c, etc.
N(s)
Y(s) 2
R (s )
( s 2 )[(s 4 ) 2
3 2
][(s 100 ) 2
100 ]
(a) What are the eigenvalues?
(b) What are the time constants?
(c) What are the damping ratios?
(d) What are the damped natural frequencies?
(e) If the input is a step, write the general form of the inverse Laplace of Y(s). Be as
specific as possible.
4.37 After Laplace transforming a differential equation for z(t) with input r(t), the following
result was achieved:
15s 680
Z(s) 2
R (s )
( s 4 )[(s 2 ) 2
8 ]
(a) What is the transfer function for this system? _______________________
(b) What are the eigenvalues of this system?___________________________
(c) What are the time constants for this system? ________________________
(d) What is the damping ratio of this system? _______________________
(e) What is the damped natural frequency of this system? ____________
(f) What is the undamped natural frequency, , of this system? ____________
(g) (Suppose r(t) is a unit step input. It can be shown that z(t) will be of the form
r1 ? _______________
r2 ? _______________
r3 ? _______________
? _______________
(g) What will be the final value of z(t), i.e. z()? _______________________
99
4.38 For the differential equation given below, demonstrate that z is always in the neighborhood
of 2. Obtain a straight line approximation for z 3 and use it to obtain an estimate of the damping
ratio and time constant of the system.
4.39 An analog controller Gc has been converted to z-transform format using the MATLAB
10+1
commands shown below. () = ()() = 100+1 ()
>> Gc=tf([10 1],[100 1]);
>> Gcd=c2d(Gc,0.001)
0.10.0999
=
1
What is the digital code for this controller to be used in a digital computer program?
(c) If the input u is a unit step and all initial conditions are zero,
(c.1) What is Z(s)?
(c.2) What is the general format equation for z(t)? If you dont know what general format
means, find z(t).
(c.3) What is the final value of z(t)?
4.41 (a) Use Laplace transform and the residue theorem to solve the following differential
equation for v(t); the input u is a unit step.
2 + 24 + 40 = 16 + 80(0 ) = 3 (0 ) = 0
(b) What is the final value of v? Check your answer using the final value theorem.
100
(c) What are the MATLAB commands to get a plot of v(t) using the command impulse?
(d) Express this differential equation in state variable format; assume z is the output of
interest denoted by y below. A=? B=? C=? D=?
= + = +
4.42 Express the following system in state variable format assuming E is the output of interest.
Matrix format, i.e.
= + = +
R E u v w
4 s2 1 z
+ +
- s s5 - s
(f) If r is a step input, we know that the general form of y(t) will be
() = + sin( + )
b= _________
d=__________ = __________
4.44 Consider the block diagram shown below.
(a) Express () in state variable format (note, in this case E is the input).
(b) Express G(s) in state variable format (note, in this case U is the input).
(c) Using the results of (a) and (b) above, express the total system in matrix state
variable format; assume u(t) is the output of interest in the equation for y, i.e.
= +
= +
101
A=? B=? C=? D=?
Gc (s ) G (s )
R E 0.2 s 1 U 2s 3 V
+-
0.02 s 1 s 4 s 12
2
102
Chapter 5 Solutions to Example Problems
5.1
A mass sits at equilibrium on top of a spring and damper as shown below.
Mass x
Spring Damper
It can be shown that the differential equation for the position of the mass is given by
2
10 2 + 60 + 80 = 160
(a) What is the dependent variable in the differential equation? x
(b) What is the independent variable in the differential equation? t
(c) What is the order of the differential equation? 2nd
(d) Is the differential equation linear or nonlinear? linear
(e) What is the equilibrium value of x? 160/80=2
(f) If the mass is disturbed, it will eventually return to the equilibrium position. Why? This a
passive system which means that energy is dissipated over time; there is no external energy
source.
5.2
Consider the following differential equation for a suspension system:
3. Assuming that the initial conditions for this differential equation are (0 ) =
0(0 ) = 0, draw a sketch of () starting at = 0.
y(t)
0.1
0 time
103
4. Obtain a linear approximation for this differential equation by obtaining a straight line
approximation for 3 using the two point method. Be sure to start by sketching 3 and
noting the two points for your straight line.
y3
y 3 .01 y 0
0.001
0 0.1 y
5. After substituting your straight line into the original differential equation, check to see if
the new linearized differential equation gives the correct final value.
+ 6.5 + 9,800(0.01) = 9.8() = 0.1
5.3
M z
k b
k b
The input (independent variable) to this system is the displacement u. The equations for this
suspension system are
10 + 1 + 2 = 0
1 = 100( )
2 = 5( )
3 = 100( )
4 = 5( )
1 + 2 3 4 = 0
(a) List the unknowns (dependent variables) and confirm that the number of equations matches
the number of unknowns. 6 equations with unknowns: 1 , 2 , 3 , 4 , ,
104
(b) Use the "D" operator to convert the differential equations to algebraic equations.
102 + 1 + 2 = 0
1 = 100( )
2 = 5( )
3 = 100( )
4 = 5( )
1 + 2 3 4 = 0
(c) Eliminate 1 , then eliminate 2 , then eliminate 3 , and then eliminate 4 . How many
equations with which unknowns do you have left?
102 + 100( ) + 5( ) = 0
100( ) + 5( ) 100( ) 5( ) = 0
Two equations with unknowns z and v.
5.4
(a) Laplace transform the following differential equation and solve for the Laplace transform
Z(s).
2 + 12 + 36 = 24(0 ) = 0 (0 ) = 4
Note, the answer should be in the format of a numerator polynomial over a denominator
polynomial. Your answer is not complete until it is in this format.
2( 2 () 0 4) + 12(() 0)+36Z(s)=24/s
8 + 24
() =
(2 2+ 12 + 36)
0 + 24
()0 = = 0.666
0 + 0 + 36
Setting the derivatives of z in the original differential equation and solving for z gives
0.666 which checks.
(a) Solve the following differential equation x(t) using separation of variables if x(0) =4.
2 + 6 = 0
() = 4 3
(b) Confirm that your solution is correct using the original differential equation.
2(12) 3 + 6(4 3 ) = 0
5.6
We know that the inverse Laplace of Z(s) will be of the following format:
() = + + sin( + )
5
= = 0.184
4 68
=0
6(4)2 + 12(4) + 5
= = 0.07
(4)([(4 + 2)2 + 82 ]
= 4
= 2
=8
2. The equation for Y(s) is written below in terms of the input U(s).
6 2 + 3 + 84
() = [ ] ()
( + 3)[( + 5)2 + 92 ]
62 +3+84
(e) What is the transfer function? [(+3)[(+5)2 +92 ]]
(f) What are the eigenvalues? = 3 5 9
106
1 1
(g) What are the time constants?
3 5
(h) If u(t) is a unit impulse, what is U(s) and what is Y(s)?
() = 1
6 2 + 3 + 84
() = [ ]
( + 3)[( + 5)2 + 92 ]
5.7
Laplace transform the differential equation below and then solve for Z(s).
3 + 6 + 12 = 18(0 ) = 2 (0 ) = 4
+ 2 + 4 = 6
18
2 () 2 4 + 2(() 2) + 4() =
2 2 + 8 + 6
() =
( 2 + 2 + 4)
5.8
Consider the following Laplace transform:
15 3 + 2 2 + 640
() =
(5 4 + 162 3 + 1424 2 + 3744 + 1280)
What will be the final value of z(t) found using the final value theorem?
0 + 0 + 640
() = = 0.5
0 + 0 + 0 + 0 + 1280
What is the initial value of z(t) as determined from the initial value theorem?
(0+ ) = 0
What are the MATLAB commands for generating a plot of z(t) using the impulse command.
>> z=tf(num,den);
>> impulse(z)
107
5.9
Consider the two simultaneous equations below for a mechanical lift system with step input u(t)
with magnitude of 5.
10 + 6 + 3 = 2(0 ) = 0 (0 ) = 5
2 + +10 4 = 2(0 ) = 4
Convert these equations to the Laplace domain by Laplace transforming the equations.
+ 0.6 + 0.3 = 0.2(0 ) = 0 (0 ) = 5
+ 5 2 = (0 ) = 4
Laplace transforming gives
2 () 5 + 0.6() + 0.3() = 0.2()
5
() 4 + 5() 2() =
5.10
For the differential equation below, use Eulers numerical integration to compute the first two
solution values of x(t) using a time step of 0.01.
+ = ( ) =
0 1 20-10*1=10 1+0.01*10=1.1
Use the inverse Laplace transform and solve for the exact solution of x(t) and compare the numerical
solution values with the exact solution values.
() + () =
+
() =
( + )
() =
t Numerical x(t) () =
0 1 1
108
5.11
The differential equations for the suspension shown below with input displacement u(t) are
10 + 100 + 1000 = 100 + 1000
100 + 4000 = 100 + 1000 + 3000
(a) Assume all initial conditions are zero and convert the equations above to Laplace domain.
Z
+ 10 + 100 = 10 + 100
+ 40 = + 10 + 30
Laplace transforming gives
(c) Demonstrate that if you solve for W(s) in the first equation and then substitute this expression
for W(s) into the 2nd equation, when you solve for Z(s) you get
( + 10)() + 30()
() =
( + 40)
( + 10)() + 30()
( 2 + 10 + 100)() = (10 + 100)
( + 40)
3000 + 300
() = [ ] ()
3 + 40 2 + 300 + 3000
5.12
Express the following differential equation with input u in state variable format. What are the initial
conditions for the state variables?
+ + = + ( ) = ( ) = . ( ) =
= = ( ) = ( ) = .
= + =
109
5.13
A dynamic system is represented by the differential equation shown below.
+ 7 + 10 = 14 + 20
(a) What is the transfer function of this system?
14 + 20
2
+ 7 + 10
(b) What are the eigenvalues of this system?
Eigenvalues = -5 and -2
(c) What are the time constants for this system?
Time constants = 1/5 and 1/2
(d) Suppose the input u(t) is a unit step. What will be the final value of z(t)?
0 + 0 + 10() = 0 + 20(1)() = 2
(e) How long will it take for z(t) to be within 1% of this final value?
It takes about five times the largest time constant = 5/2 = 2.5 seconds
5.14
Perform the following matrix operations:
1 2 3 1 4 7
(1) = [4 5 6] = [2 5 8]
7 8 9 3 6 9
1 2 3 1 6
(2) = [4 5 6] = [1] = [15]
7 8 9 1 24
1
(3) [2 4 1] [2 ] = 21 + 42 3
3
1 2 1 + 22
1
(4) [3 4] [ ] = [31 + 42 ]
2
5 6 51 + 62
1 4 5 5
(5) [2] [4 5 6] = [ 8 10 12]
3 12 15 18
1 1 1
(6) [2] . [2] = [4]
3 3 9
Express the differential equation below in matrix state variable format, i.e.
= + = +
+ 2 + 3 + 8 = 10 = 0.1
1 = 2 = 3 =
1 0 1 0 1 0
[ 2 ] = [ 0 0 1 ] [2 ] + [ 0 ]
3 8 3 2 3 10
1
= [0 0
0.1] [ 2 ] + [0]
3
110
5.15
Solve the following differential equation using separation of variables.
20 + 60 = 80(0 ) = 2
() 1
= =
2 3 4 0
Integrating gives
4 2
() = + 3
3 3
5.16
The differential equation for the suspension system shown below is
+ 0.8 + = 0.8 +
(a) Express this differential equation in state variable format assuming y = u -z is the output of
interest.
1 = 2 = 0.8
0 1 0.8
= [ ] + [ ] = [1 0] + [1]
1 0.8 0.36
(b) Enter your state variable equations in MATLAB using the ss command.
>> A=[0 1;-1 -0.8];
>> B=[0.8;0.36];
>> C=[-1 0];
>>D=[1];
>>G=ss(A,B,C,D);
(c) Use the eig command to get the eigenvalues? Are these the correct values?
>> ev=eig(A)
Eigenvalues = -0.4 j0.8
(d) Use the command step to get a plot of y(t) for u(t) a step with magnitude 0.1. Does the plot
start and end at the correct initial and final values?
>> step(G)
The value of y at t = 0+ is 1 and the final value is 0.
111
5.17 Obtain a straight line approximation for x3 in the neighborhood of x=2.
+ () ( ) =
5.18
Two simultaneous differential equations are shown below.
1 = 2
2 = 1001 22
What are the two unknowns?
1 2
5.19
(a) Express the differential equation shown below in state variable format using matrices, i.e.
= + = + =? =? =? =?
The output of interest is = .
4 + 24 + 40 = 24 + 40(0 ) = 3 (0 ) = 2() =
= [01; 10 6]; = [6; 26]; = [10]; = [0]
(b) What are the initial conditions for the state variables, i.e. 1 (0 ) =?, 2 (0 ) =?, .
1 (0 ) = 32 (0 ) = 2
(c) For an ode45 numerical simulation, what would you specify for the final time (when to stop
the simulation)? Final time =5/3 sec.
5.20
1. For each differential equation below, answer the following questions:
(a) + 16 + 12 = 5
Is the equation linear?__yes___ What is the order? ___2nd_ What is the dependent
variable?_v_____
What is the independent variable? time
What is the final value of the dependent variable? 5/12=0.4166
(b) 2 + 0.4 + 0.1( )5 + 10 = 24
Is the equation linear?__no What is the order? ___3rd What is the dependent variable?_y____
What is the independent variable? time What is the final value of the dependent variable? 2.4
2. Before the valve on the water tank is opened, the height H of the water in the tank is 10 m.
Once the valve is opened, water flows out of the tank. The differential equation for H with water
flowing out is as follows
4 + 0.8 = 0
(a) On the sketch below, draw a reasonable estimate of H as a function of time.
112
H
10
valve
0 time
flow
Use separation of variables to solve this differential equation for H(t).
()
4 = 0.8 () (0) = 0.1() = ((0) 0.1)2
(0) 0
Does your equation for H(t) give the correct initial and final values for H?
Equation for H(t) () = (10 0.1)2
Initial value of H from the equation (0) = (10 0.1 (0))2 = 10
Final value of H from the equation () = (10 0.1)2 = 0 cannot go negative
3. A pendulum is attached to a cart as shown below. The system is shown in equilibrium, that
is, nothing is moving.
spring
cart
pendulum
If the cart is rolled to the right or left and released or if the pendulum is raised to the right or left
and then released, the cart will start rolling back and forth compressing and extending the spring
while the pendulum swings back and forth.
113
z
It can be shown, for small angles, the following two simultaneous equations with unknowns
accurately model the dynamics of this system
+ 3 + 9 = 0.9 (0 ) = 0 (0 ) = 0
7 + 175 = 2(0 ) = 0 (0 ) = 0
Using the Laplace transform, convert these equations to algebraic equations, eliminate , and
finally end up with an equation for ().
( 2 + 3 + 9)() 0 30 = 0.9 2 ()
(7 2 + 175)() = 2 2 () + 20
Which simplifies to
900
() = [ ]
26 4 + 105 3 + 1190 2 + 2625 + 7875
5.21
1. Obtain a linear approximation to the following differential equation using the initial and final
values of z.
+ 3 + 6 = 12(0 ) = 1
0 + 0 + 6 = 12, () = 4
1 2
+
3 3
2
+ 3 + 6[ + ] = 12
3 3
+ 3 + 2 = 8
114
2. Consider the following Laplace transform for Z(s):
6 2 + 20 + 80
() =
[ 2 + 12 + 40]
(a) Use the final value theorem (FVT) to compute the final value of z(t).
80
()=0 = =2
40
(b) Use the initial value theorem (IVT) to compute the value of z(t) at t = 0+.
()= = 6
(c) What are the poles of Z(s) which are the roots of the denominator polynomial?
= 0, 6 + 2, 6 2
3. The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 3
402 = 02 (0 ) = 5
1 2 = 250 (0 ) = 0
H1 H2
Q
40[2 5] = 0
1 2 = 250[() 0]
(b) Reduce the equations down to two equations with unknowns H1(s) and H2(s) .
1 2
=
250
Thus,
1 2
20[1 () 3] = 0
250
1 2
40[2 5] = 0
250
115
(d) Reduce the equations down to one equation for the unknown H1(s).
Thus,
1.5108 2 + 65,000
1 =
(5107 2 + 15,000)
(e) Use the final value theorem to determine the final value of H1. Does this value make sense?
65,000
1 ()=0 = = 4.333
15,000
Since the initial water height in this tank was 3 and the other 5, a final value between 3 and 5 makes
sense.
(f) Use the initial value theorem to check the initial value. Is it correct?
1.5108
1 ()= = 5107
= 3 which is the correct value.
5.22
1. The differential equations for the suspension shown below with input displacement u(t) are
+ 10 + 100 = 10 + 100
+ 40 = + 10 + 30
(a) Assume all initial conditions are zero and convert the equations above to Laplace domain.
Z
(b) Demonstrate that if you solve for W(s) in the first equation and then substitute this expression
for W(s) into the 2nd equation, when you solve for Z(s) you get
3000 + 300
() = [ ] ()
3 + 40 2 + 300 + 3000
2 + 10 + 100
( + 40) ( ) = ( + 10) + 30
10 + 100
3000 + 300
[ ]
3 + 40 2 + 300 + 3000
(f) If the input u(t) is a unit step, the general form of the equation for z(t) can be shown to be
() = + + sin( + )
3000 + 300 1
() = [ ]
3 2
+ 40 + 300 + 3000
(g) What is the final value of z(t) and how long will it take to get within 1% of this value?
2. Use the residue theorem to solve the following differential equation for y(t).
22 + 44 = 88(0 ) = 5
5 + 4
() =
( + 2)
() = 2 + 3 2
3. Use separation of variables to solve the differential equation in problem 2.
117
()
=
(0) 2 4 0
2() 4
[ ] = 2
2(0) 4
2() 4
= 2
2(0) 4
() = 2 + 3 2
5.23
1. Find the magnitude and angle of the following complex numbers:
+4
(a) 4 + j4 Magnitue= 42 + 42 = 32 = 5.66 = 1 (+4) = 4
+4 3
(b) -4 + j4 Magnitude= 42 + 42 = 32 = 5.66 = 1 (4) = 4
4 5
(c)-4 j4 Magnitude= 42 + 42 = 32 = 5.66 = 1 ( ) =
4 4
4 7
(d)4 - j4 Magnitude=42 + 42 = 32 = 5.66 = 1 (+4) = 4
(4+4)(4+4) 3 7 3
() 44
Magnitude= 5.66*5.66/5.66 = 5.66 = 4
+ 4 4
= 4
2. For the differential equation below,
2 + 24 + 40 = 20(0 ) = 0.5 (0 ) = 3() = 5
(a) Solve for the Laplace transform of z(t), Z(s).
5
2[ 2 () 0.5 3] + 24[() 0.5] + 40() = 20
0.5 2 + 9 + 50
() =
( 2 + 12 + 20)
(b)Check your Z(s) to see if it gives the correct initial value using the initial value theorem.
()= = 0.5
(c)Check your Z(s) to see if it gives the correct final value using the final value theorem.
50
()=0 = = 2.5. = 0
20
IVT: limit sF(s)s= FVT: limit sF(s)s=0
{} = (){} = () (0 ){} = 2 () (0 ) (0 )
118
32 1 32 32
() = { 2 2 } + | | 4 sin[4 + ( )=4+4 ]
[( + 4) + 4 ] =0 4 =4+4
1 32 4 3 3
=1+ sin (4 ) = 1 + 2 4 sin(4 )
4 32 4 4
(b) Plug t = 0 into your equation for y(t) and see if it gives the same value as the IVT.
(0) = 1 1 = 0
Plug t= into your equation for y(t) and see if it gives the same value as the FVT.
() = 1 0 = 1
5.24
1. Parts (a) and (b) of this problem are the Key Assignment. Consider the following differential
equation for y(t).
2 y 5 y 25 y(0 ) 6
(a) Use the Laplace transform and the residue theorem to solve this differential equation for y(t).
(b)
2( sY 6) 5Y 25 / s
6s 12.5
Y ( s)
s( s 2.5)
y (t ) 5 e 2.5t
(c) Check your equation for y(t) at t = 0 and at t = . Does your equation give the correct values
at t = 0 and at t = ?
y (t )t 0 6
y (t )t 5
Thus, the equation for y(t) gives the correct initial and final values.
(d) Perform two steps of Euler's integration to get y(T) and y(2T). Use 1/10 of the time constant
for T.
119
2. Consider the hydraulic lift system shown below. Fluid flows, Q, into the bottom of the
hydraulic cylinder. The pressure, P, increases and pushes the mass upwards with velocity v .
The model for the system is represented by the following equations :
1000v 0.05P 9800
P 100000Q
Q 0.05v
Velocity
v
Pressure
P
Flow Rate
Q
(a) We have three equations. What are the three unknowns? v, P, and Q
(b) Assuming the initial velocity is zero, Laplace transform the equations and then find a single
equation for the Laplace transform of the pressure P(s).
9800
1000sV 0.05P
s
P 100000Q
Q 0.05V
Solving for P gives
49000
P( s )
s( s 0.25)
(c) What is the final value for P(t) and how long does it take for P(t) to reach this final value
within 1 %?
49000
sP( s) s 0 196000 It takes about 5 time constants which is 20 seconds.
( s 0.25) s 0
3. Express the following 3rd order differential equation in a format of three simultaneous 1st
order differential equations. All initial conditions are zero.
2z 16z 8z 5z 10
120
x1 z
x2 z
x3 z
x1 x2
x2 x3
x3 5 2.5 x1 4 x2 8 x3
4. Consider the Laplace transform W(s) shown below. Pretend that W(s) is a transfer function
with the input being a unit impulse. What are the MATLAB commands for getting a plot of
w(t) using the 'impulse' command in MATLAB?
2s 4
W (s) 2
3s 20s 5
5.25
1. Use Laplace transform to solve the following differential equations for z(t):
(a) + 25 = 2 + 15(0 ) = 4 The input u(t) is a step with magnitude 5.
() 4 + 25() = (2 + 15)
14 + 75
() =
( + 25)
() = 3 + 11 25
(b) What are MATLAB commands to get a plot of z(t) in part (a) using the impulse command.
>> z=tf([14 75],[1 25 0]);
>> impulse(z)
(c) + 6 + 25 = 50()(0 ) = 1 (0 ) = 0 The input u(t) is a unit impulse.
( 2 () 1) + 6(() 1) + 25() = 50()
+ 56
() =
( + 3)2 + 42
1
() = | + 56|=3+4 3 sin(4 + ( + 56)=3+4 )
4
() = 13.29 3 sin(4 + 0.0753)
. [()] = (). [ ()] = () (0 ). [ ()] = 2 () (0 ) (0 )
1 () ()
| | sin( + ) = ( )
() =+ () =+
121
2. A vehicle suspension system is defined by the following differential equations with input u(t):
100 + 600 + 2500 = 600 + 2500
200 + 900 + 5000 = 600 + 2500 + 300 + 2500
+ 6 + 25 = 6 + 25
+ 4.5 + 25 = 3 + 12.5 + 1.5 + 12.5
(a) Define state variables and then find the equations for the derivatives of the state variables.
1 = 2 = 3 = 4 = 1.5
1 = 2
2 = 251 62 + 253 + 64 + 9
3 = 4 + 1.5
4 = 12.51 + 32 253 4.54 + 5.75
(b) Express your state variable derivative equations from (a) in state variable matrix format
assuming the output of interest is y = u - v, i.e.
= + = + =? =? =? =?
0 1 0 0 0
=[ 25 6 25 6 ] = [ 9 ] = [0 0 1 0] = [1]
0 0 0 1 1.5
12.5 3 25 4.5 5.75
3. Consider the following non-linear differential equation for v(t):
+ 84 + 300 3 = 2400(0 ) = 1.9 (0 ) = 2
(a) What is the equilibrium (final value) of v(t)?
0 + 0 + 300 3 = 2400() = 2
(b) Find a straight line approximation for 3 for values of in the neighborhood of the
equilibrium value.
3 23 + 3(2)2 ( 2) = 12 16
(c) Substitute you straight line equation for 3 in the original differential equation to obtain a
linear differential equation.
+ 84 + 300(12 16) = 2400
+ 84 + 3600 = 7200
(d) The equilibrium value of your linear differential equation should be the same as the
equilibrium value for the original differential equation. Is this the case?
7200
= = 2
3600
(e) What are the eigenvalues of your linearized differential equation? Time constants?
2 + 84 + 3600 = ( + 42 + 42.85)( + 42 42.85)
122
= 42 42.85
1
= = 0.0238
42
5.26
1. Use Laplace transform to solve the following differential equations for z(t):
(a) 2 + 10 = 4 + 20(0 ) = 3 The input u(t) is a step with magnitude 2.
2[ 3] + 10 = [4 + 20]
2 14 + 40
(2 + 10) = (4 + 20) + 6 =
7 + 20
() =
( + 5)
() = = 0 + = 5
() = 4 + 3 5
Checking z(t) at t = gives the correct value of 4. However, the t = 0+ value of z is different
from the t = 0 value due to the impulse created by .
-
2. A vehicle suspension system is defined by the following differential equations with input u(t):
100 + 600 + 2500 = 600 + 2500
200 + 900 + 5000 = 600 + 2500 + 300 + 2500
(a) Express this system of equations in state variable format.
+ 6 + 25 = 6 + 25
+ 4.5 + 25 = 3 + 12.5 + 1.5 + 12.5
1 = 2 = 3 = 4 = 1.5
1 = 2
2 = 251 62 + 253 + 64 + 9
3 = 4 + 1.5
4 = 12.51 + 32 253 4.54 + 5.75
(b) Express your state variable equations from (a) in state variable matrix format assuming the
output of interest is y = v - w, i.e. = + = + =? =? =? =?
123
0 1 0 0 0
25 6 25 6 ] = [ 9 ] = [1 0 1
=[ 0] = [0]
0 0 0 1 1.5
12.5 3 25 4.5 5.75
(c) Substitute you straight line equation for 3 in the original differential equation to obtain a
linear differential equation.
+ 2.4 + 3(300 2000) = 3000
+ 2.4 + 900 = 9000
(d) The equilibrium value of your linear differential equation should be the same as the
equilibrium value for the original differential equation. Is this the case?
0 + 0 + 900 = 9000
() = 10
(e) What are the eigenvalues of your linearized differential equation? Time constants?
= 1.2 29.98
1
= = 0.833
1.2
5.27 After Laplace transforming a differential equation for y(t) with input u(t), the following
result was achieved:
s 2 11s 30
Y( s ) 2
U( s )
(s 2)[(s 3) 4 ]
2
s 2 11s 30
(a) What is the transfer function for this system? 2
( s 2)[(s 3) 4 ]
2
(b) What are the eigenvalues of this system? -2, -3-j4, -3+j4
(c) What are the time constants for this system? and 1/3
(d) What is the damping ratio of this system? 0.6
(e) What is the damped natural frequency of this system? 4
(f) What is the undamped natural frequency of this system? 5
(g) Suppose u(t) is a unit step input. It can be shown that y(t) will be of the form
124
y(t ) C1e r1t C2e r2 t C3e r3 t sin(t )
r1 ? 0 r2 ? -2 r3 ? -3 ? 4
(h) What will be the final value of y(t), i.e. y()? 0.6
5.28 For the differential equation given below, obtain a straight line approximation for x 3 and
use it to obtain an approximation for the eigenvalues.
5.29 (a) What are the eigenvalues of the suspension system shown below? What is the damping
ratio? What is the undamped natural frequency?
z
M=10
K=90
10 + 90 = 90
Eigenvalues = 0 3, damping ratio = 0, undamped natural frequency = 3
(b) It is desired to add a shock absorber (or viscous damper) as shown below so as to improve
the ride quality of the suspension for bumps in the road. Derive a value for the damping
coefficient b that will give an eigenvalue damping ratio of 0.707.
10 + + 90 = + 90
125
M=10
b=?
K=90
Bump
2(s 2)(s 8)
Z(s) [ ]U(s)
(s 10)(s 20)(s 2 10s 925)(s 2 24s 2644)
(a) What are the eigenvalues of this system? Note, check you work since the rest of this
problem depends on you getting this part correct! -10, -20, -5-j30, -5+j30, -12+j50,-12-j50
(b) Is this system stable? Explain how you know? Yes, all eigenvalues have negative real
parts.
(c)What are the time constants of this system? 1/10, 1/20, 1/5, and 1/12
(d)What are the damping ratios, damped natural frequencies, and undamped natural frequencies
of this system? Damping ratios 0.164 and 0.233
Damped natural frequencies = 30 and 50. Undamped natural frequencies = 30.41 and 51.42.
(e) We know that if the input u(t) is a step input at time t=0, then z(t) will be of the following
form:
z(t ) C1e r1t C2e r2 t C3e r3 t C4e r4 t sin(1t 1 ) C5e r5 t sin(2t 2 )
What are each of the following:
r1 0
r2 10
r3 20
r4 5
r5 12
1 30
2 50
5.31 The equations for a water tank are as follows:
0
Q i Q o 5H
Q o 10 H
Assume Q i 0 and H(0 ) 4 .
126
Estimate how long it will take for the tank to drain by obtaining a straight line approximation for
H and then getting an estimate for the time constant of the draining tank.
Qi
Qo
The water height goes from 4 to 0; so, we need a straight line approximation based on two
points. 0.5 + 0. Using this approximation and combining the equations gives
+ = 0 Thus, the time constant is 1 sec. So, it will take approximately 5 seconds to drain
the tank.
5.32 Express the following differential equation in state variable matrix form; the output of
interest is y=z-u.
z 8z 16z 25u
32u
5.33 The equations for an inverted pendulum are shown below. The force Fi is used to stabilize
the mass Ms in the vertical position. Assuming small angles, the differential equations for this
system are
0.5z 4.9 0
z 0.18 0.09F 0
i
And the differential equation for the feedback controller is
F i 8Fi 149.6[ 6]
127
Ms
L
z
Fi
Mc
5.34 The differential equation for the roll angle, , of a ship resulting from wave and wind
disturbances, Td, is shown below
+ 1.8 + 9 = 106
Td 5000 sin(1.5t )
128
The roll angle of the ship will also be a sine wave. What will be the steady state amplitude
and frequency of (t ) ? Amplitude = 0.0006877 and frequency = 1.5 rad/sec
106
The transfer function for is defined by () = [2 +1.8+9] (s). At steady state
106
() = 5000 |2 +1.8+9| sin(1.5 + ) = 0.00068776sin(1.5 0.38051)
=1.5
5.35 The transfer function relating Z(s) to the input U(s) is given below.
s5 s5 9
Z ( s) 2 U ( s)
s 30s 200 ( s 10)(s 20) s 0s 9
2
9
Assume that the input u(t) is a sine wave, that is U(s ) .
2
s 9
It can be shown that the inverse Laplace transform of Z(s) is of the form
C1 (10 + 5)9
(10 + 20)(100 + 9)
= 0.04128
r1 10
C2 (20 + 5)9
(20 + 10)(400 + 9)
= 0.033
r2 20
r3 0
5.36 The transfer function for the output of a system is shown below; R is the input and N(s) is a
rational polynomial such as as2+bs+c, etc.
N ( s)
Y ( s) 2
R( s )
( s 2)[(s 4) 3 ][(s 100) 100 ]
2 2 2
129
(a)What are the eigenvalues? -2, -4+j3, -4-j3, -100+j100, -100-j100
(e) If the input is a step, write the general form of the inverse Laplace of Y(s). Be as specific as
possible.
N ( s)e st
() = [ ]
( s 2)[(s 4) 2 32 ][(s 100) 2 100 2 ]
=0
st
N ( s )e
+[ ]=2
s[( s 4) 32 ][(s 100) 2 100 2 ]
2
1 N ( s)
+ | | 3 sin(3 + )
4 s( s 2)[(s 100) 2 100 2 ]
=4+3
1 N ( s)
+ | | 100 sin(100 + )
100 s( s 2)[(s 4) 2 32 ]
=100+100
5.37 After Laplace transforming a differential equation for z(t) with input r(t), the following
result was achieved:
15s 680
Z ( s) 2
R( s )
( s 4)[(s 2) 8 ]
2
15s 680
(a) What is the transfer function for this system? 2
( s 4)[(s 2) 8 ]
2
(b) What are the eigenvalues of this system? -4, -2-j8, -2+j8
(c) What are the time constants for this system? and
(d) What is the damping ratio of this system? 0.2425
(e) What is the damped natural frequency of this system? 8
(f) What is the undamped natural frequency, , of this system? 68 = 8.2462
(g) (Suppose r(t) is a unit step input. It can be shown that z(t) will be of the form
130
5.38 For the differential equation given below, obtain a straight line approximation for z 3 and
use it to obtain an estimate of the damping ratio and time constant of the system.
5.39
An analog controller Gc has been converted to z-transform format using the MATLAB
10+1
commands shown below. () = ()() = 100+1 ()
>> Gc=tf([10 1],[100 1]);
>> Gcd=c2d(Gc,0.001)
0.10.0999
= 1
0.10.0999
Thus, () = [ ] ()
1
What is the digital code for this controller to be used in a digital computer program?
() = 1 () + 0.1() 0.0999 1 ()
Or,
= 1 + 0.1 0.09991
(b.1) What are the eigenvalues of this system? -2, -5+j12, -5-j12
(b.2) What are the time constants of this system? 1/2 and 1/5
(b.3) What is the damping ratio? 0.3846
(b.4) How long will it take for z(t) to reach its final value within 1%? 2.5 sec
(b.5) What are MATLAB commands for entering this transfer function into MATLAB?
>> G=tf([16 32 169],[1 12 189 338])
(b.6) If the input u is a unit step and all initial conditions are zero,
(b.6.1) What is Z(s)?
131
16 2 + 32 + 169
( 3 + 12 2 + 189 + 338)
(c.2) What is the general format equation for z(t)? If you dont know what general format
means, find z(t).
() = 0.5 + 2 + 5 sin(12 + )
(c.3) What is the final value of z(t)? 0.5
5.41
(a) Use Laplace transform and the residue theorem to solve the following differential equation
for v(t); the input u is a unit step.
2 + 24 + 40 = 16 + 80(0 ) = 3 (0 ) = 0
(b) What is the final value of v? Check your answer using the final value theorem.
(c) What are the MATLAB commands to get a plot of v(t) using the command impulse?
(d) Express this differential equation in state variable format; assume z is the output of
interest denoted by y below. A=? B=? C=? D=?
= + = +
5.42
Express the following system in state variable format assuming E is the output of interest, i.e.
= + = +
R E u w v
4 s2 1 z
+ +
- s s5 - s
6 1 1 0
= [ 0 5 3] = [0] = [1 0 0] = [1]
4 0 0 4
132
5.43 Consider the differential equation below.
2 + 48 + 800 = 60 + 1600
(g) If r(t) is the input, what is the transfer function for y?
(h) What is the d.c. gain of this system? ____________________
(i) What is the characteristic equation? ______________________
(j) What are the eigenvalues? ___________________________________
(k) What is the time constant? __________
What is the damping ratio? _____________
What is the undamped natural frequency?______________
What is the damped natural frequency? _____________
(l) If r is a step input, we know that the general form of y(t) will be
() = + sin( + )
b= _________
d=__________ = __________
Gc (s ) G (s )
R E 0.2 s 1 U 2s 3 V
+-
0.02 s 1 s 4 s 12
2
133
Chapter 6 Previous Quiz Problems and Solutions
Quiz 1
A mass sits on top of a spring and damper as shown below.
Mass x
Spring Damper
It can be shown that the differential equation for the position of the mass is given by
2
10 2 + 60 + 80 = 160
(a) What is the dependent variable in the differential equation?_________
(b) What is the independent variable in the differential equation?__________
(c) What is the order of the differential equation?________
(d) Is the differential equation linear or nonlinear? ________
(e) If the mass is disturbed, it will bounce up and down for a while. Eventually, it will return to
an equilibrium position which means will become a constant. What will be this final value of
?_______
Quiz 1 Solution:
A mass sits on top of a spring and damper as shown below.
Mass x
Spring Damper
It can be shown that the differential equation for the position of the mass is given by
2
10 2 + 60 + 80 = 160
(a) What is the dependent variable in the differential equation? x
(b) What is the independent variable in the differential equation? t
(c) What is the order of the differential equation? 2nd
134
(d) Is the differential equation linear or nonlinear? linear
(e) If the mass is disturbed, it will bounce up and down for a while. Eventually, it will return to
an equilibrium position which means will become a constant. What will be this final value? 2
Quiz 2
Quiz 2 Solution:
3. Assuming that the initial conditions for this differential equation are (0 ) = 0(0 ) = 0,
draw a sketch of () starting at = 0.
y(t)
0.1
0 time
135
4. Obtain a linear approximation for this differential equation by obtaining a straight line
approximation for 3 using the two point method. Be sure to start by sketching 3 and noting
the two points for your straight line.
y3
y 3 .01 y 0
0.001
0 0.1 y
5. After substituting your straight line into the original differential equation, check to see if the
new linearized differential equation gives the correct final value.
+ 6.5 + 9,800(0.01) = 9.8() = 0.1
Quiz 3
Consider the following spring-mass-damper system with input u(t).
M z
k b
k b
The input (independent variable) to this system is the displacement u. The equations for this
suspension system are
10 + 1 + 2 = 0
1 = 100( )
2 = 5( )
3 = 100( )
4 = 5( )
1 + 2 3 4 = 0
(a) List the unknowns (dependent variables) and confirm that the number of equations matches
the number of unknowns.
136
(b) Use the "D" operator to convert the differential equations to algebraic equations.
(c) Eliminate 1 , then eliminate 2 , then eliminate 3 , and then eliminate 4 . How many
equations with which unknowns do you have left?
Quiz 3 Solution:
Consider the following spring-mass-damper system with input u(t).
M z
k b
k b
The input (independent variable) to this system is the displacement u. The equations for this
suspension system are
10 + 1 + 2 = 0
1 = 100( )
2 = 5( )
3 = 100( )
4 = 5( )
1 + 2 3 4 = 0
(a) List the unknowns (dependent variables) and confirm that the number of equations matches
the number of unknowns. 6 equations with unknowns: 1 , 2 , 3 , 4 , ,
(b) Use the "D" operator to convert the differential equations to algebraic equations.
102 + 1 + 2 = 0
1 = 100( )
2 = 5( )
3 = 100( )
4 = 5( )
1 + 2 3 4 = 0
(c) Eliminate 1 , then eliminate 2 , then eliminate 3 , and then eliminate 4 . How many
equations with which unknowns do you have left?
102 + 100( ) + 5( ) = 0
100( )5( ) 100( ) 5( ) = 0
Two equations with unknowns z and v.
137
Quiz 4
(a) Laplace transform the following differential equation and solve for the Laplace transform
Z(s).
2 + 12 + 36 = 24(0 ) = 0 (0 ) = 4
Note, the answer should be in the format of a numerator polynomial over a denominator
polynomial. Your answer is not complete until it is in this format.
Quiz 4 Solution
Laplace transform the following differential equation and solve for the Laplace transform Z(s).
2 + 12 + 36 = 24(0 ) = 0 (0 ) = 4
Note, the answer should be in the format of a numerator polynomial over a denominator
polynomial. Your answer is not complete until it is in this format.
2( 2 () 0 4) + 12(() 0)+36Z(s)=24/s
8 + 24
() =
(2 2 + 12 + 36)
0 + 24
()0 = = 0.666
0 + 0 + 36
Setting the derivatives of z in the original differential equation and solving for z gives
0.666 which checks.
138
Quiz 5
(a) Solve the following differential equation x(t) using separation of variables if x(0) =4.
2 + 6 = 0
(b) Confirm that your solution is correct using the original differential equation.
Quiz 5 Solution
(h) Solve the following differential equation x(t) using separation of variables if x(0) =4.
2 + 6 = 0
() = 4 3
(b)Confirm that your solution is correct using the original differential equation.
2(12) 3 + 6(4 3 ) = 0
Quiz 6
We know that the inverse Laplace of Z(s) will be of the following format:
() = + + sin( + )
=?
=?
=?
=?
=?
=?
Quiz 6 Solution
5
= 4(4+64) = 0.01838 = 0
6(4)2 + 12(4) + 5 69 48
= = = 0.0772 = 4
(4)[(4 + 2) + 64]
2 4(68)
= 2 = 8
Quiz 7
The equation for Y(s) is written below in terms of the input U(s).
6 2 + 3 + 84
() = [ ] ()
( + 3)[( + 5)2 + 92 ]
139
(a)What is the transfer function?
(b)What are the eigenvalues?
(c)What are the time constants?
Quiz 7 Solution
The equation for Y(s) is written below in terms of the input U(s).
6 2 + 3 + 84
() = [ ] ()
( + 3)[( + 5)2 + 92 ]
62 +3+84
(a)What is the transfer function? [(+3)[(+5)2 +92 ]]
(b)What are the eigenvalues? 3, 5 9
(c)What are the time constants? 1/3 and 1/5
(d)If u(t) is a unit impulse, what is U(s) and what is Y(s)? Since U(s)=1
62 +3+84
() = [(+3)[(+5)2 +92]]
Quiz 8
We know that the inverse Laplace of Z(s) will be of the following format:
() = + + sin( + )
=?
=?
=?
=?
=?
=?
Quiz 8 Solution
140
We know that the inverse Laplace of Z(s) will be of the following format:
() = + + sin( + )
5
=
4 68
=0
6(4)2 + 12(4) + 5
= = 0.07
(4)([(4 + 2)2 + 82 ]
= 4
= 2
=8
Quiz 9
Laplace transform the differential equation below and then solve for Z(s).
3 + 6 + 12 = 18(0 ) = 2 (0 ) = 4
Quiz 9 Solution
Laplace transform the differential equation below and then solve for Z(s).
3 + 6 + 12 = 18(0 ) = 2 (0 ) = 4
+ 2 + 4 = 6
18
2 () 2 4 + 2(() 2) + 4() =
2 2 + 8 + 6
() =
( 2 + 2 + 4)
Quiz 10
15 3 + 2 2 + 640
() =
(5 4 + 162 3 + 1424 2 + 3744 + 1280)
What will be the final value of z(t) found using the final value theorem?
What is the initial value of z(t) as determined from the initial value theorem?
What are the MATLAB commands for generating a plot of z(t) using the impulse command.
141
Quiz 10 Solution
15 3 + 2 2 + 640
() =
(5 4 + 162 3 + 1424 2 + 3744 + 1280)
What will be the final value of z(t) found using the final value theorem?
0 + 0 + 640
() = = 0.5
0 + 0 + 0 + 0 + 1280
What is the initial value of z(t) as determined from the initial value theorem?
(0+ ) = 0
What are the MATLAB commands for generating a plot of z(t) using the impulse command.
Quiz 11
Consider the two simultaneous equations below for a mechanical lift system with step input u(t)
with magnitude of 5.
10 + 6 + 3 = 2(0 ) = 0 (0 ) = 5
2 + +10 4 = 2(0 ) = 4
Quiz 11 Solution
Consider the two simultaneous equations below for a mechanical lift system with step input u(t)
with magnitude of 5.
10 + 6 + 3 = 2(0 ) = 0 (0 ) = 5
2 + +10 4 = 2(0 ) = 4
142
Quiz 12
For the differential equation below, use Eulers numerical integration to compute the first two solution
values of x(t) using a time step of 0.01.
+ 10 = 20(0 ) = 1
Use the inverse Laplace transform and solve for the exact solution of x(t) and compare the numerical
solution values with the exact solution values.
Quiz 12 Solution
For the differential equation below, use Eulers numerical integration to compute the first two solution
values of x(t) using a time step of 0.01.
+ 10 = 20(0 ) = 1
20
() 1 + 10() =
20 +
() =
( + 10)
() = 2 10
t Numerical x(t) () = 2 10
0 1 1
0.01 1.1 1.09516
0.02 1.19 1.18127
Quiz 13
The differential equations for the suspension shown below with input displacement u(t) are
10 + 100 + 1000 = 100 + 1000
100 + 4000 = 100 + 1000 + 3000
(a) Assume all initial conditions are zero and convert the equations above to Laplace domain.
143
Z
(b) Demonstrate that if you solve for W(s) in the first equation and then substitute this
expression for W(s) into the 2nd equation, when you solve for Z(s) you get
3000 + 300
() = [ 3 ] ()
+ 40 2 + 300 + 3000
Quiz 13 Solution
The differential equations for the suspension shown below with input displacement u(t) are
10 + 100 + 1000 = 100 + 1000
100 + 4000 = 100 + 1000 + 3000
(a) Assume all initial conditions are zero and convert the equations above to Laplace domain.
Z
+ 10 + 100 = 10 + 100
+ 40 = + 10 + 30
Laplace transforming gives
( 2 + 10 + 100)() = (10 + 100)()
( + 40)() = ( + 10)() + 30()
(b) Demonstrate that if you solve for W(s) in the first equation and then substitute this
expression for W(s) into the 2nd equation, when you solve for Z(s) you get
( + 10)() + 30()
() =
( + 40)
( + 10)() + 30()
( 2 + 10 + 100)() = (10 + 100)
( + 40)
144
3000 + 300
() = [ ] ()
3 + 40 2 + 300 + 3000
Quiz 14
Express the following differential equation with input u in state variable format. What are the initial
conditions for the state variables?
+ 5 + 10 = 20 + 40(0 ) = 3 (0 ) = 0.5(0 ) = 0
Quiz 14 solution
Express the following differential equation with input u in state variable format. What are the initial
conditions for the state variables?
+ 5 + 10 = 20 + 40(0 ) = 3 (0 ) = 0.5(0 ) = 0
1 = 2 = 201 (0 ) = 32 (0 ) = 0.5
1 = 2 + 20 2 = 101 52 60
Quiz 15
(d) Suppose the input u(t) is a unit step. What will be the final value of z(t)?
(e) How long will it take for z(t) to be within 1% of this final value?
Quiz 15 Solution
(d) Suppose the input u(t) is a unit step. What will be the final value of z(t)?
0 + 0 + 10() = 0 + 20(1)() = 2
(e) How long will it take for z(t) to be within 1% of this final value?
It takes about five times the largest time constant = 5/2 = 2.5 seconds
Quiz 16
1 2 3
(1) = [4 5 6] =
7 8 9
1 2 3 1
(2) = [4 5 6] = [1] =
7 8 9 1
1
(3) [2 4 1] [2 ] =
3
1 2
1
(4) [3 4] [ ] =
2
5 6
1
(5) [2] [4 5 6] =
3
1 1
(6) [2] . [2]
3 3
Express the differential equation below in matrix state variable format, i.e.
= + = +
+ 2 + 3 + 8 = 10 = 0.1
146
Quiz 16 Solution
1 2 3 1 4 7
(1) = [4 5 6] = [2 5 8]
7 8 9 3 6 9
1 2 3 1 6
(2) = [4 5 6] = [1] = [15]
7 8 9 1 24
1
(3) [2 4 1] [2 ] = 21 + 42 3
3
1 2 1 + 22
1
(4) [3 4] [ ] = [ 1 + 42 ]
3
2
5 6 51 + 62
1 4 5 5
(5) [2] [4 5 6] = [ 8 10 12]
3 12 15 18
1 1 1
(6) [2] . [2] = [4]
3 3 9
Express the differential equation below in matrix state variable format, i.e.
= + = +
+ 2 + 3 + 8 = 10 = 0.1
1 = 2 = 3 =
1 0 1 0 1 0
[ 2 ] = [ 0 0 1 ] [ 2 ] + [ 0 ]
3 8 3 2 3 10
1
= [0 0
0.1] [ 2 ] + [0]
3
Quiz 17
Solve the following differential equation using separation of variables.
20 + 60 = 80(0 ) = 2
147
Quiz 17 Solution
+ 0.8 + = 0.8 +
(a) Express this differential equation in state variable format assuming y = u -z is the output of
interest.
(b) Enter your state variable equations in MATLAB using the ss command.
(c) Use the eig command to get the eigenvalues? Are these the correct values?
(d) Use the command step to get a plot of y(t) for u(t) a step with magnitude 0.1. Does the plot
start and end at the correct initial and final values?
Quiz 18 Solution
+ 0.8 + = 0.8 +
148
z
(a) Express this differential equation in state variable format assuming y = u -z is the output of
interest.
1 = 2 = 0.8
0 1 0.8
= [ ] + [ ] = [1 0] + [1]
1 0.8 0.36
(b) Enter your state variable equations in MATLAB using the ss command.
>> A=[0 1;-1 -0.8];
>> B=[0.8;0.36];
>> C=[-1 0];
>>D=[1];
>>G=ss(A,B,C,D);
(c) Use the eig command to get the eigenvalues? Are these the correct values?
>> ev=eig(A)
Eigenvalues = -0.4 j0.8
(d) Use the command step to get a plot of y(t) for u(t) a step with magnitude 0.1. Does the plot
start and end at the correct initial and final values?
>> step(G)
The value of y at t = 0+ is 1 and the final value is 0.
Quiz 19
Quiz 19 Solution
3 23 + 12( 2) = 12 16
149
Quiz 20
Two simultaneous differential equations are shown below.
1 = 2
2 = 1001 22
What are the two unknowns? _______________________
Eliminate 2 and get a single differential equation for 1 .
Quiz 20 Solution
1 + 2 1 + 1001 = 0
Quiz 21
(a) Express the differential equation shown below in state variable format using matrices, i.e.
= + = + =? =? =? =?
The output of interest is = .
4 + 24 + 40 = 24 + 40(0 ) = 3 (0 ) = 2() =
(b) What are the initial conditions for the state variables, i.e. 1 (0 ) =?, 2 (0 ) =?, .
(c) For an ode45 numerical simulation, what would you specify for the final time (when to stop
the simulation)?
Quiz 21 Solution
0 1 6
(a) = [ ] = [ ] = [1 0] = [0]
10 6 26
(b) 1 (0 ) = 32 (0 ) = 2 Note, a unit step is zero at t = 0-
(c) Final time 5/3 sec.
150
Chapter 7 Previous Homework and Solutions
Homework 1
For each of the differential equations below, solve for the Laplace transform of y(t) which is
denoted by Y(s). In every case, the answer should be the ratio of two polynomials; no other form
is acceptable. For example
2 2 + 4 + 5
() = 3
8 + 7 2 + 3 + 4
1. + 3 = 0(0 ) = 4
2. + 3 = 2(0 ) = 4
3. + 3 = 10()(0 ) = 4
4. 5 + 2 + 3 = 0(0 ) = 4 (0 ) = 8
5. 5 + 2 + 3 = 10(0 ) = 4 (0 ) = 8
Homework 1 Solution
4
1.
+3
4+2
2. (+3)
14
3. +3
20+48
4. 52 +2+3
202 +48+10
5. (52 +2+3)
Homework 2
Use the residue theorem to find the inverse Laplace transform y(t) for each of the following Y(s):
1
1. () = +4
+2
2. () = (+5)(+10)
2 +2+10
3. () = (+2)(+10)
+4
4. () = (+2+5)(+25)
Homework 2 Solution
Use the residue theorem to find the inverse Laplace transform y(t) for each of the following Y(s):
1
1. () = +4 () = 4
+2 3 8
2. () = (+5)(+10) () = 5 5 + 5 10
151
2 +2+10 5 9
3. () = (+2)(+10) () = 0.5 0 8 2 + 8 10
(b) For 1. and 2. in part (a), solve these differential equations using the separation of variables
method and confirm that you got the same answers as found in part (a).
(c) For the following differential equations with input u(t), find the transfer functions and
eigenvalues.
1. + 3 + 11.25 + 18.5 = 10
2. + 3 + 11.25 + 18.5 = 10 + 5
3. 4 + 12 + 45 + 74 = 12 + 8 + 4
Homework 3 Solution
152
Homework 4
A cart with the ring attached to it moves latterly with displacement z and the ball rolls without
slip with angle inside the ring.
The differential equations for this system assuming small angles can be shown to be
1. Use symbolic math and the 'solve' command in MATLAB and solve for the Laplace
transform of (t ), which is denoted by (s ). Use the initial value theorem to see if it is
correct.
2. Perform the inverse Laplace transform and get an equation for (t ). Use 'pfract' to
simplify getting the inverse Laplace transform. Check the equation at t = 0; does it give
the initial value?
3. Using the impulse command get values of (t ) . Use the output bracket format so you
will have values of and t to use in the (t ) equation and in the plot command.
[Th,t]=impulse( )
4. Using the plot command in MATLAB plot (t ) as a function of time using values from
your equation and values from the impulse command (t and ). Both plots should be on
the same graph; use the xlabel, ylabel, title, and legend commands with your plots. Are
your plots identical? If not, find your error and get them to be identical.
153
Homework 4 Solution
A cart with the ring attached to it moves latterly with displacement z and the ball rolls without
slip with angle inside the ring.
The differential equations for this system assuming small angles can be shown to be
1. Use symbolic math in MATLAB and solve for the Laplace transform of (t ), (s ).
>> syms s
>> H=solve('2.45*(s^2*Th-0.5*s)+0.98*(s*Th-0.5)+9.8*Th+s^2*Z=0',...
'(12*s^2+720*s+1200)*Z+3.5*(s^2*Th-0.5*s)=0','Z,Th');
>> TH=collect(H.Th,s);
>> pretty(TH)
3 2
185.0 s + 12684.0 s + 26040.0 s + 8400.0
----------------------------------------------------------
4 3 2
370.0 s + 25368.0 s + 53760.0 s + 117600.0 s + 168000.0
This is the Laplace transform (s) . Checking the initial value theorem to see if it is
correct:
185
(0 ) s ( s) s 0.5 which is correct since the initial value is 0.5.
370
2. Perform the inverse Laplace transform and get an equation for (t ).
>> pfract([185 12684 26040 8400],[370 25368 53760 117600 168000])
154
Transfer function from input 1 to output:
-6.349e-005
-----------
s + 66.45
>> n=0.4995*(-0.2017+j*1.9873)+0.1982;
>> C=abs(n)/1.9873
C = 0.5019
>> phi=angle(n)
phi = 1.4729
Thus, the inverse Laplace transform of (s) is
(t ) 0.00006349e66.45t 0.0005387e1.713t 0.5019e0.2017t sin(1.9873t 1.4729)
Checking the answer at t = 0 gives (0) 0.5 which is the correct value.
3. Using the impulse command get values of (t ) .
>> THtf=tf([185 12684 26040 8400],[370 25368 53760 117600 168000]);
>> [THt,t]=impulse(THtf); % Note, the output brackets give numerical values for theta and time
to be used in the equation for theta and in the plot command.
4. Using the plot command in MATLAB plot (t ) as a function of time using values from your
equation and values from the impulse command (t and ). Both plots should be on the same
graph. Are your plots identical? If not, find your error and get them to be identical.
Homework 6 Solution
0.5
using inverse Laplace
0.4 using impulse command
0.3
0.2
Theta, radians
0.1
-0.1
-0.2
-0.3
-0.4
0 5 10 15 20 25 30
Time, sec.
The two different approaches give identical results for the simulation of the angular position of
the ball in the ring. Note that it does start at 0.5 and ends at zero which are correct.
Homework 5
A cart with the ring attached to it moves latterly with displacement z and the ball rolls without slip with
angle inside the ring. The force F is the input to the system.
Z
F
156
The differential equations for this system assuming small angles can be shown to be
1. Use symbolic math in MATLAB and the solve command to get the transfer function for (s ) .
2. What is the DC gain for this transfer function? What does this DC gain mean if F is a step input?
Explain why this makes sense.
3. Use the damp command to get the eigenvalues, damping ratios, undamped natural
frequencies, and time constants.
4. Use pfract to determine the modes of this system. This system consists of two basic
components, the cart and the ball. See if you can determine by common sense which modes are
associated with each component.
5. Assume that F is a step with magnitude of 1000 and use the step command to get a plot of
(t ) . Is the time required to reach steady state approximately 5 times the largest time
constant? Is the oscillatory nature of the response consistent with the magnitude of the
damping ratio?
6. Assume that F = 1000e-5t and use the impulse command to get a plot of (t ) .
Homework 5 Solution
A cart with the ring attached to it moves latterly with displacement z and the ball rolls without slip with
angle inside the ring. The force F is the input to the system.
Z
F
The differential equations for this system assuming small angles can be shown to be
157
1. Use symbolic math in MATLAB and the solve command to get the transfer function for (s ) .
>> syms s F
>> H=solve('(2.45*s^2+0.98*s+9.8)*Th+s^2*Z=0',...
'(12*s^2+720*s+1200)*Z+3.5*s^2*Th=F','Z,Th');
>> h=collect(H.Th,s);
>> h=collect(h,F);
>> pretty(h)
-50 s^2
--------------------------------------------------------------------------- F
1295 s^4 + 88788 s^3 + 188160 s^2 + 411600 s + 588000
2. What is the DC gain for this transfer function? What does this DC gain mean if F is a step input?
Explain why this makes sense.
3. Use the damp command to get the eigenvalues, damping ratios, undamped natural
frequencies, and time constants.
>> damp(G)
Eigenvalue Damping Undamped natural frequency (rad/s)
-1.71e+000
-2.02e-001 + 1.99e+000i 1.01e-001 2.00e+000
-2.02e-001 - 1.99e+000i 1.01e-001 2.00e+000
-6.64e+001
Time constants = 1/1.71, 1/0.202, and 1/66.4 seconds
4. Use pfract to determine the modes of this system. This system consists of two basic
components, the cart and the ball. See if you can determine by common sense which modes are
associated with each component.
>> pfract([-50 0 0],[1295 88788 188160 411600 588000])
Mode #1
0.0005995
---------
s + 66.45
158
Mode#2
-0.0003188 s + 0.000618
-----------------------
s^2 + 0.4034 s + 3.99
Mode #3
-0.0002808
----------
s + 1.713
Mode 2 is an oscillatory mode which is associated with the ball rolling back and forth inside the
ring. Modes 1 and 3 by default have to be associated with the movement of the cart.
5. Assume that F is a step with magnitude of 1000 and use the step command to get a plot of
(t ) . Is the time required to reach steady state approximately 5 times the largest time
constant? Is the oscillatory nature of the response consistent with the magnitude of the
damping ratio?
>> step(1000*G)
Step Response
0.2
0.15
0.1
0.05
Amplitude
-0.05
-0.1
-0.15
0 5 10 15 20 25 30
Time (sec)
Note that the ball initially rolls up the right side of the ring which is consistent with the cart
suddenly being pushed to the left. Five times the time constant of the oscillatory mode is about
25 seconds which is approximately how long it takes for the ball to quit moving around and end
up at 0 . The smaller the damping ratio, the more oscillatory the response. The response
is consistent with a damping ratio of 0.1.
159
6. Assume that F = 1000e-5t and use the impulse command to get a plot of (t ) .
1000
For this F(t), F ( s ) . Thus,
s5
50s 2 1000
(s)
1295s 88788s 188160s 411600s 588000 s 5
4 3 2
In MATLAB, the best way to multiply two transfer functions is with the 'series' command, i.e.
>> GF=series(G,tf(1000,[1 5]))
Transfer function:
-50000 s^2
--------------------------------------------------------------------------
1295 s^5 + 95263 s^4 + 632100 s^3 + 1.352e006 s^2 + 2.646e006 s + 2.94e006
Pretending that GF is a transfer function with a unit impulse input allows us to get a plot of
(t ) using the impulse command, i.e.
>> impulse(GF)
>> title('Response of ball for exponential force input')
>> ylabel('Ball angle, radians')
0.06
0.04
Ball angle, radians
0.02
-0.02
-0.04
-0.06
0 5 10 15 20 25 30
Time (sec)
Homework 6
Consider the following differential equation with input u(t) which is a unit step function.
+ 2 = + 6(0 ) = 1
(a) Using Laplace transform and the residue theorem, find an equation for z(t).
(b) Express the original differential equation in the format required for numerical analysis.
1
Using 10 of the time constant for T, use Euler's integration to compute z(T) and z(2T).
160
(c) Compare the values of z(T) and z(2T) obtained in part (b) with values of z(t) at t=T and t=2T
using your equation obtained in part (a). They should be very close for this small value of T. If
they are not close, then figure out which one you are doing incorrectly.
Homework 6 Solution
Consider the following differential equation with input u(t) which is a unit step function.
+ 2 = + 6(0 ) = 1
(a) Using Laplace transform and the residue theorem, find an equation for z(t).
1
() 1 + 2() = () 0 + 6()() =
Thus,
2 + 6
() =
( + 2)
Using the residue theorem to find the inverse Laplace transform gives
() = 3 2
(b) Express the original differential equation in the format required for numerical analysis.
1
Using 10 of the time constant for T, use Euler's integration to compute z(T) and z(2T).
= 6 2
Thus, = and = 6 2 = 6 2( + ) = 2 + 4
Time constant =1/2 = 0.5. Thus, T = 0.05
(c) Compare the values of z(T) and z(2T) obtained in part (b) with values of z(t) at t=T and t=2T
using your equation obtained in part (a). They should be very close for this small value of T. If
they are not close, then figure out which one you are doing incorrectly.
t x(t) () = x(t+T)= z(t+T)= Analytical Sol.
2() + 4() T () + () x(t+T)+u(t+T) 3 2(+)
0- 1 -2 + 4 = 2 0.05*2 + 1=1.1 1.1+1=2.1 3 2(.05) =
2.095
0.05 1.1 -2*1.1 + 4= 1.8 0.05*1.8+1.1= 1.19+1=2.19 3 2(0.1) =
1.19 2.181
0.10 1.19 -2*1.19+4=1.62 0.05*1.62+1.19= 1.271+1= 3 2(0.15) =
1.271 2.271 2.259
Because of the term in the original differential equation which is an impulse for a step, the
(0 ) (0+ ) = 2. Regardless, z(0.05) and z(0.1) from both methods of solution are very
close, i.e.
2.1 compared to 2.095 and 2.19 compared to 2.181
2.2
161
Homework 7
Use 'ode45' in MATLAB and generate a plot of v(t ) for the following differential equation. The
input u(t) is a step with magnitude of 0.5.
Homework 7 Solution
Homework 8
Consider the following differential equation for a suspension system:
Homework 8 Solution
Consider the following differential equation for a suspension system:
162
4. Obtain a linear approximation for this differential equation by obtaining a straight line
approximation for 3 using the point and slope method. Be sure to start by sketching 3 and
noting the location of your straight line.
Y3=0.13+3(.1)2(y-0.1)=0.001+0.03(y-0.1)=0.03y-0.002
5. After substituting your straight line into the original differential equation, check to see if the
new linearized differential equation gives the correct final value.
y+6.5y+9800[.03y-0.002]=9.8
Or
y+6.5y+294y=29.4
Homework 9
The equations for a spring/mass/damper system are shown below.
(a) Laplace transform the three equations to get three algebraic equations in terms of the three
unknowns Y(s), (), () and in terms of the ground input U(s).
Assume (0 ) = 0(0 ) = 0 (0 ) = 2
(b) Since you now have three algebraic equations and three unknowns, you can eliminate the
unknowns () () and simplify the three equations down to one equation for the
unknown (). Do this to get an expression for ().
(c) What is the transfer function for this suspension system? What are the eigenvalues? What is
the time constant? What is the damping ratio? What is the undamped natural frequency?
163
(d) Assume u(t) is a step input with magnitude 0.2. Find an expression for Y(s); the answer will be a
numerator polynomial over a denominator polynomial. Check the accuracy of your Y(s) using
the initial and final value theorems.
Homework 9 Solution
The equations for a spring/mass/damper system are shown below.
(a) Laplace transform the three equations to get three algebraic equations in terms of the three
unknowns Y(s), (), () and in terms of the ground input U(s).
Assume (0 ) = 0(0 ) = 0 (0 ) = 2
100
10[ 2 () 2] + () + () =
() = 1000[() ()]
() = 40[() ()]
(b) Since you now have three algebraic equations and three unknowns, you can eliminate the
unknowns () () and simplify the three equations down to one equation for the
unknown (). Do this to get an expression for ().
100
10[ 2 () 2] + 40() + 1000() = [40 + 1000]()
40 + 1000 20 100
() = [ ] () +
10 2
+ 40 + 1000 2
(10 + 40 + 1000)
(c) What is the transfer function for this suspension system? What are the eigenvalues? What is
the time constant? What is the damping ratio? What is the undamped natural frequency?
40+1000
Transfer function: 102 +40+1000
which simplifies to
28 + 100
() = [ ]
[10 2+ 40 + 1000]
100
Final value theorem: () = 1000 = 0.1 which checks since when you plug u=0.2 and all
derivatives equal to zero into the original three equations and solve for y, you get 0.1.
Initial value theorem: (0+ ) = 0 which matches the initial condition on (), (0 ) = 0.
Note, if you multiply Y(s) by s, you get the Laplace transform for (), i.e.
28 + 100
() = [ ]
[10 2 + 40 + 1000]
Applying the initial value theorem gives (0+ ) = 2.8 (0 ) = 2.
This difference is due to the term in the equations which is an impulse when is a step; that
is, an impulse force acting on the mass causes the velocity of the mass to instantly change.
Homework 10
The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 3
402 = 02 (0 ) = 5
1 2 = 250 (0 ) = 0
H1 H2
Q
165
(f) If you Laplace transform each of these three equations you get
20[1 () 3] = 0
40[2 5] = 0
1 2 = 250[() 0]
(h) Use the residue theorem and shortcut for complex poles to get an equation for H1(t).
(i) Use the impulse command in MATLAB to get a plot of H1(t) and plot the equation found in
part (c) on the same graph with red dots for comparison.
Homework 10 Solution
The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 3
402 = 02 (0 ) = 5
1 2 = 250 (0 ) = 0
H1 H2
Q
(j) If you Laplace transform each of these three equations you get
20[1 () 3] = 0
40[2 5] = 0
1 2 = 250[() 0]
(l) Use the residue theorem and shortcut for complex poles to get an equation for H1(t).
13104 0 0 3 2 + 13104
1 () = + | | sin(0.01732 + )
3104 0.01732 =0+0.01732
3 2 + 13104 3(0.01732)2 + 13104
| | =| | = 0.023098
=0+0.01732
0.01732
= 1.5708
Thus
1 () = 4.333 + 1.333sin(0.01732 1.5708)
Checking at t = 0
1 (0) = 4.333 + 1.333(1) = 3 which is correct!
(m) Use the impulse command in MATLAB to get a plot of H1(t) and plot the equation found in
part (c) on the same graph with red dots for comparison.
>> [h1m,t]=impulse(h1,2000);
>> plot(t,h1m,'k',t,4.333+1.333*sin(0.01732*t-1.5708),'r.')
>> xlabel('time, sec.')
>> ylabel('H1')
>> title('Homework 5 comparing solutions to water tanks problem')
>> legend('solution from impulse command','inverse Laplace solution','location',best)
Homework 5 comparing solutions to water tanks problem
6
5.5
5
solution from impulse command
inverse Laplace solution
H1
4.5
3.5
3
0 500 1000 1500 2000 2500
time, sec.
167
Homework 11
The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 3
402 = 02 (0 ) = 5
1 2 = 250 + (0 ) = 0
H1 H2
Q
(n) Laplace transform each of these three equations and solve for the Laplace transform for H1
by hand; that is, you do the algebra. The answer will be in terms of R.
(o) Repeat (a) only this time use symbolic math in MATLAB; confirm that you get the same
equation for H1(s).
(p) Determine the value of R that results in a damping ratio of 0.5 (or whatever I told you in
class). Once you have determined the necessary value for R, use the subs command to
get the transfer function with the value of R needed for the desired damping ratio.
(q) Use the impulse command in MATLAB to get plots of H1(t) using the value of R found in part
(c); plot on the same graph, H1(t) for two other values of R, one 20% greater and one 20%
smaller than the R that gives your desired damping ratio. In what ways are these plots of
H1 the same? Different?
Homework 11 Solution
The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 3
402 = 02 (0 ) = 5
1 2 = 250 + (0 ) = 0
168
H1 H2
Q
(r) Laplace transform each of these three equations and solve for the Laplace transform for H1
by hand; that is, you do the algebra. The answer will be in terms of R.
(s) Repeat (a) only this time use symbolic math in MATLAB; confirm that you get the same
equation for H1(s).
(t) Determine the value of R that results in a damping ratio of 0.5 (or whatever I told you in
class). Once you have determined the necessary value for R, use the subs command to
get the transfer function with the value of R needed for the desired damping ratio.
(u) Use the impulse command in MATLAB to get plots of H1(t) using the value of R found in part
(c); plot on the same graph, H1(t) for two other values of R, one 20% greater and one 20%
smaller than the R that gives your desired damping ratio. In what ways are these plots of
H1 the same? Different?
syms s R
H=solve('-Q-20*(s*H1-3)=0','Q-40*(s*H2-5)=0','H1-H2=250*s*Q+R*Q','H1,H2,Q');
pretty(H.H1)
digits 4
%The value of R in the following statements obtained using the results of
%the first three statements above.
h1a=vpa(subs(H.H1,R,3.4641));
h1b=vpa(subs(H.H1,R,3.4641*1.2));
h1c=vpa(subs(H.H1,R,3.4641*0.8));
%The polynomials in the following statements obtained using the results of
%the previous three statements above.
%The symbolic polynomials in the commands below were copied from the output
%of the previous three commands and then pasted into the sym2poly command.
h1aTF=tf(sym2poly(30000.0*s^2 + 415.7*s + 13.0),sym2poly(s*(10000.0*s^2 +
138.6*s + 3.0)));
h1bTF=tf(sym2poly(30000.0*s^2 + 498.8*s + 13.0),sym2poly(s*(10000.0*s^2 +
166.3*s + 3.0)));
h1cTF=tf(sym2poly(30000.0*s^2 + 332.6*s + 13.0),sym2poly(s*(10000.0*s^2 +
110.9*s + 3.0)));
impulse(h1aTF,'k',h1bTF,'k.',h1cTF,'k-.',800)
legend('R = 3.4641','R = 1.2*3.4641','R = 0.8*3.4641','location','best')
title('Height H1 of water in the first tank following unequal height initial
conditions')
169
Height H1 of w ater in the first tank follow ing unequal height initial conditions
4.8
4.6
4.4
4.2
4
Amplitude
R = 3.4641
R = 1.2*3.4641
3.8 R = 0.8*3.4641
3.6
3.4
3.2
3
0 100 200 300 400 500 600 700 800
Time (seconds)
Adding friction associated with viscosity to the water flowing through the line between
tanks causes the water levels to eventually quit oscillating and settle at the correct steady
state height.
Homework 12
It can be shown that the differential equation for the suspension system shown below is a follows:
M=1000 kg
170
The solution to this differential equation is the displacement of the mass z(t) resulting from the non-
smooth road profile u(t) which represents a displacement input.
(e) We have learned in class that you can get a plot of z(t) by pretending that Z(s) is a transfer
function with a unit impulse input and then using the command impulse in MATLAB to
generate a plot of z(t). Use the impulse command on Z(s) and then add this plot to the plot in
part (c) using the hold command. The plots should be identical so use dots for one of the
functions and the command legend to distinguish between the two. Note, when you multiply
U(s) times the transfer function to get Z(s), use the command series for multiplying two
transfer functions; do not use g*h where g and h are the two transfer functions to be
multiplied. Also, although not needed here, when adding two transfer functions, use parrallel;
do not simply add them such as g + h.
Note, instead of using the hold command, you can use the following to get both plots of z(t) on
the same plot:
>> [zi]=impulse(Z,t);
>> plot(t,z,r.,t,zi,k)
Use this approach to generate a second combined plot. Be sure your plot has a title, xlabel,
ylabel, and legend.
Confirm that the plots are identical.
(f) Another way to get a plot of z(t) is to use the command lsim. The commands will be as follows:
>> t=0:0.01:7; Actually, you dont need to generate t again if the values of t are still in memory.
>> u=1-cos(2*t);
>> [zLsim]=lsim(G,u,t);
Generate a combined plot using
>> plot(t,z,k.,t,zi,r+,t,zLsim,k*)
Be sure your plot has a title, xlabel, ylabel, and legend.
Confirm that all three plots are identical.
171
(g) Considering the equation for the input u(t), what can you say about the resulting displacement
of the mass. For example, compare the input and output frequencies. Also, compare the input
and output amplitudes. You might want to plot z(t) and u(t) on the same graph to answer these
questions.
Homework 12 Solution
It can be shown that the differential equation for the suspension system shown below is a follows:
M=1000 kg
The solution to this differential equation is the displacement of the mass z(t) resulting from the non-
smooth road profile u(t) which represents a displacement input.
7200+36000
(a) What is the transfer function G(s) for this system?() = 10002 +7200+36000
(b) What are the eigenvalues, damping ratio, and time constant of this system? -3.6j4.8, 0.6, 0.278
4
(c) Assume that () = 1 cos(2). If {cos()} = 2 +2 show that () = (2 +4)
1 4
{1 cos(2)} = 2 =
+ 4 ( 2 + 4)
(d) For the u(t) in (c), obtain the expression for Z(s) assuming all initial conditions are zero, and then
using the inverse Laplace transform, find an equation for z(t).
7200 + 36000 4
() = ()() =
1000 2 + 7200 + 36000 ( 2 + 4)
The following m-file was used to express Z(s) in partial fractions:
G=tf([7.2 36],[1 7.2 36]);
Z=series(G,tf([4],[1 0 4 0]));
[num,den]=tfdata(Z,'v')
pfract(num,den)
172
3.6
() = 1 + |0.104 + 0.842|=3.6+4.8 sin(4.8 + )
4.8
0
+ |1.104 0.9356|=2 sin(2 + )
2
= 1 + 0.14249 3.6 sin(4.8 + 0.81765) + 1.1049sin(2 1.6131)
After finding the equation for z(t), generate an array of values of t and z(t) in MATLAB using
>> t=0:0.01:7;
>> z=your equation goes here;
Dont forget, when multiplying two arrays, element by element, you must use .* instead of *.
format shorte
t=0:0.01:7;
z=1+0.14249*exp(-3.6*t).*sin(4.8*t+0.81765)+1.1049*sin(2*t-1.6131);
plot(t,z,'k')
title('Homework 7 part(d)')
xlabel('time, sec.')
ylabel('z(t)')
Homework 7 part(d)
2.5
1.5
z(t)
0.5
-0.5
0 1 2 3 4 5 6 7
time, sec.
(e) We have learned in class that you can get a plot of z(t) by pretending that Z(s) is a transfer
function with a unit impulse input and then using the command impulse in MATLAB to
generate a plot of z(t). Use the impulse command on Z(s) and then add this plot to the plot in
part (d) using the hold command. The plots should be identical so use dots for one of the
functions and the command legend to distinguish between the two. Note, when you multiply
U(s) times the transfer function to get Z(s), use the command series for multiplying two
transfer functions; do not use g*h where g and h are the two transfer functions to be
multiplied. Also, although not needed here, when adding two transfer functions, use parrallel;
do not simply add them such as g + h.
173
[zi]=impulse(Z,t);
plot(t,z,'k',t,zi,'r.')
xlabel('time, sec.')
ylabel('z(t)')
title('Homework 7 part(e)')
legend('from inverse Laplace','from impulse command','location','best')
Homework 7 part(e)
2.5
1.5
z(t)
0.5
0
from impulse command
from inverse Laplace
-0.5
0 1 2 3 4 5 6 7
time, sec.
Homework 7 part(f)
2.5
0.5
-0.5
0 1 2 3 4 5 6 7
time, sec.
174
(g) Considering the equation for the input u(t), what can you say about the resulting displacement
of the mass. For example, compare the input and output frequencies. Also, compare the input
and output amplitudes. You might want to plot z(t) and u(t) on the same graph to answer these
questions.
The input and output frequencies are identical; this is always the case. In regard to the amplitude of the
output, it will either be larger or smaller than the amplitude of the input depending on the magnitude of
the transfer function at the input frequency. The input of 1-cos2t produces a wave from 0 to 2. From the
graph, we see that z(t) goes from 0 to about 2.1. The value of 2.1 can also be determined from the
inverse Laplace transform equation for z(t), i.e.
() = 1 + 0 + 1.1049sin()
Note in the equation above, the peak value will be 1 + 1.1049 = 2.1049.
The entire m-file used for this homework solution is given below:
format shorte
G=tf([7.2 36],[1 7.2 36]);
Z=series(G,tf([4],[1 0 4 0]));
[num,den]=tfdata(Z,'v')
pfract(num,den)
t=0:0.01:7;
z=1+0.14249*exp(-3.6*t).*sin(4.8*t+0.81765)+1.1049*sin(2*t-1.6131);
plot(t,z,'k')
title('Homework 7 part(d)')
xlabel('time, sec.')
ylabel('z(t)')
figure
[zi]=impulse(Z,t);
plot(t,z,'k',t,zi,'r.')
xlabel('time, sec.')
ylabel('z(t)')
title('Homework 7 part(e)')
legend('from inverse Laplace','from impulse command','location','best')
figure
u=1-cos(2*t);
[zLsim]=lsim(G,u,t);
plot(t,z,'k',t,zi,'r.',t,zLsim,'k*')
xlabel('time, sec.')
ylabel('z(t)')
title('Homework 7 part(f)')
legend('from inverse Laplace','from impulse command','from lsim','location','best')
Homework 13
If a linear system has a sine wave input and all of the eigenvalues of the system have nonzero negative
real parts, then after approximately five times the largest time constant, the output will be a sine wave
at the same frequency with an amplitude equal to the input amplitude times the magnitude of the
system transfer function evaluated with s = jI where is the input frequency, i.e.
() = ()()() = ( )() = |( )|sin( + )
= [( )]
(a) In your own words and math, redo the proof of this result using the shortcut of the residue
theorem applied to the complex poles of Z(s).
175
(b) Apply this expedited approach to getting an equation for y(t) for for the following
system:
+ 10
() = [ ] X(s)() = 5sin(4)
+2
(c) Apply this expedited approach to getting an equation for w(t) for for the following
system:
100
() = [ ] ()() = 10sin(3)
( + 2)2 + 32
Homework 13 Solution
If a linear system has a sine wave input and all of the eigenvalues of the system have nonzero negative
real parts, then after approximately five times the largest time constant, the output will be a sine wave
at the same frequency with an amplitude equal to the input amplitude times the magnitude of the
system transfer function evaluated with s = jI where is the input frequency, i.e.
= [( )]
(a) In your own words and math, redo the proof of this result using the shortcut of the residue
theorem applied to the complex poles of Z(s).
() = () 2
+ 2
() = () + 0
After about five times the largest time constant assuming all poles of H(s) have non-zero negative real
parts,
1
() = 0 + 0 = |( ) | sin( + [( ) ])
= |( )| sin( + [( )])
(b) Apply this expedited approach to getting an equation for y(t) for for the following
system:
+ 10
() = [ ] X(s)() = 5sin(4)
+2
4 + 10 4 + 10
() = 5 | | sin (4 + [ ])
4 + 2 4 + 2
42 + 102 4 4
=5 sin(4 + 1 ( ) 1 ( ))
42 + 22 10 2
= 12.0416sin(4 0.7266)
176
Using MATLAB to check the result for = 4,
>> s=j*4;
>> H=(s+10)/(s+2);
>> 5*abs(H)= 12.0416
>> angle(H)= -0.7266
These answers agree with the hand calculations.
Bode Diagram
15
Magnitude (dB)
10
System: H
5 Frequency (rad/s): 4
Magnitude (dB): 7.63
0
0
Phase (deg)
-30
System: H
Frequency (rad/s): 4
-60 Phase (deg): -41.4
-1 0 1 2 3
10 10 10 10 10
Frequency (rad/s)
7.63
From the graph above 2010 |(4)| = 7.63 Thus, 5|(4)| = 5 10 20 = 12.04 and
the phase angle is -41.4 deg = -0.7226. These results also agree with the hand calculations.
Note, using bode, we can get the magnitude and phase of the transfer function at any input
frequency.
(c) Apply this expedited approach to getting an equation for w(t) for for the following
system:
100
() = [ ] ()() = 10sin(3)
( + 2)2 + 32
100 3 100 3
() = 10 | 2 2 | sin (3 + [ ])
(3 + 2) + 3 (3 + 2)2 + 32
= 237.17sin(3 + 0.3218)
177
Homework 14
Express the differential equations below in state variable format, i.e.
1 = 1 (1 , 2 , , , ) 1 (0 )
2 = 2 (1 , 2 , , , ) 2 (0 )
..
= (1 , 2 , , , ) (0 )
= (1 , 2 , , , )
(1) + 2 + 12 = 4 = (0 ) = 3 (0 ) = 6
(2) + + 2 + 12 = 4 = (0 ) = 3 (0 ) = 6 (0 ) = 1
(3) + 2 3 + 12 = 4 = (0 ) = 3 (0 ) = 6
(4) + 2 + 12 = 4 = (0 ) = 2 (0 ) = 0.4
(5) + 0.2 + 9 sin() = 0.18 = (0 ) = 0.1 (0 ) = 0
Homework 14 Solution
Express the differential equations below in state variable format, i.e.
1 = 1 (1 , 2 , , , ) 1 (0 )
2 = 2 (1 , 2 , , , ) 2 (0 )
..
= (1 , 2 , , , ) (0 )
= (1 , 2 , , , )
(1) + 2 + 12 = 4 = (0 ) = 3 (0 ) = 6
1 = 2 = 1 = 2 2 = 4 121 22 1 (0 ) = 32 (0 ) = 6 = 1
(2) + + 2 + 12 = 4 = (0 ) = 3 (0 ) = 6 (0 ) = 1
1 = 2 = 3 = 1 = 2 2 = 3 3 = 4 121 22 3
1 (0 ) = 32 (0 ) = 63 (0 ) = 1 = 2
(3) + 2 3 + 12 = 4 = (0 ) = 3 (0 ) = 6
1 = 2 = 1 = 2 2 = 4 121 223 1 (0 ) = 32 (0 ) = 6 = 1
(4) + 2 + 12 = 4 = (0 ) = 2 (0 ) = 0.4
1 = 2 = 1 = 2 2 = 4 121 22 1 (0 ) = 22 (0 ) = 0.4 = 1
178
Homework 15
The differential equation for a suspension is given below. The output of interest is y = u z where u is a
displacement input. Assume at time = 0, u(t) is a step with magnitude of 0.05 meters.
k b
Homework 15 Solution
The differential equation for a suspension is given below. The output of interest is y = u z where u is a
displacement input. Assume at time = 0, u(t) is a step with magnitude of 0.05 meters.
k b
179
12,000 + 144,000
() = () () = [() ()]
1000 2 + 12,000 + 144,000
1000 2 0.05 50
= 2
= 2
1000 + 12,000 + 144,000 1000 + 12,000 + 144,000
(b) In MATLAB, use the impulse command to get a plot of y(t).
>> G=tf([50 0],[1000 12000 144000]);
>> impulse(G)
>> title('Homework 10 inverse Laplace of Y(s)')
>> ylabel('y=u-z, meters')
0.04
0.03
0.02
y=u-z, meters
0.01
-0.01
-0.02
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Time (seconds)
+ 12 + 144 = 12 + 144
1 = 2 = 12
1 = 2 + 12 2 = 144 1441 12(2 + 12) = 1441 122
= 1
(d) Use ode45 in MATLAB to numerically solve this differential equation and generate a plot of
y(t).
Compare this plot with the plot in (b) and confirm that the plots are identical.
%m-file to start the simulation saved as Hmwk10Start
[t,x]=ode45(@Hmwk10Eqns,[0 0.9],[0 0]);
y=0.05-x(:,1);
plot(t,y)
title('Homework 10 numerical solution')
ylabel('y = u - z, meters')
xlabel('time, seconds')
180
%m-file containing the state variable differential equations named Hmwk10Eqns
function dx=Hmwk10Eqns(t,x)
dx=zeros(2,1);
u=0.05;
dx(1)=x(2)+12*u;
dx(2)=-144*x(1)-12*x(2);
end
0.04
0.03
y = u - z, meters
0.02
0.01
-0.01
-0.02
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
time, seconds
Homework 16
The differential equation for a suspension is given below. The output of interest is y = u z where u is a
displacement input. Assume at time = 0, u(t) is a step with magnitude of 0.05 meters.
k b
181
(b) In MATLAB, use the impulse command to get a plot of y(t).
(c) Express the differential equation in state variable format.
(d) Use ode45 in MATLAB to numerically solve this differential equation and generate a plot of
y(t). Compare this plot with the plot in (b) and confirm that the plots are identical.
Homework 16 Solution
The differential equation for a suspension is given below. The output of interest is y = u z where u is a
displacement input. Assume at time = 0, u(t) is a step with magnitude of 0.05 meters.
k b
0.04
0.03
0.02
y=u-z, meters
0.01
-0.01
-0.02
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Time (seconds)
182
(g) Express the differential equation in state variable format.
+ 12 + 144 = 12 + 144
1 = 2 = 12
1 = 2 + 12 2 = 144 1441 12(2 + 12) = 1441 122
= 1
(h) Use ode45 in MATLAB to numerically solve this differential equation and generate a plot of
y(t).
Compare this plot with the plot in (b) and confirm that the plots are identical.
%m-file to start the simulation saved as Hmwk10Start
[t,x]=ode45(@Hmwk10Eqns,[0 0.9],[0 0]);
y=0.05-x(:,1);
plot(t,y)
title('Homework 10 numerical solution')
ylabel('y = u - z, meters')
xlabel('time, seconds')
0.04
0.03
y = u - z, meters
0.02
0.01
-0.01
-0.02
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
time, seconds
183
Homework 17
The differential equation for a suspension is given below. The output of interest is y = u z where u is a
displacement input.
k b
(a) Find the transfer function for Y(s). That is, if Y(s)=H(s)U(s), what is H(s)?
(b) Use the phase variable method to express H(s) in state variable format. A=? B=? C=? D=?
The phase variable method requires that the numerator polynomial be at least one less order
than the denominator.
(d) Use the command tf2ss in MATLAB to generate values of A, B, C, and D. Explain why some of
these are different from those in (b).
(e) Using the values found in (b) use the command ss2tf to generate a transfer function. How
does this transfer function compare with H(s) in (a)?
(f) Use the simulation diagram method to create values of A, B, C, and D for this differential
equation and output of interest y=u-z. How do these values compare with those in (b) and
those in (d)? Use ss2tf with these values to generate a transfer fun. How does it compare
with H(s) in (a)?
Homework 17 Solution
The differential equation for a suspension is given below. The output of interest is y = u z where u is a
displacement input.
184
z
k b
(a) Find the transfer function for Y(s). That is, if Y(s)=H(s)U(s), what is H(s)?
12,000 + 144,000
() = () () = [() ()]
1000 2 + 12,000 + 144,000
1000 2
= ()
1000 2 + 12,000 + 144,000
1000 2 2
() = =
1000 2 + 12,000 + 144,000 2 + 12 + 144
(b) Use the phase variable method to express H(s) in state variable format. A=? B=? C=? D=?
The phase variable method requires that the numerator polynomial be at least one less order
than the denominator. Using long division to divide 2 + 12 + 144 into 2 gives
12 + 144
() = 1 2
+ 12 + 144
Thus, we can write
12 + 144 12 + 144
() = ()() = [1 2 ] () = () 2 ()
+ 12 + 144 + 12 + 144
12+144
all we had was Y(s)=- 2 (), then the phase variable equations would be
+12+144
0 1 0
= [ ] + [ ] = [144 12] + [0]
144 12 1
But, y equals u + [144 12]X. So, = [144 12] + [1]
0 1 0
So, = [ ] = [ ] = [144 12] = [1]
144 12 1
Transfer function:
s^2
----------------
s^2 + 12 s + 144
185
(d) Use the command tf2ss in MATLAB to generate values of A, B, C, and D. Explain why some of
these are different from those in (b).
>> num=[1 0 0];
>> den=[1 12 144];
>> [a,b,c,d]=tf2ss(num,den)
a=
-12 -144
1 0
b=
1
0
c=
-12 -144
d=1
a, b, c, and d are not the same as A, B, C, D because the state variables are different.
(e)Using the values found in (b) use the command ss2tf to generate a transfer function. How does
this transfer function compare with H(s) in (a)?
>> [NUM,DEN]=ss2tf(a,b,c,d)
NUM =
1 0 0
DEN =
1 12 144
This transfer function is identical to H(s) above which must be the case.
(f) Use the simulation diagram method to create values of A, B, C, and D for this differential
equation and output of interest y=u-z. How do these values compare with those in (b) and those in
(d)? + 12 + 144 = 12 + 144
1 = 2 = 12
1 = 2 + 12 2 = 144 1441 12(2 + 12) = 1441 122
= 1
0 1 12
=[ ] = [ ] = [1 0] = [1]
144 12 0
186
A, B, and C are not the same as a, b, and c in (d)
Use ss2tf with these values to generate a transfer fun. How does it compare with H(s) in (a)?
>> format short e
>> A=[0 1;-144 -12];
>> B=[12;0];
>> C=[-1 0];
>> D=[1];
>> [num,den]=ss2tf(A,B,C,D)
num =
1.0000e+000 -1.9540e-015 -8.8818e-015
den =
1 12 144
Realizing that two of the numerator terms are very small numbers (essentially zero) associated
with computational errors, we see that we get the same transfer function.
Homework 18
A cannon ball is fired at an initial angle of with an initial velocity of V=100 m/sec. The differential
equations for the ball are as follows:
10z 0.2Vz 0
10 y 0.2Vy 98 0
0 z
187
Homework 18 Solution
All equations, analysis, commands, results and conclusions are to either be typed on or pasted to this
document as you would do in a professional report.
A cannon ball is fired at an initial angle of with an initial velocity of V=100 m/sec. The differential
equations for the ball are as follows:
10z 0.2Vz 0
10 y 0.2Vy 98 0
50
40
Altitude, m
30
20
10
-10
0 20 40 60 80 100 120
Horizontal Distance, m
options=odeset('events',@HonProjStop);
V=100;TH=25*pi/180;
[t,x]=ode45(@HonProjEqns,[0 15],[0 V*cos(TH) 0
V*sin(TH)],options);
TH=45*pi/180;
[t,u]=ode45(@HonProjEqns,[0 15],[0 V*cos(TH) 0
V*sin(TH)],options);
TH=65*pi/180;
188
[t,w]=ode45(@HonProjEqns,[0 15],[0 V*cos(TH) 0
V*sin(TH)],options);
plot(x(:,1),x(:,3),'r.')
hold
plot(u(:,1),u(:,3),'bx')
plot(w(:,1),w(:,3),'k-')
hold off
xlabel('Horizontal Distance, m')
ylabel('Altitude, m')
title('Cannonball Trajectory v. Firing Angle')
legend('25 degrees','45 degrees','65 degrees')
function dx=HonProjEqns(t,x)
dx=zeros(4,1);
V=sqrt(x(2)^2+x(4)^2);
dx(1)=x(2);
dx(2)=-0.02*V*x(2);
dx(3)=x(4);
dx(4)=-9.8-0.02*V*x(4);
end
Homework 19
As shown below, two water tanks are connected by a long pipe. Initially, before the water is allowed to
flow through the pipe, the height H1 of the water in tank #1 is greater than the height H2 of the water in
tank #2.
H1
d H2
L
Q
(1) Laplace transform these equations and solve for 1 (). Use the FVT and IVT to check 1 ().
(2) Find the inverse Laplace of 1 () to get an equation for 1 ().
(3) In MATLAB, pretend that 1 () is a transfer function with a unit impulse input. Use the
command impulse to get a plot of 1 () and plot on the same graph 1 () using the equation
found in (2) above. Use the legend command to confirm that the plots are identical.
(4) Highlight, copy, and paste your MATLAB commands and results on this MS Word document as
part of your solution to be submitted.
Homework 19 Solution
As shown below, two water tanks are connected by a long pipe. Initially, before the water is allowed to
flow through the pipe, the height H1 of the water in tank #1 is greater than the height H2 of the water in
tank #2.
H1
d H2
L
Q
190
10 2 + 0.243055 + .018476 10 2 + 0.243055 + .018476
1 () = =
( 2 + .0243055 + 0.00246348) [( + 0.012153)2 + (0.048123)2 ]
:1 ()= = 1 ()=0 = 7.5:1 ()=0 = 1 ()= = 10
(6) Find the inverse Laplace of 1 () to get an equation for 1 ().
.0121153
1 () (
= + 0)1 () =0 + (0.048123 + )
0.048123
= |( 2 + .0243055 + 0.00246348)1 ()|=0.012153+0.048123 = 0.12409
= [( 2 + .0243055 + 0.00246348)1 ()]=0.012153+0.048123 = 1.3235
1 () = 7.5 + 2.5738 0.012153 sin(.048123 + 1.3235)
(7) In MATLAB, pretend that 1 () is a transfer function with a unit impulse input. Use the
command impulse to get a plot of 1 () and plot on the same graph 1 () using the equation
found in (2) above. Use the legend command to confirm that the plots are identical.
(8) Highlight, copy, and paste your MATLAB commands and results on this MS Word document as
part of your solution to be submitted.
% Homework 3 MAE 3360 10-12-13
format short g
syms s
A=solve('-Q-10*(s*H1-10)=0','Q-10*(s*H2-5)=0',...
'9800*(H1-H2)=795625*s*Q+19338*Q','H1,H2,Q');
digits(5)
h1=vpa(A.H1);%Converts H1(s) solution to floating point numbers
pretty(h1)
[num,den]=numden(h1);% Gets numerator and denominator of H1
Num=sym2poly(num);%Converts numerator from symbolic to polynomial
Den=sym2poly(den);%converts denominator from symbolic to polynomial
roots(Den)%Gets the poles of H1(s)
H1Ptf=tf(Num,Den);%Creates a pretend transfer function assuming unit impulse input
[H1impulse,t]=impulse(H1Ptf);%Generates impulse response and time array
H1t=7.5+2.5738*exp(-0.012153*t).*sin(0.048123*t+1.3235);
plot(t,H1impulse,'r',t,H1eqn,'k:','LineWidth',2)
xlabel('time, sec.')
ylabel('H1, m')
title('Comparing analytical and numerical H1(t) solutions')
legend('impulse command with pretend tf','inverse Laplace transform')
8.5
H1, m
7.5
6.5
6
0 50 100 150 200 250 300 350 400 450
time, sec.
191
Homework 20
1. (a) Express the following differential equation with input u(t) in state variable format:
2 + 24 + 88 + 96 = 48(0 ) = 2 (0 ) = 1 (0 ) = 0
(b) What is the DC gain of this differential equation?
(c) What are the initial conditions for the state variables?
(d) Express the state variable equations in (a) in matrix format assuming ()is the output of
interest, i.e.
= + = +
(e) Use the MATLAB command eig to get the eigenvalues of this differential equation.
(f) Enter the system found in (d) into MATLAB as a state space system and use the command
damp to get the damping ratio and natural frequency. Use the command dcgain to confirm
the answer to part (b).
(g) Use the command lsim to get a plot of the output of interest assuming u(t) is a step with
magnitude 10. Note, considering your value for the DC gain and the fact that the input is a
constant, what should be the final value of w(t)?
(h) Find the Laplace transform () and use the pretend transfer function concept with the
impulse command to get a plot of (). Plot on the same graph as the answer to part (g) for
comparison. Be sure to label the axes and insert a legend on the graph.
2. The equations for a vehicle suspension are shown below. The input is the displacement u(t). The
output of interest is y = v u. Express the equations for this system in state variable format, i.e.
= + = +
Mw bw kw bv kv w
M
mv 2bv 2kv bw kw bu ku
k b
v
m
k b
192
Homework 20 Solution
1. (a) Express the following differential equation with input u(t) in state variable format:
+ 24 + 88 + 96 = 48(0 ) = 2 (0 ) = 1 (0 ) = 0
2
1 = 2 = 3 =
1 = 2 2 = 3 3 = 24 481 442 123
>> homework4sol
193
EVS =
-2
-4
-6
DCgain = 0.5
comparing lsim plot with inverse Laplace plot
5
4.5
3.5
w
2.5
using lsim
using impulse for inverse Laplace
2
0 0.5 1 1.5 2 2.5
time, sec
2. The equations for a vehicle suspension are shown below. The input is the displacement u(t).
The output of interest is y = v u. Express the equations for this system in state variable format,
i.e.
= + = +
194
Mw bw kw bv kv w
M
mv 2bv 2kv bw kw bu ku
k b
v
m
k b
1 = 2 = 3 = 4 =
0
0 1 0 0 2
= = = [0010] = [1]
0 0 0 1
2 2
[ ] 2 2
[ 2 ]
Homework 21
The equations for a vehicle suspension are shown below. The input is the displacement u(t). The output
of interest is / where g is gravity, 9.8 m/s2. Express the equations for this system in state variable
format in terms of M, b, k, etc.
= + = +
Mw bw kw bv kv w
mv (b c)v (k K )v bw kw cu Ku M
k b
v
m
K c
195
(1) Create a new m-file for this problem. The first statements are to assign values to the design
parameters, i.e. = 36000 = 100000 = 8400 = 10000
= 1000 = 250
(2) The next statements define the state variable matrices in terms of M, b, k, etc.
1 = 2 = 3 = 4 = =
= 1 2 + 3 + 4 +
(3) Use the ss command to create a state space system.
(4) Use the damp command to get the eigenvalues and damping ratio(s) of the system.
(5) Use the dcgain command to get the DC gain.
Does this value make sense?
(6) Use the step command to get and plot the step response of the system.
(7) Use the max command to find the maximum value of y.
(8) Try a few different values for c and observe the difference in the maximum value of y.
Comment on the significance of the choice of c in regard to ride comfort.
Homework 21 Solution
The equations for a vehicle suspension are shown below. The input is the displacement u(t).
The output of interest is / where g is gravity, 9.8 m/s2. Express the equations for this system
in state variable format in terms of M, b, k, etc.
= + = +
Mw bw kw bv kv w
mv (b c)v (k K )v bw kw cu Ku M
k b
v
m
K c
(1) Create a new m-file for this problem. The first statements are to assign values to the design
parameters, i.e. = 36000 = 100000 = 8400 = 10000
= 1000 = 250
196
Eigenvalue Damping Frequency
-2.60e+00 + 4.77e+00i 4.78e-01 5.43e+00
-2.60e+00 - 4.77e+00i 4.78e-01 5.43e+00
-6.98e+00
-6.98e+01
(6) Use the dcgain command to get the DC gain. DC gain = 7.1054e-15
Does this value make sense? Yes, because the output of interest is normalized acceleration
and for a constant input, the acceleration eventually goes to zero. Output = DC gain*input =0
(7) Use the step command to get and plot the step response of the system.
(8) Use the max command to find the maximum value of y. For c=10000, the maximum
acceleration is 34.286 gs which would be totally unacceptable. This high value is caused by the
in the differential equations which is an impulse if u is a step. Think about it; if you are moving
forward in your car at a significant speed and hit a curb, the force would probably be great
enough to knock the front axle and suspension off! For realist inputs (not pure steps), you
would like to keep the peak accelerations under about 0.1 g.
(9) Try a few different values for c and observe the difference in the maximum value of y.
Comment on the significance of the choice of c in regard to ride comfort. See m-fle and graph.
197
plot(t,y2,'k',t,y1,'r-.',t,y3,'k:','LineWidth',2)
title('comparing peak accelerations for various damping coefficients c for step inputs')
xlabel('time, sec')
ylabel('normalized acceleration w"/g')
legend('c=7500 Ns/m','c=10000 Ns/m','c=12500 Ns/m','Location','Best')
comparing peak accelerations for various damping coefficients c for step inputs
45
40
35
normalized acceleration w"/g
30
c=7500 Ns/m
c=10000 Ns/m
25
c=12500 Ns/m
20
15
10
-5
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
time, sec
Homework 22
The schematic for an impact barrier for a car is shown below. Typically, these barriers are
constructed of components that collapse storing and dissipating energy. For example, partially
filled barrels of water; on impact, air in the barrels softens the impact by storing energy while the
water being forced out of the crushed barrels dissipates energy. The objective is to stop a car
with as small of a maximum deceleration as possible but yet not let the barrier totally collapse.
Once a barrier totally collapses, it is equivalent to hitting an immoveable object. As shown in
the schematic, the maximum this barrier can collapse is distance D.
D
+ + = 0(0 ) = 0 (0 ) =
Specifically, determine the best damping coefficient b for the barrier assuming K=2000 N/m for
the worse case scenario of the car mass M=1000 kg with an impact speed of Vo=24 m/s; The
maximum value of the deceleration, (), should not be greater than 4.0 gs with a maximum
collapse distance D = 10m . Note, use g=9.8 m/s2.
(1) Formulate a state variable model for an ode45 simulation
(2) Your first simulation should generate plots of y and using b = 0. This will be one of the
worst possible values but will give you insight regarding the total time needed for the
simulation. Be sure to stop the simulation when first becomes negative because this
means the car and bumper have stopped moving forward and the car is bouncing back off
of the bumper; the differential equation is not a valid model after this happens.
(3) By trial and error, determine a value for b that meets the design specifications. Show
plots of for at least three values of b: your best value, a value greater, and a value
smaller. Be sure to label and include a legend on all plots.
Homework 22 Solution
The schematic for an impact barrier for a car is shown below. Typically, these barriers are
constructed of components that collapse storing and dissipating energy. For example, partially
filled barrels of water; on impact, air in the barrels softens the impact by storing energy while the
water being forced out of the crushed barrels dissipates energy. The objective is to stop a car
with as small of a maximum deceleration as possible but yet not let the barrier totally collapse.
Once a barrier totally collapses, it is equivalent to hitting an immoveable object. As shown in
the schematic, the maximum this barrier can collapse is distance D.
199
The objective of this homework problem is to perform a series of ode45 simulations for different
values of viscous damping b to determine a value that gives the lowest possible maximum value
of deceleration without the displacement being greater than D. See section 3.6 in the notebook.
Assuming that the car has just contacted the yellow bumper with initial velocity Vo, the
differential equation for the forward displacement y of the car and bumper is as follows:
+ + = 0(0 ) = 0 (0 ) =
Specifically, determine the best damping coefficient b for the barrier assuming K=2000 N/m for
the worse case scenario of the car mass M=1000 kg with an impact speed of Vo=24 m/s; The
maximum value of the deceleration, (), should not be greater than 4.0 gs with a maximum
collapse distance D = 10m . Note, use g=9.8 m/s2.
(1) Formulate a state variable model for an ode45 simulation
1 2
1 = 2 = 1 = 2 2 = 1 (0 ) = 02 (0 ) = 24
(2) Your first simulation should generate plots of y and / using b = 0. This will be one of
the worst possible values but will give you insight regarding the total time needed for the
simulation. Be sure to stop the simulation when first becomes negative because this
means the car and bumper have stopped moving forward and the car is bouncing back off
of the bumper; the differential equation is not a valid model after this happens.
%Homework 6, MAE3360 11-19-13
%Car crash barrier design
global M K b D
D=10;M=1000;Vo=24;K=2000;g=9.8;
options=odeset('events',@Stop_3360_111913);
dr=0;b=2*dr*sqrt(K*M);
[t,x]=ode45(@Hmwk7Eqns_3360_111913,[0 3],[0 Vo],options);
plot(t,x(:,1),'k','LineWidth',2)
xlabel('time, sec.')
ylabel('car displacement, m')
title('barrier performance with zero damping')
figure
plot(t,x(:,2),'k','LineWidth',2)
xlabel('time, sec.')
ylabel('car velocity, m')
title('barrier performance with zero damping')
figure
A=-K*x(:,1)/M-b*x(:,2)/M;
plot(t,A,'k','LineWidth',2)
xlabel('time, sec.')
ylabel('car deceleration, g')
title('barrier performance with zero damping')
200
dx(2)=-K*x(1)/M-b*x(2)/M;
end
10
8
car displacement, m
0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45
time, sec.
23.5
23
22.5
car velocity, m/s
22
21.5
21
20.5
20
19.5
19
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45
time, sec.
201
barrier performance with zero damping
0
car deceleration, g -5
-10
-15
-20
-25
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45
time, sec.
From these three plots above, we see that with zero damping, the car hits the end of
barrier in about 0.45 sec still moving at 19.5 m/s. Also, without considering the extra
impact deceleration associated with hitting the end of the barrier, the deceleration has still
exceeded 20 gs.
(3) By trial and error, determine a value for b that meets the design specifications. Show
plots of for at least three values of b: your best value, a value greater, and a value
smaller. Be sure to label and include a legend on all plots.
%Homework 6, MAE3360 11-19-13
%Car crash barrier design
clear all
global M K b D
D=10;M=1000;Vo=24;K=2000;g=9.8;
options=odeset('events',@Stop_3360_111913);
dr=0.5;b=2*dr*sqrt(K*M);
[t,x5]=ode45(@Hmwk7Eqns_3360_111913,[0 2],[0 Vo],options);
dr=0.45;b=2*dr*sqrt(K*M);
[t,x45]=ode45(@Hmwk7Eqns_3360_111913,[t],[0 Vo],options);% Using previous time array so can plot on
same graph
dr=0.4;b=2*dr*sqrt(K*M);
[t,x4]=ode45(@Hmwk7Eqns_3360_111913,[t],[0 Vo],options);
plot(t,x4(:,1),'r',t,x45(:,1),'k:',t,x5(:,1),'r-.','LineWidth',2)
xlabel('time, sec.')
ylabel('car displacement, m')
title('homework 6 MAE 3360 Nov. 19, 2013')
legend('damping ratio =0.4','damping ratio=0.45','damping ratio=0.5','Location','Best')
figure
plot(t,x4(:,2),'r',t,x45(:,2),'k:',t,x5(:,2),'r-.','LineWidth',2)
xlabel('time, sec.')
ylabel('car velocity, m/sec')
title('homework 6 MAE 3360 Nov. 19, 2013')
legend('damping ratio =0.4','damping ratio=0.45','damping ratio=0.5','Location','Best')
figure
A4=-K*x4(:,1)/M-b*x4(:,2)/M;
A45=-K*x45(:,1)/M-b*x45(:,2)/M;
202
A5=-K*x5(:,1)/M-b*x5(:,2)/M;
plot(t,A4/g,'r',t,A45/g,'k:',t,A5/g,'r-.','LineWidth',2)
xlabel('time, sec.')
ylabel('car deceleration, g')
title('homework 6 MAE 3360 Nov. 19, 2013')
legend('damping ratio =0.4','damping ratio=0.45','damping ratio=0.5','Location','Best')
Examining the three graphs below, a damping ratio of 0.45 ( b=1273 Ns/m) keeps the displacement just under D
and limits the deceleration to slightly under 2 gs.
10
8
car displacement, m
6
damping ratio =0.4
damping ratio=0.45
4 damping ratio=0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
time, sec.
203
homework 6 MAE 3360 Nov. 19, 2013
25
damping ratio =0.4
damping ratio=0.45
20 damping ratio=0.5
15
car velocity, m/sec
10
-5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
time, sec.
-2
car deceleration, g
-2.2
-2.4
-2.6
-2.8
-3
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
time, sec.
Note, using the events function to end the simulation will cause problems if
you intend to put more than one plot on a graph unless you make sure the
simulation using the shortest time is run first and t from the previous run is
used in place of [start time final time]. See attached m-files.
204
Homework 23
Two systems with the corresponding differential equations are shown below.
1. The first is a forward moving vehicle and suspension system. At time t = 0, the wheel hits a
bump defined by the surface roughness u(t). (a) What is the dependent variable? (b) What is
the input variable? (3) What is the order of the differential equation? (4) How many initial
conditions are required to solve the equation? What are the initial conditions? (5) Is the
equation linear or nonlinear? (6) Sketch a reasonable estimate of z(t) following the bump which
occurs at t = 0.
2. The second is water draining from a water tank where H is the height of the water. (1) What is
the dependent variable? (2) What is the order of the differential equation? (3) Is the equation
linear or nonlinear? (4) Since there is no input variable, there must be nonzero initial conditions
otherwise there is no solution. What are the initial conditions? (5) Considering the initial
conditions, draw a reasonable estimate of the height of the water H(t) starting at t = 0.
Vehicle
forward
motion
flow out
of tank
u
10 H 0.2 H 0 H (0 ) 5
z(t)
H(t)
0 time time
0
3. For systems with zero initial conditions, the D operator can be used to convert the differential
equation to an algebraic equation. Do this for the first system.
205
Homework 23 Solution
Two systems with the corresponding differential equations are shown below.
1. The first is a forward moving vehicle and suspension system. At time t = 0, the wheel hits a
bump defined by the surface roughness u(t). (a) What is the dependent variable? Z
(b) What is the input variable? U
(c) What is the order of the differential equation? 2
(d) How many initial conditions are required to solve the equation? 2
What are the initial conditions? (0 ) = 0, (0 ) = 0, (0 ).
(e) Is the equation linear or nonlinear? Linear
(f) Sketch a reasonable estimate of z(t) following the bump which occurs at t = 0.
2. The second is water draining from a water tank where H is the height of the water. (a) What is
the dependent variable? H(b) What is the order of the differential equation? 1(c) Is the equation
linear or nonlinear? Linear(d) Since there is no input variable, there must be nonzero initial
conditions otherwise there is no solution. What are the initial conditions?5 (e) Considering the
initial conditions, draw a reasonable estimate of the height of the water H(t) starting at t = 0.
Vehicle
forward
motion
flow out
of tank
u
10 H 0.2 H 0 H (0 ) 5
z(t) 5
H(t)
3. For systems with zero initial conditions, the D operator can be used to convert the differential
equation to an algebraic equation. Do this for the first system.
(1002 + 1000 + 10000) = (1000 + 10000)
206
Homework 24
Two systems with the corresponding differential equations are shown below.
1. The first is a forward moving vehicle and suspension system. At time t = 0, the wheel hits a
bump defined by the surface roughness u(t).
(a) What is the transfer function for z?
(b) What is the characteristic polynomial for this suspension system?
(c) Manually factor, using the quadratic equation, the characteristic polynomial to compute the
eigenvalues.
(d) Use the root command in MATLAB to get the eigenvalues.
(e) Use the tf command in MATLAB to enter the transfer function; note, MATLAB will express
the answer in terms of s instead of D.
(f) Use the damp command to get the eigenvalues of this transfer function. What is the
damping ratio? What is the undamped natural frequency? What is the damped natural
frequency? What is the time constant of this system?
(g) After hitting a bump, how long will it take for the vibration to settle out within 1%?
(h) The original equations used to model this suspension consist of an equation for each
component, i.e.
= 10000( )
= 1000( )
: 100 + + = 0
Convert the 2nd and 3rd equations to algebraic equations using the D operator. Re-write these
algebraic equations in terms of s instead of D; in symbolic math, the use of D probably will
not work for representing algebraic equations since the use of D implies taking the derivative.
Then, use the symbolic math command solve in MATLAB to solve for z; the answer should be
the transfer function times u.
2. The second is water draining from a water tank where H is the height of the water. It can be
shown that the solution to this differential equation is
() = 5 0.02
Create and execute an m-file with the following MATLAB commands to generate a plot of H(t).
clear all
t=0:1:250;
H=5*exp(-0.02*t);
plot(t,H,'r','LineWidth',2)
title('Homework 2: Draining a water tank')
xlabel('Time, sec.')
ylabel('Height of water, m')
207
Copy and paste your m-file and plot to a Word document to include with your solution to this
homework assignment.
z
Vehicle
forward
motion
flow out
of tank
u
10 H 0.2 H 0 H (0 ) 5
Homework 24 Solution
Two systems with the corresponding differential equations are shown below.
1. The first is a forward moving vehicle and suspension system. At time t = 0, the wheel hits a
bump defined by the surface roughness u(t).
(a) What is the transfer function for z?
1000 + 10000
[ ]
100 2 + 1000 + 10000
(b) What is the characteristic polynomial for this suspension system? 100 2 + 1000 + 10000
(c) Manually factor, using the quadratic equation, the characteristic polynomial to compute the
eigenvalues. = 5 75 = 5 8.6603
(d) Use the roots command in MATLAB to get the eigenvalues.
>> roots([100 1000 10000])
ans =
-5.0000 + 8.6603i
-5.0000 - 8.6603i
(e) Use the tf command in MATLAB to enter the transfer function; note, MATLAB will express
the answer in terms of s instead of D.
>> G=tf([1000 10000],[100 1000 10000])
208
G=
1000 s + 10000
------------------------
100 s^2 + 1000 s + 10000
Continuous-time transfer function.
(f) Use the damp command to get the eigenvalues of this transfer function.
>> damp(G)
Pole Damping Frequency Time Constant
(rad/seconds) (seconds)
(g) After hitting a bump, how long will it take for the vibration to settle out within 1%? 1 sec.
(h) The original equations used to model this suspension consist of an equation for each
component, i.e.
= 10000( )
= 1000( )
: 100 + + = 0
Convert the 2nd and 3rd equations to algebraic equations using the D operator. Re-write these
algebraic equations in terms of s instead of D; in symbolic math, the use of D probably will
not work for representing algebraic equations since the use of D implies taking the derivative.
Then, use the symbolic math command solve in MATLAB to solve for z; the answer should be
the transfer function times u. Note, to understand what collect and pretty do, type just H.z.
>> syms s u
>> H=solve('Fs=10000*(z-u)','Fd=1000*s*(z-u)','100*s^2*z+Fs+Fd=0','Fs,Fd,z');
>> Z=collect(H.z,u);
>> pretty(Z)
10(+10)
2 +10+100
The second system is water draining from a water tank where H is the
height of the water. It can be shown that the solution to this differential equation is
() = 5 0.02
Create and execute an m-file with the following MATLAB commands to generate a plot of H(t).
clear all
209
t=0:1:250;
H=5*exp(-0.02*t);
plot(t,H,'r','LineWidth',2)
title('Homework 2: Draining a water tank')
xlabel('Time, sec.')
ylabel('Height of water, m')
Copy and paste your m-file and plot to a Word document to include with your solution to this
homework assignment.
4.5
3.5
Height of water, m
2.5
1.5
0.5
0
0 50 100 150 200 250
Time, sec.
210
Homework 25
A sliding block system is shown below. A spring connects a swinging bar to the block. A force f
is the input to the system. The differential equations that model the motion of this system
resulting from a certain input f are also given below.
y
y 100 y 50 0.1 f
64 75 y 0
f
Homework 25 Solution
A sliding block system is shown below. A spring connects a swinging bar to the block. A force f
is the input to the system. The differential equations that model the motion of this system
resulting from a certain input f are also given below.
y
y 100 y 50 0.1 f
64 75 y 0
f
211
(a) What are the unknowns?
(b) What is the order of each differential equation? 2
(c) Are the equations linear? yes
(d) Use the D operator to convert the equations to algebraic equations.
( + ) = .
( + ) =
(e) Manually solve for y by eliminating .
From 2nd equations: = +
Into 1st equation gives: ( + ) + = .
.( +)
Or = + +
.( +)
(f) What is the transfer function for y?
+ +
(g) Repeat (e) but this time use symbolic math and the solve command.
syms s f
H=solve('(s^2+100)*y-50*T=0.1*f','(s^2+64)*T-75*y=0','T,y');
A=H.y/f;
pretty(A)
S4 + 164.0 s2 + 2650.0
ans =
0.0000 +12.0759i
0.0000 -12.0759i
-0.0000 + 4.2629i
-0.0000 - 4.2629i
(j) Explain why this system does not have time constants. The time constants are infinity since
the real parts of the eigenvalues are zero.
212
(k) What are the modes of this system? Use the MATLAB command pfract.
>> pfract([1 0 64],[1 0 164 0 2650])
0.641
Second Mode: ------------------
s^2 + 145.8
0.359
First Mode: -------------------------
s^2 + 18.17
Note, I have removed the small terms that should be zero but arent because of round-off
errors.
(l) Suppose the force f is a single blow with a hammer. Describe the motion of the system at each
mode?
During the first mode, the mass and bar are moving exactly in phase. During the second
mode, the movement of the mass and bar are exactly 180 degrees out of phase. The motion
transitions back and forth between the modes.
Homework 26
Use the Laplace transform to solve each of the following differential equations for v(t); show all
of your steps in getting the solution. Note, before solving for each v(t), draw a sketch of your
estimate of v(t). For each case, use the FVT and the IVT to check your V(s) before finding the
inverse Laplace transform. Then, once you get each v(t), check the solution at t=0 and t= to
confirm your answer.s=-3+j
(1) + 12 + 20 = 0(0 ) = 10 (0 ) = 0
(2) + 12 + 20 = 100(0 ) = 10 (0 ) = 0
(3) 2 + 12 + 20 = 0(0 ) = 10 (0 ) = 0
(4) 2 + 12 + 20 = 100(0 ) = 10 (0 ) = 0
213
Homework 26 Solution
Use the Laplace transform to solve each of the following differential equations for v(t); show all
of your steps in getting the solution. Note, before solving for each v(t), draw a sketch of your
estimate of v(t). For each case, use the FVT and the IVT to check your V(s) before finding the
inverse Laplace transform. Then, once you get each v(t), check the solution at t=0 and t= to
confirm your answer.
Note, all of the Laplace transforms below confirm the initial and final values. Also, all of
the inverse Laplace transforms confirm the initial and final values.
(1) + + = ( ) = ( ) =
10 + 120 100 2 20 10
() = () =
( + 2)( + 10) 8 8
(2) + + = ( ) = ( ) =
10 2 + 120 + 100 50 2 10 10
() = () = 5 +
( + 2)( + 10) 8 8
(3) + + = ( ) = ( ) =
10 + 60
() =
( + 3)2 + 12
3
() = |10 + 60|=3+ sin(1 + (10 + 60)=3+ )
1
(4) + + = ( ) = ( ) =
10 2 + 60 + 50
() =
[( + 3)2 + 11 ]
3 10 2 + 60 + 50 10 2 + 60 + 50
() = 5 0 + | | sin(1 + ( ) )
1 =3+
=3+
214
Homework 27
The solutions to the following differential equations were obtained in Homework 4. For
Homework 5, you are to use the MATLAB command impulse to get plots of the solutions to
the same equations. In each case, plot the analytical solution on the same graph to confirm they
are identical.
(1) + 12 + 20 = 0(0 ) = 10 (0 ) = 0
(2) + 12 + 20 = 100(0 ) = 10 (0 ) = 0
(3) 2 + 12 + 20 = 0(0 ) = 10 (0 ) = 0
(4) 2 + 12 + 20 = 100(0 ) = 10 (0 ) = 0
Homework 27 Solution
Use the Laplace transform to solve each of the following differential equations for v(t); show all
of your steps in getting the solution. Note, before solving for each v(t), draw a sketch of your
estimate of v(t). For each case, use the FVT and the IVT to check your V(s) before finding the
inverse Laplace transform. Then, once you get each v(t), check the solution at t=0 and t= to
confirm your answer.
Note, all of the Laplace transforms below confirm the initial and final values. Also, all of
the inverse Laplace transforms confirm the initial and final values.
(1) + + = ( ) = ( ) =
10 + 120 100 2 20 10
() = () =
( + 2)( + 10) 8 8
10
using inverse Laplace
9 using impulse command
6
v(t)
0
0 0.5 1 1.5 2 2.5 3
time, sec.
215
(2) + + = ( ) = ( ) =
10 2 + 120 + 100 50 2 10 10
() = () = 5 +
( + 2)( + 10) 8 8
11
using inverse Laplace
using impulse command
10
9
v(t)
5
0 0.5 1 1.5 2 2.5 3
time, sec.
(3) + + = ( ) = ( ) =
10 + 60
() =
( + 3)2 + 12
3
() = |10 + 60|=3+ sin(1 + (10 + 60)=3+ )
1
() = 31.62 3 sin( + 0.32175)
10
using inverse Laplace
9 using impulse command
6
v(t)
0
0 0.5 1 1.5 2 2.5
time, sec.
216
(4) + + = ( ) = ( ) =
10 2 + 60 + 50
() =
[( + 3)2 + 11 ]
3 10 2 + 60 + 50 10 2 + 60 + 50
() = 5 0 + | | sin(1 + ( ) )
1 =3+
=3+
() = 5 + 15.811 3 sin( + 0.3218)
11
using inverse Laplace
using impulse command
10
9
v(t)
5
0 0.5 1 1.5 2 2.5
time, sec.
clear all
G=tf([10 120],[1 12 20]);
[V,t]=impulse(G);
v=100*exp(-2*t)/8-20*exp(-10*t)/8;
plot(t,v,'r',t,V,'k.','LineWidth',2)
xlabel('time, sec.')
ylabel('v(t)')
legend('using inverse Laplace','using impulse command')
figure
clear all
G=tf([10 120 100],[1 12 20 0]);
[V,t]=impulse(G);
v=5+50*exp(-2*t)/8-10*exp(-10*t)/8;
plot(t,v,'r',t,V,'k.','LineWidth',2)
xlabel('time, sec.')
ylabel('v(t)')
legend('using inverse Laplace','using impulse command')
figure
clear all
G=tf([10 60],[1 6 10]);
[V,t]=impulse(G);
v=31.62*exp(-3*t).*sin(t+0.32175);
plot(t,v,'r',t,V,'k.','LineWidth',2)
xlabel('time, sec.')
ylabel('v(t)')
legend('using inverse Laplace','using impulse command')
figure
clear all
G=tf([10 60 50],[1 6 10 0]);
[V,t]=impulse(G);
v=5+15.81*exp(-3*t).*sin(t+0.3218);
plot(t,v,'r',t,V,'k.','LineWidth',2)
xlabel('time, sec.')
ylabel('v(t)')
legend('using inverse Laplace','using impulse command')
217
Homework 28
A pile driver is used to drive the pile shown below into the ground. This is a study to determine
the significance of the pounding frequency of input force Fi on the amplitude of the force at the
ground Fg. The total mass of the pile is M=15,000 Kg. The stiffness of the pile is K=AE/L =
1.5e8 N/m where the pile length is L=15 m. Although a 5 or more lumped mass would be
preferred for the study, for simplicity, only 3 lumped masses was used. b = 50,000 Ns/m for the
viscous damping coefficient.
Fi
M/3
3K b
M/3
L M
K 3K b
AE
M/3
3K b
Fg
For the three-lumped mass model, it can be shown that the transfer function relating the ground
force Fg to the input pounding force Fi is as follows:
Note, the total ground force will include the constant weight of the beam but we are only
considering the additional force due to the pounding.
(1) What is the DC gain of this transfer function? What does this mean?
(2) What are the eigenvalues of this transfer function? What are the resonant frequencies of the
beam (damped natural frequencies)?
(3) Use the MATLAB command bode to determine the magnitudes of this transfer function at the
resonant frequencies. Which resonant frequency produces the greatest transfer function
magnitude? What is this magnitude (convert it from dB)?
(4) If the input force is () = 1 sin(1 ) 1 , we
know that Fg(t) will become a sine wave at the same frequency. What will be the amplitude of
the Fg sine wave?
218
Homework 28 Solution
A pile driver is used to drive the pile shown below into the ground. This is a study to determine
the significance of the pounding frequency of input force Fi on the amplitude of the force at the
ground Fg. The total mass of the pile is M=15,000 Kg. The stiffness of the pile is K=AE/L =
1.5e8 N/m where the pile length is L=15 m. Although a 5 or more lumped mass would be
preferred for the study, for simplicity, only 3 lumped masses was used. b = 50,000 Ns/m for the
viscous damping coefficient.
Fi
M/3
3K b
M/3
L M
K 3K b
AE
M/3
3K b
Fg
For the three-lumped mass model, it can be shown that the transfer function relating the ground
force Fg to the input pounding force Fi is as follows:
Note, the total ground force will include the constant weight of the beam but we are only
considering the additional force due to the pounding.
(1) What is the DC gain of this transfer function? What does this mean?
DC gain = 1 This means if Fi is a constant C, then the final value of Fi will also be a constant
equal to DC gain*C = C.
(2) What are the eigenvalues of this transfer function? What are the resonant frequencies of the
beam (damped natural frequencies)? Resonant frequencies = 134, 374, and 540 rad/sec.
Pole Damping Frequency Time Constant
(rad/seconds) (seconds)
219
(3) Use the MATLAB command bode to determine the magnitudes of this transfer function at the
resonant frequencies. 37.8 dB (77.6), 16.5 dB (6.7), and 0.0868 dB (1.01). Which resonant
frequency produces the greatest transfer function magnitude? 134 rad/sec.
What is this magnitude (convert it from dB)? The amplitude of Fg will be 77.6 times greater
than the amplitude of Fi.
Bode Diagram
40
System: G
30 Frequency (rad/s): 134
Magnitude (dB): 37.8
20
System: G
10 System: G Frequency (rad/s): 535
Frequency (rad/s): 374 Magnitude (dB): 0.0868
Magnitude (dB)
-10
-20
-30
-40
-50
-60
0
-180
Phase (deg)
-360
-540
2 3
10 10
Frequency (rad/s)
Homework 29
An impact barrier for a car is shown below. The objective is to stop a car with as small of a
maximum deceleration as possible but yet not let the barrier totally collapse; as shown, the
maximum the barrier can collapse is distance D. The specific design process is to select a
spring constant K and damping coefficient b for the barrier for the worse-case scenario of
M=1000 kg car with an impact speed of Vo=24 m/s; The maximum deceleration should not
exceed -4.0 gs with a maximum collapse distance D = 10m .
D
220
The differential equation for the displacement z of the car is given below
+ + =
Assume t = 0 at the instant the car contacts the yellow bumper and at this instant,
( ) = and ( ) = /.
(a) Express the differential equation in matrix state variable format. Note, every
matrix term in will be zero since there is no input (u=0).
We have two outputs-of-interest, i.e. = = .
? ?
[ ] = [ ] [ ] + [ ]
? ?
? ?
[ ] = [ ] [ ] + [ ]
? ?
(b) Assume K = 2131 N/m and b = 1139Ns/m. Use MATLAB with your state variable
equations and the command initial to get plots of () (). Do these values
for K and b satisfy the design specification? Note, once the barrier stops the
forward motion of the car, the car will bounce back. The differential equation is not
valid once the bounce back is initiated.
Homework 29 Solution
An impact barrier for a car is shown below. The objective is to stop a car with as small of a
maximum deceleration as possible but yet not let the barrier totally collapse; as shown, the
maximum the barrier can collapse is distance D. The specific design process is to select a
spring constant K and damping coefficient b for the barrier for the worse-case scenario of
M=1000 kg car with an impact speed of Vo=24 m/s; The maximum deceleration should not
exceed -4.0 gs with a maximum collapse distance D = 10m .
D
The differential equation for the displacement z of the car is given below
+ + =
Assume t = 0 at the instant the car contacts the yellow bumper and at this instant,
221
( ) = and ( ) = /.
(a) Express the differential equation in matrix state variable format. Note, every
matrix term in will be zero since there is no input (u=0).
We have two outputs-of-interest, i.e. = = .
[ ]=[ ] [ ] + [ ]
. .
[ ] = [. . ] [ ] + []
. .
Note, y2 has been divided by 9.8 to normalized the deceleration by gravity to get gs.
(b) Assume K = 2131 N/m and b = 1139Ns/m. Use MATLAB with your state variable
equations and the command initial to get plots of () (). Do these values
for K and b satisfy the design specification? Note, once the barrier stops the
forward motion of the car, the car will bounce back. The differential equation is not
valid once the bounce back is initiated.
clear all
format shortg
A=[0 1;-2131/1000 -1139/1000];B=[0;0];
C=[1 0;-(2131/1000)/9.8 -(1139/1000)/9.8];D=[0;0];
G=ss(A,B,C,D);
[Y,t]=initial(G,[0;24],1);
plot(t,Y(:,1),'k','LineWidth',2)
xlabel('time, sec.')
ylabel('z, m')
title('displacement of car into barrier')
figure
plot(t,Y(:,2),'k','LineWidth',2)
xlabel('time, sec.')
ylabel('deceleration, g')
title('deceleration of car after hitting barrier')
222
displacement of car into barrier
12
10
8
z, m
0
0 0.2 0.4 0.6 0.8 1
time, sec.
-2
-2.2
deceleration, g
-2.4
-2.6
-2.8
-3
-3.2
0 0.2 0.4 0.6 0.8 1
time, sec.
223
Homework 30
An impact barrier for a car is shown below. When the car contacts the gray bumper, the
yellow piston starts moving forward compressing the fluid in the cylinder due to the
movement of the piston to the left. Also, the rise in pressure forces the fluid through the
orifice represented by flow rate Q out of the cylinder. Hopefully, the barrier will stop a car
with an initial impact speed of 24 m/s without the deceleration exceeding 5 gs and without
total barrier collapse corresponding to y = 10 m. To decrease the g levels of deceleration, a
rubber ball or balloon filled with air has been placed in the water in the cylinder to
increase the compressibility of the fluid in the cylinder.
The equations for the displacement y of the piston and car, for the pressure P in the
cylinder, and for the flow rate Q m3/s are as follows:
+ ( ) = ( ) = ( ) = /
( ) = ( )(. )( ) = /
= (. )|| ()
In the equation for Q, sign(P) is a programming command that produces +1 if P>0 and -1
if P<0. Thus, Q can be positive or negative without calculating the square root of negative
numbers.
Note, if you have any MATLAB questions regarding this assignment, please consult
only with Professor Hullender.
224
Homework 30 Solution
An impact barrier for a car is shown below. When the car contacts the gray bumper, the
yellow piston starts moving forward compressing the fluid in the cylinder due to the
movement of the piston to the left. Also, the rise in pressure forces the fluid through the
orifice represented by flow rate Q out of the cylinder. Hopefully, the barrier will stop a car
with an initial impact speed of 24 m/s without the deceleration exceeding 5 gs and without
total barrier collapse corresponding to y = 10 m. To decrease the g levels of deceleration, a
rubber ball or balloon filled with air has been placed in the water in the cylinder to
increase the compressibility of the fluid in the cylinder.
The equations for the displacement y of the piston and car, for the pressure P in the
cylinder, and for the flow rate Q m3/s are as follows:
+ ( ) = ( ) = ( ) = /
( ) = ( )(. )( ) = /
= (. )|| ()
In the equation for Q, sign(P) is a programming command that produces +1 if P>0 and -1
if P<0. Thus, Q can be positive or negative without calculating the square root of negative
numbers.
function dx=barrier3360(t,x)
y=x(1);yd=x(2);P=x(3);%allows writing equations in terms of y, yd, and P
dx=zeros(3,1);
dx(1)=x(2);
dx(2)=-(5e-5)*P;
Q=(8.9e-4)*sqrt(abs(P))*sign(P);
dx(3)=2e8*(.05*yd-Q)/(10-y);
end
function[Val,Ister,Dir]=StopSim8(t,x)
Val(1)=x(1)-10;Ister(1)=1;Dir(1)=0;%stops simulation if y=10
Val(2)=x(2);Ister(2)=1;Dir(2)=0;%stops simulation if velocity=0
end
20
displacement, m
velocity, m/s
outputs of interest
deceleration/g
15
10
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
time, sec.
226
Homework 31
Homework 30 pertained to the simulation of the dynamics of a car impacting a crash barrier composed of a
piston and cylinder filled with water with a hole (orifice) for water to escape from the cylinder. Flow through
the orifice provides energy dissipation. The solution to the equations revealed that the design of the barrier
was ineffective at preventing a car from collapsing the barrier even though the peak deceleration was only
slightly greater than 5 gs.
This assignment pertains to the simulation of the same barrier but this time with a series of holes staggered
along the top of the cylinder as shown in the figure below.
The equations for the displacement y of the piston and car, for the pressure P in the cylinder, and for the flow
rate Q m3/s are as follows:
+ ( ) = ( ) = ( ) = /
( ) = ( )(. )( ) = /
= (. )|| ()
where the MATLAB equations for n, the number of holes, in relation to the hole locations a, b, and c are as
follows:
a=?; b=?;c=?;
n=4;
if y>a; n=3; end;
if y>b; n=2; end;
if y>c; n=1; end;
These equations should be inserted in your m-file prior to the new equation for Q. See the m-file listings on
the solution to Homework 8. You are to modify your simulation equations for Homework 8 to include the
staggered holes and experiment with different values of a, b, and c in an attempt to prevent y from exceeding
10 m before becomes zero and without the deceleration exceeding a peak value of 5 gs.
Show a plot with (), (), ()/ corresponding to your best design values for a, b, and c. Does your
design meet the specifications?
227
Homework 31 Solution
Homework 8 pertained to the simulation of the dynamics of a car impacting a crash barrier composed of a
piston and cylinder filled with water with a hole (orifice) for water to escape from the cylinder. Flow through
the orifice provides energy dissipation. The solution to the equations revealed that the design of the barrier
was ineffective at preventing a car from collapsing the barrier even though the peak deceleration was only
slightly greater than 5 gs.
This assignment pertains to the simulation of the same barrier but this time with a series of holes staggered
along the top of the cylinder as shown in the figure below.
The equations for the displacement y of the piston and car, for the pressure P in the cylinder, and for the flow
rate Q m3/s are as follows:
+ ( ) = ( ) = ( ) = /
( ) = ( )(. )( ) = /
= (. )|| ()
where the MATLAB equations for n, the number of holes, in relation to the hole locations a, b, and c are as
follows:
a=?;b=?;c=?;
n=4;
if y>a; n=3; end;
if y>b; n=2; end;
if y>c; n=1; end;
These equations should be inserted in your m-file prior to the new equation for Q. See the m-file listings on
the solution to Homework 8. You are to modify your simulation equations for Homework 8 to include the
staggered holes and experiment with different values of a, b, and c in an attempt to prevent y from exceeding
10 m before becomes zero and without the deceleration exceeding a peak value of 5 gs.
Show a plot with (), (), ()/ corresponding to your best design values for a, b, and c. Does your
design meet the specifications? The design meet specifications as shown below.
clear all
format shortg
options=odeset('events',@StopSim8);
[t,X]=ode45(@barrier9,[0 2],[0 24 0],options);
plot(t,X(:,1),'r',t,X(:,2),'k.',t,(5e-5)*X(:,3)/9.8,'k--','LineWidth',2)
xlabel('time, sec.')
ylabel('outputs of interest')
228
title('Homework 8, Crash Barrier Simulation')
legend('displacement, m','velocity, m/s','deceleration/g','Location','Best')
function dx=barrier9(t,x)
y=x(1);yd=x(2);P=x(3);%allows writing equations in terms of y, yd, and P
dx=zeros(3,1);
dx(1)=x(2);
dx(2)=-(5e-5)*P;
a=5;b=7;c=8.5;
n=4;
if y>a;n=3;end;
if y>b;n=2;end;
if y>c;n=1;end;
Q=n*(2.4e-4)*sqrt(abs(P))*sign(P);
dx(3)=2e8*(.05*yd-Q)/(10-y);
end
function[Val,Ister,Dir]=StopSim8(t,x)
Val(1)=x(1)-10;Ister(1)=1;Dir(1)=0;%stops simulation if y=10
Val(2)=x(2);Ister(2)=1;Dir(2)=0;%stops simulation if velocity=0
end
20
displacement, m
velocity, m/s
outputs of interest
deceleration/g
15
10
0
0 0.5 1 1.5 2
time, sec.
229
Homework 32
The simulation diagram for the roll control of an airplane is shown below where is the
roll angle of the airplane and is the desired roll angle. The input to the hydraulic
actuator is u(t); the actuator adjusts the aileron angle which causes the plane to roll.
A control engineer has designed the controller Gc(s) to improve the speed and damping of
the roll response following a roll angle input command from the pilot.
. + . +
() =
. + . +
hydraulic airplane
desired actuator dynamics roll angle
roll angle d + u 10 1 1
Gc 10
s 10 0.2s 1 s
- ailerons
Create a Simulink diagram of this roll control system. We would like to generate plots (on
the same graph) of () with and without the controller; without the controller means
Gc(s) = 1. The desired roll angle is a step input of 5 degrees. Also generate plots of ()
with and without the controller.
Do you think the control engineer has done a good job of designing Gc(s)? What is the
maximum aileron angle with and without the controller? Is the maximum aileron angle
with the controller realistic?
230
Homework 32 Solution
Do you think the control engineer has done a good job of designing Gc(s)? The roll of the
airplane is lightly damped without the controller; with the controller, the overshoot and
settling time to the desired roll angle are reduced significantly.
What is the maximum aileron angle with and without the controller? About 53 degrees
which is too big. Is the maximum aileron angle with the controller realistic? Unlikely.
>> plot(y(:,3),y(:,2),'r--',y(:,3),y(:,5),'k','Linewidth',2)
>> title('Homework 32 - airplane roll control')
>> ylabel('roll angle, \phi degrees')
>> xlabel('time, sec.')
>> legend('PID controller','unity gain controller','Location','Best')
>> figure
>> plot(y(:,3),y(:,1),'r--',y(:,3),y(:,4),'k','Linewidth',2)
>> title('Homework 32 - airplane roll control')
>> ylabel('aileron angle, \theta degrees')
>> xlabel('time, sec.')
>> legend('PID controller','unity gain controller','Location','Best')
231
Homework 32 - airplane roll control
9
6
roll angle, degrees
PID controller
2 unity gain controller
0
0 0.5 1 1.5 2 2.5 3
time, sec.
50
40
PID controller
unity gain controller
30
aileron angle, degrees
20
10
-10
-20
-30
0 0.5 1 1.5 2 2.5 3
time, sec.
232
Homework 33
1. Express the following polynomials in factored format. In each case, check your work by
multiplying the factored components to determine if they give the correct original polynomial.
For example
2. Assume that a polynomial has been factored and some of the roots have been found to be the
following complex pair: 2 4.
(a) What is the time constant associated with this complex pair? ________________
(b) What is the damped natural frequency associated with this complex pair? ______
(c) What is the undamped natural frequency associated with this complex pair? _____
(d) What is the damping ratio associated with this complex pair? ___________
3. Use a calculator or computer to find the roots of the following polynomial. Determine time
constants, damping ratios, undamped natural frequencies, and damped natural frequencies.
2 5 + 58 4 + 736 3 + 4720 2 + 15200 + 20000
Roots: _____________________________________________________________
Time Constants: _____________________________________________
Undamped natural frequencies: ___________________________________________
Damped natural frequencies: ___________________________________________
Homework 33 Solution
1. Express the following polynomials in factored format. In each case, check your work by
multiplying the factored components to determine if they give the correct original polynomial.
For example
2. Assume that a polynomial has been factored and some of the roots have been found to be the
following complex pair: 2 4.
(e) What is the time constant associated with this complex pair? 0.5 sec.
(f) What is the damped natural freq. associated with this complex pair? 4 rad/sec
(g) What is the undamped natural freq. associated with this complex pair?20 = 4.472
(h) What is the damping ratio associated with this complex pair? 0.4472
3. Use a calculator or computer to find the roots of the following polynomial. Determine time
constants, damping ratios, undamped natural frequencies, and damped natural frequencies.
2 5 + 58 4 + 736 3 + 4720 2 + 15200 + 20000
Roots: 8 6, 5, 4 2
Time Constants: 0.125 sec. 0.2 sec. 0.25 sec.
Undamped natural frequencies: 10 rad/sec 4.472 rad/sec
Damped natural frequencies: 6 rad/sec 2 rad/sec
234
digits for single.
format SHORTENG Engineering format that has at least 5 digits and a power that is a
multiple of three
format LONGENG Engineering format that has exactly 16 significant digits and a power
that is a multiple of three.
Type:
>> format shortg (What I recommend in general)
Enter different values for the variable a and observe how MATLAB displays the number for
different formats:
>> a=123456
>> a=123456789123456789
4. Multiply two polynomials using the command conv: (2s+3)(s+4) = 2s2 +11s + 12
>> n1=[2 3];
>> n2=[1 4];
>> conv(n1,n2)
5. Enter the ratio of two polynomials such as a transfer function. For example:
83 +32 +12+16
() = 4 +223 +1642 +488+480 (note, the numerator is from part 2 above)
>> d=[1 22 164 488 480];
>> G=tf(n,d)
6. We can also enter a transfer function if the numerator and denominator are factored:
( + 2)( + 3)
= 4.078
( + 5)( + 6 + 7)( + 6 7)
The numerator roots are called zeros: -2 and -3
The denominator roots are called poles: - 5 and -6 - j7 and -6 + j7
The number 4.078 in front is called the gain.
>>H=zpk([-2 -3],[-5 -6 j*7 -6 +j*7],4.078)
Note, we can change the format to the polynomial format using tf:
>>H=tf(H)
7. We know that the denominator of a transfer function is called the characteristic polynomial
and its roots are the eigenvalues. The eigenvalues give us damping ratios and natural
frequencies.
>> damp(H) This command gives us the eigenvalues for a transfer function.
235
8. Suppose you have several commands that may need to be repeated more than once and you
dont want to have to keep typing them over and over; this can be done by creating an M-file.
To create a new M-file with a series of commands, under the home tab and then new tab,
select script; if the series of commands require inputs and outputs, select function. Type in
the commands and save it with a name and location you can find. You will probably need to
change the path to this location so MATLAB can find it; use set path under the home tab.
Note, when creating an M-file, it is wise to add comment statements to help you remember the
purpose of the M-file and how to use it. The % notes the beginning of a comment. Also,
comments at the beginning will be displayed following the command help name of M-file.
Sample M-file: Suppose we want an M-file to plot y = 2sin(t) and x = 2sin(t+0.75) for
0 8 every 0.1 sec.
%The following M-file is to be saved with the name plot demo
% plotting sine functions y = 2sin(t) and x = 2sin(t +0.75) for 0t8 every 0.1 sec
t=0:0.1:8; %Generates values of t from 0 to 8 every 0.1 sec.
y=2*sin(pi*t); %Generates a value for y for each value of t.
x=2*sin(pi*t+0.75); % Generates a value for x for each value of t.
% >> help plot to see possible data patterns and colors
plot(t,y,'r',t,x,'k-.','Linewidth',2) %Plots y and x on the same plot as a functions of time
%Avoid using blue; black and red copy best for black and white only copies.
title('plot demo for two functions')
xlabel('time,sec.')
ylabel('sine functions y and ')
legend('y(t)','x(t)','Location','Best') %Type help legend to see the options
To execute this M-file for A=4 type the following in the command window:
>> SolveSymEqns;
10. Using your calculator, find the magnitude and phase angle of Z below; also do it using
MATLAB to check your answers:
( + 2)( + 10)
= [0.1 2 ]
( + 4 + 16) =3+5
>> s=-3+j*5;
>> Z=0.1*(s+2)*(s+10)/(s^2+4*s+16);
>> MagZ=abs(Z)
>> AngleZ=angle(Z)
Homework 34 Solution
8.
%The following M-file is to be saved with the name plot demo
% plotting sine functions y = 2sin(?t) and x = 2sin(?t +0.75) for 0?t?8 every 0.1 sec
t=0:0.1:8; %Generates values of t from 0 to 8 every 0.1 sec.
y=2*sin(pi*t); %Generates a value for y for each value of t.
x=2*sin(pi*t+0.75); % the same function shifted in phase
plot(t,y,'r',t,x,'k-.','Linewidth',2) %Plots y and x on the same plot as a functions of
time
%Avoid using blue; black and red copy best.
title('plot demo for two functions')
xlabel('time,sec.')
ylabel('sine functions')
legend('y(t)','x(t)','Location','Best') %Type help legend to see the options
1.5
0.5
y(t)
sine functions
x(t)
0
-0.5
-1
-1.5
-2
0 1 2 3 4 5 6 7 8
time,sec.
237
9.
% Symbolic math demo
% Using symbolic math to solve simultaneous equations
function [X]=SolveSymEqns(A)
syms a % declare a to be symbolic so we can substitute a value for it
H=solve('2*x+a*y=4','-3*x+5*y=2','x,y');
x=H.x
x=subs(H.x,a,A)
digits(5)
X=vpa(x)
end % this designates the end of the function
To execute this M-file for A=4 type the following in the command window:
>> SolveSymEqns(4); % assigns A=4 to be used in the M-file
x = -(2*(a - 10))/(3*a + 10)
x = 6/11
X = 0.54545
ans = 0.54545
10. Using your calculator, find the magnitude and phase angle of Z below; also do it using
MATLAB to check your answers:
( + 2)( + 10)
= [0.1 2 ]
( + 4 + 16) =3+5
|1+5| (1+5) |7+5| (7+5)
Using calculator: = 0.1 2
|(3+5)2 +4(3+5)+16| ((3+5) +4(3+5)+16)
|1 + 5| (1+5) |7 + 5| (7+5)
= 0.1
|12 10| (1210)
238
Homework 35
+ 2 + 3 3 = 24(0 ) = 1 (0 ) = 0
Setting derivatives of y to zero to get the final value gives: 0 + 0+3y3=24. Final
value of y = 2. So, we need the equation for a line that passes through (y,y3)=(1,1)
and (2,8). 3 7 6. Thus, + 2 + 3(7 6) = 24 or
+ 2 + 21 = 42
2. Consider the following differential equation for y with input u.
3 + 36 + 183 + 246 = 6 + 54 + 1476
6 2 +54+1476
(g) What is the transfer function?
3 3 +36 2 +183+246
239
(h) What are the eigenvalues? -2, -5+j4, -5-j4
(i) What is the damping ratio? 0.781
(j) What is the damped natural frequency?4 rad/sec
(k) What are the time constants? 0.5 and 0.2 sec
(l) It can be shown that if u(t) is a constant, then y(t) will eventually
become a constant. Approximately how long will take for y(t) to be
within 1% of its final value? 5x0.5 = 2.5 sec
Homework 36
Consider the following three lumped mass approximation model for a pile being driven into the
ground with input force F(t); the output of interest is the force f(t) exerted on the ground
resulting from the input force F(t).
F(t) F(t)
m=10 kg
b=5 Ns/m
M z k=1000 N/m
k b
M v
k b
M w
k b
f f
It can be shown that the equations representing this model for displacements z, v, and w defined
to be zero at equilibrium and assuming zero displacement at the bottom end of the pile are as
shown below. The ground force is the force that forces the bottom end of the pile into the
ground. The output of interest to us is the ground force.
mz bz kz bv kv F
mv 2bv 2kv bz kz bw kw
mw 2bw 2kw bv kv
f 3mg bw kw
A symbolic math M-file is shown in the notebook for obtaining the transfer function relating the
output to the input.
(a) Type or paste this M-file into your computer and demonstrate you can get this transfer
function; use s instead of d. Be prepared to explain (for instance on an exam) the purpose of
each of the command lines in the M-file.
The transfer function H(s) relating the ground force f to the input force F is shown below. Did
you M-file give the same result?
() = ()()
6.25 3 + 3750 2 + 750,000 + 50,000,000
() =
50 6 + 125 5 + 25,088 4 + 30,011 3 + 3,004,000 2 + 750,000 + 50,000,000
240
(b) Suppose the input F(t) is a step with magnitude Fo. Use the final value theorem to compute the
final value of the ground force (note we are neglecting the weight 3Mg of the beam). Explain
why this value makes sense.
The DC gain can be computed by setting s in a transfer function to zero. What is the DC gain of
H(s) above? The MATLAB command is dcgain(H). Enter this transfer function H into MATLAB
and use the dcgain command. What is the answer? Does it make sense? Why?
(d) We know that the partial fractions of a transfer function are called the modes of the transfer
function or the modes of the system. The sum of the mode responses makeup the total system
response. Use the MATLAB command pfract to get the modes of this system. What are the
time constants, damping ratios, and frequencies of the different modes? If the input F(t) is an
impulse, which mode will be the most important? Why?
(e) Enter each mode as a separate transfer function into MATLAB: H1(s), H2(s), and H3(s). Use the
impulse command to compare the impulse response of the modes, i.e.
>> impulse(H,r,H1,k--,H2,r*,H3,k-.,5) % The 5 limits the time to 5 sec
>> legend(all 3 modes together,first mode,second mode,third mode,Location,Best)
(f) Which mode response most closely resembles the total system response? Why?
Homework 36 Solution
Homework 37
In each case below, check your Laplace transform and final equation for y(t) using the initial and
final value theorems and calculating y(t)t=0 and ()= .
1. Use the residue method to solve the following differential equation for y(t).
+ 7 + 10 = 10(0 ) = 0 (0 ) = 10
2. Use the residue method to solve the following differential equation for y(t).
+ 7 + 10 = 20 + 14 (0 ) = 10 (0 ) = 0
u(t)
0.5
0 t
241
25
3. () = Solve for y(t)
(2 +6+25)
Homework 37 Solution
In each case below, check your Laplace transform and final equation for y(t) using the initial and
final value theorems and calculating y(t)t=0 and ()= .
4. Use the residue method to solve the following differential equation for y(t).
+ 7 + 10 = 10(0 ) = 0 (0 ) = 10
10
2 10 + 7 + 10 =
10 + 10
() = :() = 1: (0+ ) = 0
( + 2)( + 5)
u(t)
0.5
0 t
0.5
2 10 + 7( 10) + 10 = (14 + 20)
10 2 + 77 + 10
() = :1:10
( + 5)( + 2)
() = 1 + 17.333 2 8.333 5 () = 1(0) = 1 + 17.333 8.333 = 10
25
6. () = Solve for y(t).
(2 +6+25)
FVT: () = 1:(0+ ) = 0
3 25 25
() = 1 0 + | | sin (4 + ( ))
4 3 + 4 3 + 4
() = 1 + 1.25 3 sin(4 2.2143) () = 1 + 0 = 1
(0) = 1 + 1.25 sin(2.2143) = 0
Homework 38
The purpose of this assignment is to demonstrate the power of being able to generate a plot of an
inverse Laplace transform without having to first generate the equation for the inverse Laplace;
this is done by pretending that the Laplace transform is a transfer function with a unit impulse
input. We can do this because the Laplace transform of a unit impulse is 1.
242
In Homework 37, for each problem below, you found the equation for Y(s) and then found y(t)
using the inverse Laplace transform. In this assignment, you are to use the MATLAB command
impulse to get a plot of y(t) without having to first get the equation for y(t) as you did in
Homework 37. For each problem below, generate two plots for y(t) for comparison on a single
graph, one plot using the equation for y(t) and the other plot generated using the impulse
command.
1.
+ 7 + 10 = 10(0 ) = 0 (0 ) = 10
10 + 10
() =
( + 2)( + 5)
() = 1 + 1.666 2 2.666 5
2. + 7 + 10 = 20 + 14 (0 ) = 10 (0 ) = 0
u(t)
0.5
0 t
10 2 + 77 + 10
() =
( + 5)( + 2)
() = 1 + 17.333 2 8.333 5
25
3. () =
(2 +6+25)
Homework 38 Solution
The purpose of this assignment is to demonstrate the power of being able to generate a plot of an
inverse Laplace transform without having to first generate the equation for the inverse Laplace;
this is done by pretending that the Laplace transform is a transfer function with a unit impulse
input. We can do this because the Laplace transform of a unit impulse is 1.
In Homework 37, for each problem below, you found the equation for Y(s) and then found y(t)
using the inverse Laplace transform. In this assignment, you are to use the MATLAB command
impulse to get a plot of y(t) without having to first get the equation for y(t) as you did in
Homework 37. For each problem below, generate two plots for y(t) for comparison on a single
graph, one plot using the equation for y(t) and the other plot generated using the impulse
command.
1.
243
+ 7 + 10 = 10(0 ) = 0 (0 ) = 10
10 + 10
() =
( + 2)( + 5)
() = 1 + 1.666 2 2.666 5
Homework 7.1
1.4
using impulse
using inverse Laplace
1.2
0.8
y
0.6
0.4
0.2
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
time, sec
2. + 7 + 10 = 20 + 14 (0 ) = 10 (0 ) = 0
u(t)
0.5
0 t
10 2 + 77 + 10
() =
( + 5)( + 2)
() = 1 + 17.333 2 8.333 5
244
Homework 7.2
11
using impulse
using inverse Laplace
10
6
y
1
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
time, sec
25
3. () =
(2 +6+25)
1.2
0.8
y
0.6
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
time, sec
245
Y1=tf([10 10],[1 7 10 0]);
[y1i,t]=impulse(Y1);
y1=1+1.666*exp(-2*t)-2.666*exp(-5*t);
plot(t,y1i,'r',t,y1,'k.','Linewidth',2)
xlabel('time, sec')
ylabel('y')
legend('using impulse','using inverse Laplace')
title('Homework 7.1')
figure
clear t
Y2=tf([10 77 10],[1 7 10 0]);
[y2i,t]=impulse(Y2);
y2=1+17.333*exp(-2*t)-8.333*exp(-5*t);
plot(t,y2i,'r',t,y2,'k.','Linewidth',2)
xlabel('time, sec')
ylabel('y')
legend('using impulse','using inverse Laplace')
title('Homework 7.2')
figure
clear t
Y3=tf(25,[1 6 25 0]);
[y3i,t]=impulse(Y3);
y3=1+1.25*exp(-3*t).*sin(4*t-2.2143);
plot(t,y3i,'r',t,y3,'k.','Linewidth',2)
xlabel('time, sec')
ylabel('y')
legend('using impulse','using inverse Laplace')
title('Homework 7.3')
246
Homework 39
The schematic for a vehicle suspension is shown below. The differential equation for the upward
displacement y of the vehicle mass in terms of the road profile u is also shown below. The
frequency of the road profile is a function of the vehicle speed.
mass y
u
road
(a) Solve the differential equation for y(t) using Laplace transforms for = 10/.
(b) Show that the equation for y(t) as is a sine function. What is the amplitude of the y(t)
sine function? How much larger or smaller is this amplitude compared to the amplitude of the
road sine function?
(c) Using MATLAB, plot y(t) and show that y(t) does eventually become a constant amplitude sine
function. Confirm from your plot that the amplitude in (b) is correct.
(d) Use the MATLAB command bode to generate the frequency response of the transfer function
for this suspension and confirm that the amplitude at = 10/ is correct.
Homework 39 Solution
The schematic for a vehicle suspension is shown below. The differential equation for the upward
displacement y of the vehicle mass in terms of the road profile u is also shown below. The
frequency of the road profile is a function of the vehicle speed.
mass y
u
road
(e) Solve the differential equation for y(t) using Laplace transforms for = 10/. Since we are
interested in the steady state solution, it doesnt matter what the initial conditions are. The
point of the problem is to observe how the solution converges to the steady state sinusoidal
function.
247
+ . ()
:() = [ ]
+ + +
+ . .
() = = +
+ + + + + + +
() = . (. + . ) + . ( . )
Assuming the initial value of z is 0.3, z(0-) = 0.3:
. +. ++ .+. .
() = + + ++ = ++ + +
() = . (. + . ) + . ( . )
Show that the equation for y(t) as is a sine function. What is the amplitude of the y(t)
sine function? How much larger or smaller is this amplitude compared to the amplitude of
the road sine function? Regardless of the initial conditions:
As , () = 0.1601 sin(10 0.8961) 1.6.
(f) Using MATLAB, plot y(t) and show that y(t) does eventually become a constant amplitude sine
function.
It will take about 1.25 seconds for y(t) to reach steady state behavior. So, we will run the
simulation for 3 seconds to see enough of the steady behavior to get the steady state sine wave
amplitude. Also, the largest pole magnitude is 10; so, we need a time increment no greater than
1/(10*10) = 0.01.
>> t=0:0.01:3;
>> y=0.1364*exp(-4*t).*sin(9.1652*t+1.9823)+0.1601*sin(10*t-0.8961);
>> Y=0.4318*exp(-4*t).*sin(9.1652*t+1.393)+0.1601*sin(10*t-0.8961);
>> plot(t,y,'r',t,Y,'k.','Linewidth',2)
>> xlabel('time, sec.')
>> ylabel('y(t)')
>> title('plots of y(t) for different initial conditions')
>> legend('initial value of y = 0','initial value of y=0.3','Location','best')
plots of y(t) for different initial conditions
0.3
initial value of y = 0
0.25
initial value of y=0.3
0.2 X: 2.76
Y: 0.1601
0.15
0.1
y(t)
0.05
-0.05
-0.1
-0.15
-0.2
0 0.5 1 1.5 2 2.5 3
time, sec.
Confirm from your plot that the amplitude in (b) is correct. As shown above, the amplitude is
correct.
248
(g) Use the MATLAB command bode to generate the frequency response of the transfer function
for this suspension and confirm that the amplitude at = 10/ is correct.
As shown in the frequency response plot below, the amplitude at 10 rad/s is 4.06 dB which is
equivalent to a gain of 1.5959 1.6 which agrees with the time domain solution. Also note that
the phase on the frequency response plot is -51.8 degrees which is -0.9041 rad which is also
approximately which is approximately equal to -0.8961 rad obtained using the inverse Laplace
transform.
Bode Diagram
6
4
System: g
Frequency (rad/s): 10
Magnitude (dB)
-2
-4
-6
0
-45
Phase (deg)
System: g
Frequency (rad/s): 10
Phase (deg): -51.8
-90
-135
1
10
Frequency (rad/s)
249
Homework 40
The schematic for a vehicle suspension is shown below. The differential equation for the upward
displacement y of the vehicle mass in terms of the road profile u is also shown below. Assume
the road profile input is a step of 0.1 m at time zero and assume the initial conditions are all zero.
mass y
u 0.1 m
road
(a) Draw an estimate of y(t). Be sure to show the initial and final values and the approximate time
to steady state.
y
0 time
(b) Define state variables for this differential equation and write the derivative equations, i.e.
1 =?
2 =?
(c) Use ode45 to generate a numerical solution and a plot of y. Does your plot match your estimate
in part (a)?
250
Homework 40 Solution
The schematic for a vehicle suspension is shown below. The differential equation for the upward
displacement y of the vehicle mass in terms of the road profile u is also shown below. Assume
the road profile input is a step of 0.1 m at time zero and assume the initial conditions are all zero.
mass y
u 0.1 m
road
(a) (15%) Draw an estimate of y(t). Be sure to show the initial and final values and the approximate
time to steady state.
y, m
0.1
1.25
0 time, sec
(b) (25%) Define state variables for this differential equation and write the derivative equations, i.e.
= =
= + = +
(c) (40%) Use ode45 to generate a numerical solution and a plot of y. Does your plot match your
estimate in part (a)? Yes, the initial and final values match as well as the time to steady state.
clear all
[t,x]=ode45(@hmwk9eqns3360,[0 1.25],[0 0]);
y=x(:,1);
plot(t,y,'r','Linewidth',2)
xlabel('time, sec.')
ylabel('y(t), m')
title('Homework 9 Vehicle Mass Displacement')
figure
y2=0.1-x(:,1);
plot(t,y2,'r','Linewidth',2)
xlabel('time, sec.')
ylabel('u-y(t), m')
title('Homework 9 Variation in Suspension Stroke')
251
function dx = hmwk9eqns3360( t,x )
dx=zeros(2,1);
u=0.1;
dx(1)=x(2)+8*u;
dx(2)=-100*x(1)-8*x(2)+36*u;
end
Homework 9 Vehicle Mass Displacement
0.14
0.12
0.1
0.08
y(t), m
0.06
0.04
0.02
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4
time, sec.
0.08
0.06
0.04
u-y(t), m
0.02
-0.02
-0.04
0 0.2 0.4 0.6 0.8 1 1.2 1.4
time, sec.
252
Homework 41
A cannon ball is fired at an initial angle of 60 deg with an initial velocity of V=100 m/sec. The
differential equations for the trajectory of the ball can be shown to be:
V z 2 y 2
10z 0.2 zV 0
10 y 0.2 y V 98 0
y (0 ) 0
y (0 ) 100 sin(60 deg) 86.6m / s
z (0 ) 0
z(0 ) 100 cos(60 deg) 50m / s
V(0)=100
(0) 60 deg
0 z
(a) On the graph above, draw an estimate of the trajectory of the ball.
(b) Define state variables for the two differential equations above.
(c) What are the initial conditions for your state variables?
(d) Find the derivative equations for the state variables.
(e) Create M-files for obtaining a plot of the trajectory, with y and z coordinates as shown above,
using ode45. Use an event function to end the simulation when the ball hits the ground on its
descent. Use common sense to determine if your simulation is probably correct.
253
Homework 41 Solution
A cannon ball is fired at an initial angle of 60 deg with an initial velocity of V=100 m/sec. The
differential equations for the trajectory of the ball can be shown to be:
V z 2 y 2
10z 0.2 zV 0
10 y 0.2 y V 98 0
y (0 ) 0
y (0 ) 100 sin(60 deg) 86.6m / s
z (0 ) 0
z(0 ) 100 cos(60 deg) 50m / s
y
V(0)=100
(0) 60 deg
0 z
(a) On the graph above, draw an estimate of the trajectory of the ball.
(b) Define state variables for the two differential equations above.
1 = 2 = 3 = 4 =
(c) What are the initial conditions for your state variables?
1 (0 ) = 02 (0 ) = 503 (0 ) = 04 (0 ) = 86.6
= 22 + 42
1 = 2
2 = 0.022
3 = 4
4 = 9.8 0.024
(e) Create M-files for obtaining a plot of the trajectory, with y and z coordinates as shown above,
using ode45. Use an event function to end the simulation when the ball hits the ground on its
descent. Use common sense to determine if your simulation is probably correct. The graph
below makes sense.
254
options=odeset('events',@SimStop);
V=100;TH=60*pi/180;
[t,x]=ode45(@TrajectoryEqns,[0 15],[0 V*cos(TH) 0 V*sin(TH)],options);
plot(x(:,1),x(:,3),'r.')
xlabel('Horizontal Distance, m')
ylabel('Altitude, m')
title('Homework 10 Cannonball Trajectory - 60 deg. firing angle')
60
50
40
Altitude, m
30
20
10
-10
0 10 20 30 40 50 60 70 80
Horizontal Distance, m
255
Homework 42
Repeat problem 41 but this time using SIMULINK to get the plot. Note, I suggest you first draw
a simulation diagram starting by solving for and then putting these terms through
integrators. You will need to use Sqrt and Product from Math Operations in the library.
Dont forget to add initial conditions to the appropriate integrators. Also, use the solution to
Homework 41 to get the final simulation time or guess long to get it.
Homework 42 Solution
Homework 11 Solution MAE 3360 Due Nov. 17, 2015
Last, First Name___________________________
Repeat problem 10 but this time using SIMULINK to get the plot. Note, I suggest you first draw
a simulation diagram starting by solving for and then putting these terms through
integrators. You will need to use Sqrt and Product from Math Operations in the library.
Dont forget to add initial conditions to the appropriate integrators. Also, use the solution to
Homework 10 to get the final simulation time or guess long to get it.
Simulink Diagram (50%)
256
Homework 11: Simulink solution to cannonball trajectory
70
60
50
height of ball, m
40
30
20
10
0
0 10 20 30 40 50 60 70 80
horizontal travel distance of ball, m
Homework 43
The radar dish system shown below is used to track airplane targets as they pass overhead. The
input to the system is the true angle to the target (degrees) which is a ramp defined by 10t. In
other words, the targets typically pass over at a rate of 10 deg./sec. The pointing angle of the
dish is denoted by also in degrees.
d (t )
d e u deg.
0.4758s 1 100 1 10
+-
0.0234s 1 5s 1 s 30 1
hydraulic
controller positioner
t
0 time, sec
(a) The input to the controller is e. Show that the differential equation for the controller is
0.0234 + = 0.4758 +
257
(b) The input to the hydraulic positioner is u. Show that the differential equation for the hydraulic
positioner is
5 + = 100
(c) Assign the three state variables for this system and express the state variable equations in matrix
format where the output of interest is , i.e.
= + = +
(d) Use damp to compute the eigenvalues of this system. Based on the time constants, about how
long does it take to acquire the target?
(e) Assume that the initial pointing angle (0 ) of the dish is 90 degrees (vertical) at the time that
the control system becomes aware of a passing target which at that instant is at an angle of 30
degrees above the horizon. Use lsim to generate and then plot the time response of the pointing
angle of the dish.
Homework 43 Solution
The radar dish system shown below is used to track airplane targets as they pass overhead. The
input to the system is the true angle to the target (degrees) which is a ramp defined by 10t. In
other words, the targets typically pass over at a rate of 10 deg./sec. The pointing angle of the
dish is denoted by also in degrees.
d (t )
d e u deg.
0.4758s 1 100 1 10
+-
0.0234s 1 5s 1 s 30 1
hydraulic
controller positioner
t
0 time, sec
(a) (10%) The input to the controller is e. Show that the differential equation for the controller is
0.0234 + = 0.4758 +
(b) (10%) The input to the hydraulic positioner is u. Show that the differential equation for the
hydraulic positioner is
5 + = 100
258
(c) (40%) Assign the three state variables for this system and express the state variable equations in
matrix format where the output of interest is , i.e.
= + = +
(e) (30%) Assume that the initial pointing angle (0 ) of the dish is 90 degrees (vertical) at the time
that the control system becomes aware of a passing target which at that instant is at an angle of 30
degrees above the horizon. Use lsim to generate and then plot the time response of the pointing
angle of the dish.
>> t=0:1/300:2;
>> PhiTar=30+10*t;
>> Xi=[90;0;0];
>> Phi=lsim(G,PhiTar,t,Xi);
>> plot(t,PhiTar,'r',t,Phi,'k-.','Linewidth',2)
>> xlabel('time, sec')
259
>> ylabel('angle, deg')
>> legend('angle to target','angle of radar antenna')
>> title('Homeowrk 12: state variable version of radar antenna control')
80
70
60
angle, deg
50
40
30
20
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time, sec
260
Chapter 8 Previous Exams and Solutions
Exam 1a
1. (20%) For each differential equation below, answer the following questions:
(a) + 16 + 12 = 5
Is the equation linear?________ What is the order? _______ What is the dependent
variable?_______
What is the independent variable?_____ What is the final value of the dependent
variable?________
(b) 2 + 0.4 + 0.1( )5 + 10 = 24
Is the equation linear?________ What is the order? _______ What is the dependent
variable?_______
What is the independent variable?_____ What is the final value of the dependent
variable?________
2. Before the valve on the water tank is opened, the height H of the water in the tank is 10 m.
Once the valve is opened, water flows out of the tank. The differential equation for H with water
flowing out is as follows
4 + 0.8 = 0
(10%) On the sketch below, draw a reasonable estimate of H as a function of time.
valve
0 time
flow
Use separation of variables to solve this differential equation for H(t).
Does your equation for H(t) give the correct initial and final values for H?
(20%) Equation for H(t) _______________________________
(5%) Initial value of H from the equation __________
(5%) Final value of H from the equation ___________
261
3. A pendulum is attached to a cart as shown below. The system is shown in equilibrium, that
is, nothing is moving.
spring
cart
pendulum
If the cart is rolled to the right or left and released or if the pendulum is raised to the right or left
and then released, the cart will start rolling back and forth compressing and extending the spring
while the pendulum swings back and forth.
z
It can be shown, for small angles, the following two simultaneous equations with unknowns
accurately model the dynamics of this system
+ 3 + 9 = 0.9
7 + 175 = 2
Using the 'D' operator, convert these equations to algebraic equations, eliminate , and finally
end up with a single differential equation for . What is the order of this differential equation?
262
Exam 1a Solution
1. (20%) For each differential equation below, answer the following questions:
(a) + 16 + 12 = 5
Is the equation linear?__yes___ What is the order? ___2nd_ What is the dependent
variable?_v_____
What is the independent variable? time
What is the final value of the dependent variable? 5/12=0.4166
(b) 2 + 0.4 + 0.1( )5 + 10 = 24
Is the equation linear?__no What is the order? ___3rd What is the dependent variable?_y____
What is the independent variable? time What is the final value of the dependent variable? 2.4
2. Before the valve on the water tank is opened, the height H of the water in the tank is 10 m.
Once the valve is opened, water flows out of the tank. The differential equation for H with water
flowing out is as follows
4 + 0.8 = 0
(10%) On the sketch below, draw a reasonable estimate of H as a function of time.
H
10
valve
0 time
flow
Use separation of variables to solve this differential equation for H(t).
()
4 = 0.8 () (0) = 0.1() = ((0) 0.1)2
(0) 0
Does your equation for H(t) give the correct initial and final values for H?
(20%) Equation for H(t) () = (10 0.1)2
(5%) Initial value of H from the equation (0) = (10 0.1 (0))2 = 10
(5%) Final value of H from the equation () = (10 0.1)2 = 0 H cannot go
negative
263
3. A pendulum is attached to a cart as shown below. The system is shown in equilibrium, that
is, nothing is moving.
spring
cart
pendulum
If the cart is rolled to the right or left and released or if the pendulum is raised to the right or left
and then released, the cart will start rolling back and forth compressing and extending the spring
while the pendulum swings back and forth.
z
It can be shown, for small angles, the following two simultaneous equations with unknowns
accurately model the dynamics of this system
+ 3 + 9 = 0.9
7 + 175 = 2
Using the 'D' operator, convert these equations to algebraic equations, eliminate , and finally
end up with a single differential equation for . What is the order of this differential equation?
(15%) Equations in terms of the 'D' operator
(2 + 3 + 9) = 0.92 (72 + 175) = 22
(20%) Single differential equation in terms of z only
0.92
= 2
+ 3 + 9
2 2
0.92
(7 + 175) = 2 2
+ 3 + 9
Which simplifies to
(5.24 + 213 + 2382 + 525 + 1575) = 0
which corresponds to the following differential equation:
5.2 (4) + 21 + 238 + 525 + 1575 = 0
(5%) Order of the differential equation for z? 4th
264
Exam 1b
1. (15%) Obtain a linear approximation to the following differential equation based on the initial
and final values of z.
+ 3 + 6 = 12(0 ) = 1
6 2 + 20 + 80
() =
[ 2 + 12 + 40]
(a) (5%) Use the final value theorem (FVT) to compute the final value of z(t).
(b)(5%) Use the initial value theorem (IVT) to compute the value of z(t) at t = 0+.
(c)(9%) What are the poles of Z(s) which are the roots of the denominator polynomial?
3. The equations for the water flowing through a long line between two tanks and the height of the
water in the tanks are as follows:
201 = 01 (0 ) = 3
402 = 02 (0 ) = 5
1 2 = 250 (0 ) = 0
H1 H2
Q
+ 3 + 6 = 12(0 ) = 1
0 + 0 + 6 = 12, () = 4
1 2
+
3 3
2
+ 3 + 6[ + ] = 12
3 3
+ 3 + 2 = 8
6 2 + 20 + 80
() =
[ 2 + 12 + 40]
(a) (5%) Use the final value theorem (FVT) to compute the final value of z(t).
80
()=0 = =2
40
(b)(5%) Use the initial value theorem (IVT) to compute the value of z(t) at t = 0+.
()= = 6
(c)(9%) What are the poles of Z(s) which are the roots of the denominator polynomial?
= 0, 6 + 2, 6 2
3. The equations for the water flowing through a long line between two tanks and the height of the
water in the tanks are as follows:
201 = 01 (0 ) = 3
402 = 02 (0 ) = 5
1 2 = 250 (0 ) = 0
266
H1 H2
Q
40[2 5] = 0
1 2 = 250[() 0]
(b)(15%) Reduce the equations down to two equations with unknowns H1(s) and H2(s) .
1 2
=
250
Thus,
1 2
20[1 () 3] = 0
250
1 2
40[2 5] = 0
250
(c)(15%) Reduce the equations down to one equation for the unknown H1(s).
2 = 1 + [5,000 2 + 1]1 15,000
Thus,
1.5108 2 + 65,000
1 =
(5107 2 + 15,000)
(d)(6%) Use the final value theorem to determine the final value of H1. Does this value make
sense?
65,000
1 ()=0 = = 4.333
15,000
Since the initial water height in this tank was 3 and the other 5, a final value between 3 and 5 makes
sense.
(e) (5%) Use the initial value theorem to check the initial value. Is it correct?
1.5108
1 ()= = = 3 which is the correct value.
5107
267
Exam 1c
(b.6) (4%) Assume that the input u is a constant of 4. About how long will it take for z to
reach its final value and what will be the final value?
2. The differential equations for the suspension shown below with input displacement u(t)
are
+ 2 + 10 = 2 + 10
2 + 20 = 2 + 10 + 10
(a) (20%) Find the transfer function for z
268
(b) (10%) The MATLAB command for entering a transfer function is as follows:
>> H=tf(a,b)
a= ?
b= ?
3. Consider the following differential equation with a constant input:
2 + 415 + 2 3 = 54(0 ) = 2 (0 ) = 0
(a) (15%) Linearize this differential equation by obtaining a straight line approximation
for 3 .
(b) (10%) What are the eigenvalues of the linearized differential equation?
Note, 15 = 3.872983346
2 + 16 + 30 = 2 + 4
Exam 1c Solution
1. Consider the following differential equation with input u.
+ 8 + 37 + 50 = 150 + 25
2. The differential equations for the suspension shown below with input displacement u(t)
are
+ 2 + 10 = 2 + 10
2 + 20 = 2 + 10 + 10
(a) (20%) Find the transfer function for z
Converting differential equations to algebraic equations using the D or s operator and solving for
z gives the following transfer function:
20 + 100
23 + 202 + 20 + 100
(b) (10%) The MATLAB command for entering a transfer function is as follows:
>> H=tf(a,b)
a= [20 100];
b= [2 20 20 100];
3. Consider the following differential equation with a constant input:
2 + 415 + 2 3 = 54(0 ) = 2 (0 ) = 0
(a) (15%) Linearize this differential equation by obtaining a straight line approximation for 3 . z
starts at 2 and ends at 3; thus, a straight line through these two points gives
270
+ 215 + 19 = 57
2 + 16 + 30 = 2 + 4
What are the modes of this system? The modes are the partial fractions of the transfer
function, i.e.
+2 0.5 1.5
[ 2 ]= +
+ 8 + 15 +3 +5
0.5
Usually, the first mode is the one with the largest time constant. So, the first mode is +3 and
1.5
the second mode is +5
.
Exam 2a
1. The differential equations for the suspension shown below with input displacement u(t) are
+ 10 + 100 = 10 + 100
+ 40 = + 10 + 30
(a) (10%) Assume all initial conditions are zero and convert the equations above to Laplace
domain.
Z
271
(b) (10%) Demonstrate that if you solve for W(s) in the first equation and then substitute this
expression for W(s) into the 2nd equation, when you solve for Z(s) you get
3000 + 300
() = [ 3 ] ()
+ 40 2 + 300 + 3000
(f) (12%) If the input u(t) is a unit step, the general form of the equation for z(t) can be shown
to be
() = + + sin( + )
(g) (8%) What is the final value of z(t) and how long will it take to get within 1% of this value?
2. (15%) Use the residue theorem to solve the following differential equation for y(t).
22 + 44 = 88(0 ) = 5
272
( 2 + 10 + 100) = (10 + 100)
( + 40) = ( + 10) + 30
(b) (10%) Demonstrate that if you solve for W(s) in the first equation and then substitute this
expression for W(s) into the 2nd equation, when you solve for Z(s) you get
3000 + 300
() = [ 3 ] ()
+ 40 2 + 300 + 3000
2 + 10 + 100
( + 40) ( ) = ( + 10) + 30
10 + 100
( + 40)( 2 + 10 + 100) = (10 + 100)( + 10) + 30(10 + 100)
( 3 + 50 2 + 500 + 4000 10 2 200 1000) = (300 + 3000)
3000 + 300
() = [ 3 ] ()
+ 40 2 + 300 + 3000
(c) (10%) What is the transfer function for this system?
3000 + 300
[ 3 ]
+ 40 2 + 300 + 3000
(d) (12%) Consider the following MATLAB command and results:
>> roots([1 40 300 3000])
ans =
-33.7442
-3.1279 + 8.8950i
-3.1279 - 8.8950i
What are the eigenvalues of this system?
-33.7442
-3.1279 + 8.8950i
-3.1279 - 8.8950i
(e) (8%) What are the time constants of this system?
1/33.7442 = 0.0296 and 1/3.1279 = 0.3197
(f) (12%) If the input u(t) is a unit step, the general form of the equation for z(t) can be shown
to be
() = + + sin( + )
3000 + 300 1
() = [ ]
3 + 40 2 + 300 + 3000
(g) (8%) What is the final value of z(t) and how long will it take to get within 1% of this value?
2. (15%) Use the residue theorem to solve the following differential equation for y(t).
22 + 44 = 88(0 ) = 5
273
22() 5) + 44() = 88/
5 + 4
() =
( + 2)
() = 2 + 3 2
2() 4
[ ] = 2
2(0) 4
2() 4
= 2
2(0) 4
() = 2 + 3 2
Exam 2b
1. (30%) Find the magnitude and angle of the following complex numbers:
4 + j4
-4 + j4
-4 j4
4 - j4
(4 + 4)(4 + 4)
4 4
2. For the differential equation below,
2 + 24 + 40 = 20(0 ) = 0.5 (0 ) = 3() = 5
(a) (20%) Solve for the Laplace transform of z(t), i.e. Z(s)=?.
(b)(5%) Check your Z(s) to see if it gives the correct initial value using the initial value theorem.
(c)(5%) Check your Z(s) to see if it gives the correct final value using the final value theorem.
{} = (){} = () (0 ){} = 2 () (0 ) (0 )
(b) (5%) Plug t = 0 into your equation for y(t) and see if it gives the same value as the IVT.
274
(c) (5%) Plug t= into your equation for y(t) and see if it gives the same value as the FVT.
() (+)
Portion of inverse Laplace for complex poles of
[(+)2 +2 ]()
|
(+)
| sin( +
(+)
[ ])
(+)
Exam 2b Solution
1. (30%) Find the magnitude and angle of the following complex numbers:
+4
4 + j4 Magnitue= 42 + 42 = 32 = 5.66 = 1 (+4) = 4
3 +4
-4 + j4 Magnitude= 42 + 42 = 32 = 5.66 = 1 ( ) =
4 4
4 5
-4 j4 Magnitude= 42 + 42 = 32 = 5.66 = 1 ( ) =
4 4
2 2 1 4 7
4 - j4 Magnitude=4 + 4 = 32 = 5.66 = ( ) =
+4 4
(4+4)(4+4) 3 7 3
Magnitude= 5.66*5.66/5.66 = 5.66 = + =
44 4 4 4 4
0.5 2 + 9 + 50
() =
( 2 + 12 + 20)
(b)(5%) Check your Z(s) to see if it gives the correct initial value using the initial value theorem.
()= = 0.5
(c)(5%) Check your Z(s) to see if it gives the correct final value using the final value theorem.
50
()=0 = = 2.5. = 0
20
IVT: limit sF(s)s= FVT: limit sF(s)s=0
{} = (){} = () (0 ){} = 2 () (0 ) (0 )
32 1 32 32
() = { 2 2 } + | | 4 sin[4 + ( )=4+4 ]
[( + 4) + 4 ] =0 4 =4+4
275
1 32 4 3 3
=1+ sin (4 ) = 1 + 2 4 sin(4 )
4 32 4 4
(b) (5%) Plug t = 0 into your equation for y(t) and see if it gives the same value as the IVT.
(0) = 1 1 = 0
(c) (5%) Plug t= into your equation for y(t) and see if it gives the same value as the FVT.
() = 1 0 = 1
Exam 2c
1. (a) (10%) Find the initial and final values for the following Laplace transform using the Initial
Value Theorem and the Final Value theorem:
2 + 4
() =
(2 + 10)( + 10)
(b) (20%) Use residue theorem to find the inverse Laplace transform of W(s) in part (a); check
you final equation at t = 0 and at t = .
2. The input to the vehicle suspension shown below is the displacement u(t). The equations that
define this suspension are as follows:
Mw bw kw bv kv
2bv 2kv bw kw bu ku
(a) Find the transfer function for W(s), i.e. w
W ( s ) [?]U ( s ) M
k b
k b
8+25
(b) Suppose that the transfer function for w is as follows: 2 +8+25
(b.1) (2%) What is the DC gain?
(b.2) (4%) What are the eigenvalues?
(b.3) (2%) What is the undamped natural frequency, ?
(b.4) (2%) What is the damping ratio?
(b.5) (2%) What is the time constant?
(b.6) (2%) If u(t) is a bump, about how long will it take to return to equilibrium?
3. (36%) Using the transfer function for the suspension in (2.b) above, assume that u(t) is a unit
step input and get an equation for w(t).
276
Exam 2c Solution
1. (a) (10%) Find the initial and final values for the following Laplace transform using the
Initial Value Theorem and the Final Value theorem:
2 + 4
() =
(2 + 10)( + 10)
0+4
FVT gives (0+10)(0+10) = 0.04
2/+4/2
Dividing the numerator and denominator by s2, the IVT gives [ 10 10 ] =0
(2+ )(1+ )
=
(b) (20%) Use residue theorem to find the inverse Laplace transform of W(s) in part (a); check
you final equation at t = 0 and at t = .
0+2 5 + 2 10 + 2
() = 0 + 5 + 10
(0 + 5)(0 + 10) (5)(5 + 10) (10)(10 + 5)
2. The input to the vehicle suspension shown below is the displacement u(t). The equations
that define this suspension are as follows:
Mw bw kw bv kv
2bv 2kv bw kw bu ku
(a) Find the transfer function for W(s), i.e. w
W ( s ) [?]U ( s ) M
( Ms 2 bs k )W (bs k )V k b
2(bs k )V (bs k )(U W ) v
1
from _ 2nd _ eqn : _ V (U W )
2
1 k b
so _ 1st _ eqn _ becomes : _( Ms 2 bs k )W (bs k ) (U W )
2
bs k u
Solving _ for _ W _ gives : W ( s ) U (s)
2 Ms bs k
2
8+25
(b) Suppose that the transfer function for w is as follows:
2 +8+25
(b.1) (2%) What is the DC gain? 1
(b.2) (4%) What are the eigenvalues? -43
(b.3) (2%) What is the undamped natural frequency, ? 5 rad/sec
(b.4) (2%) What is the damping ratio? 0.8
(b.5) (2%) What is the time constant? 0.25 sec
(b.6) (2%) If u(t) is a bump, about how long will it take to return to equilibrium? 1.25 sec
277
3. (36%) Using the transfer function for the suspension in (2.b) above, assume that u(t) is a
unit step input and get an equation for w(t).
8s 25 1 8s 25
W (s) 2
s 8s 25 s s[( s 4) 3 ]
2 2
25 0t e 4t
w(t ) e M sin(3t )
25 3
8s 25 8(4 j 3) 25 (7) 2 (24) 2 25
M 5
s s4 j 3 4 j3 (4) 2 (3) 2 5
angle (7 24 j ) angle (4 j3) ( 1.28) ( 0.64) 0.64
w(t ) 1 1.66e 4t sin(3t 0.64)
Exam 3a
1. Consider the following differential equation for y(t).
2 y 5 y 25 y(0 ) 6
(a) (25%) Use the Laplace transform and the residue theorem to solve this differential equation
for y(t).
(b) (10%) Check your equation for y(t) at t = 0 and at t = . Does your equation give the
correct values at t = 0 and at t = ?
(c) (15%) Perform two steps of Euler's integration to get y(T) and y(2T). Use 1/10 of the time
constant for T.
2. Consider the hydraulic lift system shown below. Fluid flows, Q, into the bottom of the
hydraulic cylinder. The pressure, P, increases and pushes the mass upwards with velocity v .
The model for the system is represented by the following equations :
1000v 0.05P 9800
P 100000Q
Q 0.05v
Velocity
v
Pressure
P
Flow Rate
Q
(a) (5%) We have three equations. What are the three unknowns?
278
(b) (20%) Assuming the initial velocity is zero, Laplace transform the equations and then find a
single equation for the Laplace transform of the pressure P(s).
(c) (10%) What is the final value for P(t) and how long does it take for P(t) to reach this final
value within 1 %?
3. (10%) Express the following 3rd order differential equation in a format of three simultaneous
1st order differential equations. All initial conditions are zero.
2z 16z 8z 5z 10
4. (5%) Consider the Laplace transform W(s) shown below. Pretend that W(s) is a transfer
function with the input being a unit impulse. What are the MATLAB commands for getting a
plot of w(t) using the 'impulse' command in MATLAB?
2s 4
W (s) 2
3s 20s 5
>> help tf
TF Creation of transfer functions or conversion to transfer function.
SYS = TF(NUM,DEN) creates a continuous-time transfer function SYS with
numerator(s) NUM and denominator(s) DEN. The output SYS is a TF object.
>> help impulse
IMPULSE Impulse response of LTI models.
IMPULSE(SYS) plots the impulse response of the LTI model SYS (created
with either TF, ZPK, or SS).
Exam 3a Solution
1. Parts (a) and (b) of this problem are the Key Assignment. Consider the following differential
equation for y(t).
2 y 5 y 25 y(0 ) 6
(a) (25%) Use the Laplace transform and the residue theorem to solve this differential equation
for y(t).
2( sY 6) 5Y 25 / s
6s 12.5
Y ( s)
s( s 2.5)
y (t ) 5 e 2.5t
(b) (10%) Check your equation for y(t) at t = 0 and at t = . Does your equation give the
correct values at t = 0 and at t = ?
y (t )t 0 6
y (t )t 5
Thus, the equation for y(t) gives the correct initial and final values.
(c) (15%) Perform two steps of Euler's integration to get y(T) and y(2T). Use 1/10 of the time
constant for T.
Time constant is 0.4 seconds so T=0.04.
279
t y(t) y (t ) 2.5 y 12.5 y(t T ) Ty (t ) y(t )
0 6 12.5-2.5*6=-2.5 0.04*(-2.5)+6=5.9
0.04 5.9 12.5-2.5*5.9=-2.25 0.04*(-2.25)+5.9=5.81
0.08 5.81
2. Consider the hydraulic lift system shown below. Fluid flows, Q, into the bottom of the
hydraulic cylinder. The pressure, P, increases and pushes the mass upwards with velocity v .
The model for the system is represented by the following equations :
1000v 0.05P 9800
P 100000Q
Q 0.05v
Velocity
v
Pressure
P
Flow Rate
Q
(a) (5%) We have three equations. What are the three unknowns? v, P, and Q
(b) (20%) Assuming the initial velocity is zero, Laplace transform the equations and then find a
single equation for the Laplace transform of the pressure P(s).
9800
1000sV 0.05P
s
P 100000Q
Q 0.05V
Solving for P gives
49000
P( s )
s( s 0.25)
(c) (10%) What is the final value for P(t) and how long does it take for P(t) to reach this final
value within 1 %?
49000
sP( s) s 0 196000 It takes about 5 time constants which is 20 seconds.
( s 0.25) s 0
280
3. (10%) Express the following 3rd order differential equation in a format of three simultaneous
1st order differential equations. All initial conditions are zero.
2z 16z 8z 5z 10
x1 z
x2 z
x3 z
x1 x2
x2 x3
x3 5 2.5 x1 4 x2 8 x3
4. (5%) Consider the Laplace transform W(s) shown below. Pretend that W(s) is a transfer
function with the input being a unit impulse. What are the MATLAB commands for getting a
plot of w(t) using the 'impulse' command in MATLAB?
2s 4
W (s) 2
3s 20s 5
>> w=tf([2 4],[3 20 5]);
>> impulse(w)
>> help tf
TF Creation of transfer functions or conversion to transfer function.
SYS = TF(NUM,DEN) creates a continuous-time transfer function SYS with
numerator(s) NUM and denominator(s) DEN. The output SYS is a TF object.
{} = (){} = () (0 ){} = 2 () (0 ) (0 )
Exam 3b
1. Use Laplace transform to solve the following differential equations for z(t):
(a) (10%) + 25 = 2 + 15(0 ) = 4 The input u(t) is a step with magnitude 5.
(b) (10%) What are MATLAB commands to get a plot of z(t) in part (a) using the impulse
command.
(c) (10%) + 6 + 25 = 50()(0 ) = 1 (0 ) = 0 The input u(t) is a unit impulse.
2. A vehicle suspension system is defined by the following differential equations with input u(t):
100 + 600 + 2500 = 600 + 2500
200 + 900 + 5000 = 600 + 2500 + 300 + 2500
281
(a) (20%) Define state variables and then find the equations for the derivatives of the state
variables.
(b) (10%) Express your state variable derivative equations from (a) in state variable matrix
format assuming the output of interest is y = u - v, i.e.
= + = + =? =? =? =?
3. Consider the following non-linear differential equation for v(t):
+ 84 + 300 3 = 2400(0 ) = 1.9 (0 ) = 2
(a) (10%) What is the equilibrium (final value) of v(t)?
(b) (15%) Find a straight line approximation for 3 for values of in the neighborhood of the
equilibrium value.
(c) (5%) Substitute you straight line equation for 3 in the original differential equation to
obtain a linear differential equation.
(d) (5%) The equilibrium value of your linear differential equation should be the same as the
equilibrium value for the original differential equation. Is this the case?
(e) (5%) What are the eigenvalues of your linearized differential equation? Time constants?
1 2
() = ( ) + [ ] ( ) + [ 2 ] ( )2 +
2!
Exam 3b Solution
1. Use Laplace transform to solve the following differential equations for z(t):
(a) (10%) + 25 = 2 + 15(0 ) = 4 The input u(t) is a step with magnitude 5.
() 4 + 25() = (2 + 15)
14 + 75
() =
( + 25)
() = 3 + 11 25
(b) (10%) What are MATLAB commands to get a plot of z(t) in part (a) using the impulse
command.
>> z=tf([14 75],[1 25 0]);
>> impulse(z)
(c) (10%) + 6 + 25 = 50()(0 ) = 1 (0 ) = 0 The input u(t) is a unit impulse.
( 2 () 1) + 6(() 1) + 25() = 50()
+ 56
() =
( + 3)2 + 42
1
() = | + 56|=3+4 3 sin(4 + ( + 56)=3+4 )
4
() = 13.29 3 sin(4 + 0.0753)
282
. [()] = (). [ ()] = () (0 ). [ ()] = 2 () (0 ) (0 )
1 () ()
| | sin( + ) = ( )
() =+ () =+
2. A vehicle suspension system is defined by the following differential equations with input u(t):
100 + 600 + 2500 = 600 + 2500
200 + 900 + 5000 = 600 + 2500 + 300 + 2500
+ 6 + 25 = 6 + 25
+ 4.5 + 25 = 3 + 12.5 + 1.5 + 12.5
(a) (20%) Define state variables and then find the equations for the derivatives of the state
variables.
1 = 2 = 3 = 4 = 1.5
1 = 2
2 = 251 62 + 253 + 64 + 9
3 = 4 + 1.5
4 = 12.51 + 32 253 4.54 + 5.75
(b) (10%) Express your state variable derivative equations from (a) in state variable matrix
format assuming the output of interest is y = u - v, i.e.
= + = + =? =? =? =?
0 1 0 0 0
=[ 25 6 25 6 ] = [ 9 ] = [0 0 1 0] = [1]
0 0 0 1 1.5
12.5 3 25 4.5 5.75
3. Consider the following non-linear differential equation for v(t):
+ 84 + 300 3 = 2400(0 ) = 1.9 (0 ) = 2
(a) (10%) What is the equilibrium (final value) of v(t)?
0 + 0 + 300 3 = 2400() = 2
(b) (15%) Find a straight line approximation for 3 for values of in the neighborhood of the
equilibrium value.
3 23 + 3(2)2 ( 2) = 12 16
(c) (5%) Substitute you straight line equation for 3 in the original differential equation to
obtain a linear differential equation.
+ 84 + 300(12 16) = 2400
+ 84 + 3600 = 7200
283
(d) (5%) The equilibrium value of your linear differential equation should be the same as the
equilibrium value for the original differential equation. Is this the case?
7200
== 2
3600
(e) (5%) What are the eigenvalues of your linearized differential equation? Time constants?
2 + 84 + 3600 = ( + 42 + 42.85)( + 42 42.85)
= 42 42.85
1
=
= 0.0238
42
1 2
)
() = ( + [ ] ( + [ 2 ] ( )2 +
)
2!
Exam 3c
1. Use the Laplace transform to solve the following differential equations for w(t). In each case, check W(s)
using the initial and final value theorems. Also, using your final equation for w(t), check using w(t) at t = 0
and at t = . Also, in each case determine the time constant(s).
(a) (19 pts) 4 + 40 = 0(0 ) = 5
(b) (19 pts) 2 + 12 + 50 = 12 + 50(0 ) = 0 (0 ) = 0
u(t)
0 t
2. A cannon ball is fired at an angle as shown below. The ball exits the cannon with a velocity 156.2 m/s.
The differential eqn for the vertical displacement is + 0.005 10(0 ) = 2 (0 ) = 100/
and the equation for the horizontal displacement is + 0.005 = 0(0 ) = 0 (0 ) = 120/
where = 2 + 2
(a) (16 pts) Express these equations in state variable format for an ode45 simulation.
(b) (26 pts) Complete the MATLAB code below for ode45 m-files to simulate these equations.
[t,x]=ode45(@Exam3Eqns,[0 10],[ 2 100 0 120 ]);
y=x(:,1);
w=x(:,3);
plot(?,?)
xlabel( horizontal displacement, m )
284
ylabel( height, m)
function dx=Exam3Eqns(t,x)
dx=zeros( ? , 1);
dx(1)= ?;
dx(2)=?;
dx(3)=?;
dx(4)=?;
end
(c) (5 pts) Draw a sketch of what you think the plot will look like.
y
0 w
3. (10 pts) The Z transform transfer function relating W(z) to the input U(z) for problem 1(b) above for
T=0.02 and u(t) piecewise constant is shown below. What is the discrete time solution to this this
differential equation?
0.1177 0.1083
() = [ 2 ] ()
1.878 + 0.8869
{()) = ()
{( + )} = ()
{(( + 2)} = 2 ()
{( )} = 1 ()
(( 2)} = 2 ()
4. (22 pts) Express the following differential equation in state variable format assuming is the output of
interest. The input is a step with magnitude of 2. What are the initial conditions for the state variables?
A = ? B = ? C = ? D = ? initial conditions = ?
2 + 12 + 50 = 12 + 50(0 ) = 0 (0 ) = 0
285
Exam 3c Solution
1. Use the Laplace transform to solve the following differential equations for w(t). In each case, check W(s)
using the initial and final value theorems. Also, using your final equation for w(t), check using w(t) at t = 0
and at t = . Also, in each case determine the time constant(s).
(a) (19 pts) 4 + 40 = 0(0 ) = 5
5
+ 10 = 0() = 05 = 0.1
+ 10
() = 5 10 (0) = 5() = 0
(b) (19 pts) 2 + 12 + 50 = 12 + 50(0 ) = 0 (0 ) = 0
u(t)
EV 3 j 4
1/ 3
2
0 t
6 + 25 2
() = [ ] 20
( + 3)2 + 42
12 + 50
() = 2 + 3 sin(4 + ) = | | = 10
4 =3+4
= (14 + 48) (3 + 4) = 0.9273
2. A cannon ball is fired at an angle as shown below. The ball exits the cannon with a velocity 156.2 m/s.
The differential eqn for the vertical displacement is + 0.005 10(0 ) = 2 (0 ) = 100/
and the equation for the horizontal displacement is + 0.005 = 0(0 ) = 0 (0 ) = 120/
where = 2 + 2
(a) (16 pts) Express these equations in state variable format for an ode45 simulation.
x1 y
x2 y
x3 w
x4 w
x1 x2
V x 22 x 42
x 2 10 0.005Vx2
x3 x4
x 4 0.005Vx4
(b) (26 pts) Complete the MATLAB code below for ode45 m-files to simulate these equations.
[t,x]=ode45(@Exam3Eqns,[0 10],[ 2 100 0 120 ]);
y=x(:,1);
w=x(:,3);
plot(w,y)
286
xlabel( horizontal displacement, m )
ylabel( height, m)
function dx=Exam3Eqns(t,x)
dx=zeros( ? , 1);
dx(1)= x(2);
V=sqrt(x(2)^2+x(4)^2);
dx(2)=-10-0.005*V*x(2);
dx(3)=x(4);
dx(4)=-0.005*V*x(4);
end
(c) (5 pts) Draw a sketch of what you think the plot will look like.
y
0 w
3. (10 pts) The Z transform transfer function relating W(z) to the input U(z) for problem 1(b) above for
T=0.02 and u(t) piecewise constant is shown below. What is the discrete time solution to this this
differential equation?
0.1177 0.1083
() = [ 2 ] ()
1.878 + 0.8869
4. (22 pts) Express the following differential equation in state variable format assuming is the output of
interest. The input is a step with magnitude of 2. What are the initial conditions for the state variables?
A = ? B = ? C = ? D = ? initial conditions = ?
2 + 12 + 50 = 12 + 50(0 ) = 0 (0 ) = 0
1 = 2 = 61 = 2 + 6 2 = 251 62 11 = 2 + 6
0 1 6
=[ ] = [ ] = [0 1] = [6]1 (0 ) = 02 (0 ) = 0
25 6 11
287
Exam 3d
1. Use Laplace transform to solve the following differential equations for z(t):
(a) (15%) 2 + 10 = 4 + 20(0 ) = 3 The input u(t) is a step with magnitude 2.
(b) (15%) 10 + 60 + 250 = 24()(0 ) = 0 (0 ) = 0 The input u(t) is a unit
impulse.
1 () ()
| | sin( + ) = ( )
() =+ () =+
2. A vehicle suspension system is defined by the following differential equations with input u(t):
100 + 600 + 2500 = 600 + 2500
200 + 900 + 5000 = 600 + 2500 + 300 + 2500
(a) (20%) Express this system of equations in state variable format.
(b) (10%) Express your state variable equations from (a) in state variable matrix format
assuming the output of interest is y = v - w, i.e.
(c) = + = + =? = =? =?
(b) (15%) Find a straight line approximation for 3 for values of in the neighborhood of the
equilibrium value.
(c) (5%) Substitute you straight line equation for 3 in the original differential equation to
obtain a linear differential equation.
(d) (5%) The equilibrium value of your linear differential equation should be the same as the
equilibrium value for the original differential equation. Is this the case?
(e) (5%) What are the eigenvalues of your linearized differential equation? Time constants?
1 2
() = ( ) + [ ] ( + [ 2 ] ( )2 +
)
2!
Exam 3d Solution
1. Use Laplace transform to solve the following differential equations for z(t):
(a) (15%) 2 + 10 = 4 + 20(0 ) = 3 The input u(t) is a step with magnitude 2.
2[ 3] + 10 = [4 + 20]
2 14 + 40
(2 + 10) = (4 + 20) + 6 =
7 + 20
() =
( + 5)
() = = 0 + = 5
288
() = 4 + 3 5
Checking z(t) at t = gives the correct value of 4. However, the t = 0+ value of z is different
from the t = 0 value due to the impulse created by .
-
1 () ()
| | sin( + ) = ( )
() =+ () =+
2. A vehicle suspension system is defined by the following differential equations with input u(t):
100 + 600 + 2500 = 600 + 2500
200 + 900 + 5000 = 600 + 2500 + 300 + 2500
(a) (20%) Express this system of equations in state variable format.
+ 6 + 25 = 6 + 25
+ 4.5 + 25 = 3 + 12.5 + 1.5 + 12.5
1 = 2 = 3 = 4 = 1.5
1 = 2
2 = 251 62 + 253 + 64 + 9
3 = 4 + 1.5
4 = 12.51 + 32 253 4.54 + 5.75
(b) (10%) Express your state variable equations from (a) in state variable matrix format
assuming the output of interest is y = v - w, i.e. = + = + =? =
? =? =?
0 1 0 0 0
=[ 25 6 25 6 ] = [ 9 ] = [1 0 1 0] = [0]
0 0 0 1 1.5
12.5 3 25 4.5 5.75
(c) (5%) Substitute you straight line equation for 3 in the original differential equation to
obtain a linear differential equation.
289
+ 2.4 + 3(300 2000) = 3000
+ 2.4 + 900 = 9000
(d) (5%) The equilibrium value of your linear differential equation should be the same as the
equilibrium value for the original differential equation. Is this the case?
0 + 0 + 900 = 9000
() = 10
(e) (5%) What are the eigenvalues of your linearized differential equation? Time constants?
= 1.2 29.98
1
= = 0.833
1.2
Exam 4.a
1. A hydraulic car lift is shown below. At time t = 0, the valve is opened allowing pressurize
fluid to flow into the cylinder pressurizing the fluid under the piston causing the piston and
car to rise with velocity v.
+ . = ( ) = /
= , /
= . /
290
2. The mass shown below is sitting on a nonlinear spring with the spring force Fs = 10z3 N.
(a) If the mass vibrates with a small amplitude about equilibrium (z=4), obtain a linear
approximation for the differential equation for z by obtaining a straight line
approximation for z3.
+ =
M
z
3. A sliding block system is shown below. A spring connects a swinging bar to the block. A force f is
the input to the system. The differential equations that model the motion of this system
resulting from a certain input f are also given below.
y
y 100 y 50 0.1 f
64 75 y 0
f
291
Exam 4.a Solution
1. A hydraulic car lift is shown below. At time t = 0, the valve is opened allowing
pressurize fluid to flow into the cylinder pressurizing the fluid under the piston causing
the piston and car to rise with velocity v.
+ . = ( ) = /
= , /
= . /
292
+ . (, ). =
.
() = =
( + ()] ( + )
(e)(10%)Check your V(s) using the initial and final value theorems. If doesnt
check, go back and determine what is wrong with part (c).
:()= :()=
.
FVT: ()= = ()= = = .
.
IVT: ()= = ()= = =
+
(f)(3%)How long will it take for the velocity to become constant (within 1%)? 5/49 .
2. The mass shown below is sitting on a nonlinear spring with the spring force Fs = 10z3 N.
(a) (20%)If the mass vibrates with a small amplitude about equilibrium (z=4), obtain a linear
approximation for the differential equation for z by obtaining a straight line
approximation for z3.
+ =
M z3
z
64
0 4 z
293
3. A sliding block system is shown below. A spring connects a swinging bar to the block.
A force f is the input to the system. The differential equations that model the motion of
this system resulting from a certain input f are also given below.
y
y 100 y 50 0.1 f
64 75 y 0
f
2 + 100 50 = 10
2 + 64 75 = 0
From the first equation,
( 2 + 100) 10 = 50( 2 + 100)/50 10/50 =
nd
Into the 2 equation gives
( 2 + 64)[( 2 + 100)/50 10/50] 75 = 0
Or
(0.02 4 + 3.28 2 + 53) = 0.2
Or
10
() = [ 4 ] ()
+ 164 2 + 2650
Exam 4.b
+
1. () = [(+)+] ()
(f) (3%) How long will it take for y to reach this final value within 1%?
294
2. (25%) Fill in the blanks below.
+ +
() =
( + + )
() = + ( + )
3. The input flow to a water tank system is . The equations that model the water heights H1
and H2 and the flow Q between the tanks are as follows:
= ( ) =
= ( ) =
= + ( ) =
Qi
H1 (t )
H 2 (t )
Q
(a) (3%) What are the unknowns?
(c) (3%) What are the initial conditions for your state variables?
(d) (10%) Write the derivative equations for your state variables.
(e) (10%) Express your state variable equations in matrix format assuming Q is the output
of interest.
4. (20%) Find ()
+ + = ()() = ()
295
Exam 4.b Solution
+
1. () = [(+) + ] ()
+ +
() =
( + + )
() = + ( + )
= = = =
3. The input flow to a water tank system is . The equations that model the water
heights H1 and H2 and the flow Q between the tanks are as follows:
= ( ) =
= ( ) =
= + ( ) =
Qi
H1 (t )
H 2 (t )
Q
(a) (3%) What are the unknowns? , ,
296
(b) (6%) Define state variables for this system of equations.
= = =
(c) (3%) What are the initial conditions for your state variables?
( ) = , ( ) = , ( ) =
(d) (10%) Write the derivative equations for your state variables in terms of the
input .
= . .
=
= . . .
(e) (10%) Express your state variable equations in matrix format assuming Q is the output
of interest.
. .
=[ . ] = [ ] = [ ] = []
. . .
4. (20%) Find ()
+ + = ()() = ()
() = | | ( + )
+ + =
= ( + ( + ) [ + ])
| + |
= . ( + + . )
= . ( )
Exam 4.c
1. A. Use the Laplace transform to solve the following differential equations for w(t).
B. In each case, check W(s) using the initial and final value theorems.
C. Also, for (a) using your final equation for w(t), check using w(t) at t = 0 and at t = .
D. Also, in each case determine the time constant(s).
0 t
297
() = + ( + )
a=?
b=?
d=?
f=?
2. A cannon ball is fired at an angle as shown below. The ball exits the cannon with a
velocity 156.2 m/s.
The differential eqn for the vertical displacement is + . ( ) = ( ) = /
and the equation for the horizontal displacement is + . = ( ) = ( ) = /
where = +
(a) (15 pts) Express these equations in state variable format for an ode45 simulation.
(b) (10 pts) Complete the MATLAB code below for ode45 m-files to simulate these equations.
y= ;
w= ;
plot(w,y)
xlabel( )
ylabel( )
function dx=Exam3Eqns(t,x)
dx=zeros( , 1);
dx(1)=
End
298
(c) (5 pts) Draw a sketch of what you think the plot will look like.
3. (5 pts) The Z transform transfer function relating W(z) to the input U(z) for problem
1(b) above for T=0.02 and u(t) piecewise constant is shown below. What is the
discrete time solution to this this differential equation, i.e. wk = ?
. .
() = [ ] ()
. + .
4. (15 pts) For the differential equation in 1(b) above, what are the MATLAB
commands for generating a plot of w(t) using the impulse command?
{()) = ()
{( + )} = ()
{(( + 2)} = 2 ()
{( )} = 1 ()
(( 2)} = 2 ()
5. (20 pts) Express the following differential equation in state variable format
assuming is the output of interest. What are the initial conditions for the state
variables?
= + = +
+ + = + ( ) = ( ) = ( ) =
299
() = () = () =
= . .
0 t
6 + 25 2 12 + 50
() = [ ] = 20
2 + 6 + 25 [( + 3)2 + 42 ]
() = + ( + )
a= 2
b=0
d=3
f=4
Time constant = 0.333 sec.
2. A cannon ball is fired at an angle as shown below. The ball exits the cannon with a velocity
156.2 m/s.
(a) (15 pts) Express these equations in state variable format for an ode45 simulation.
= = = =
= +
= = . = = .
(b) (10 pts) Complete the MATLAB code below for ode45 m-files to simulate these equations.
function dx=Exam3Eqns(t,x)
dx = zeros( 4 , 1);
dx(1) = x(2);
V = sqrt(x(2)^2 +x(4)^2);
dx(2) = - 10 - 0.005*V*x(2);
dx(3) = x(4);
dx(4 )= - 0.0005*V*x(4);
end
(c) (5 pts) Draw a sketch of what you think the plot will look like.
2
0 w
3. (5 pts) The Z transform transfer function relating W(z) to the input U(z) for problem
1(b) above for T=0.02 and u(t) piecewise constant is shown below. What is the
discrete time solution to this this differential equation, i.e. wk = ?
. .
() = [ ] ()
. + .
+ . + . = . + .
= . . + . .
4. (15 pts) For the differential equation in 1(b) above, what are the MATLAB
commands for generating a plot of w(t) using the impulse command?
+ +
() = [ ] =
+ + + + +
+
=
+ + +
301
5. (20 pts) Express the following differential equation in state variable format
assuming is the output of interest. What are the initial conditions for the state
variables?
= + = +
=[ ] = [ ] = [ ] = []
Exam 5.a
1. The differential equation for y in terms of the input u is as follows:
4 + 24 + 100 = 32 + 8 (0 ) = 0.5 (0 ) = 1
u(t)
2
0
t
(a) (10%) What is the transfer function for y?
(b) (10%) What are the eigenvalues?
(c) (10%) What is the undamped natural frequency? What is the damping ratio?
(d) (5%) What is U(s), the Laplace transform of u(t)?
(e) (10%) Find an equation for Y(s), the Laplace transform of y(t). Check your answer using the final
value theorem and the initial value theorem.
(f) (5%) Draw a sketch of your estimate of y(t).
y(t)
0 t
302
2. The modelling equations for the mass spring damper system are shown below in terms of the
force input F.
x
F
+2
3. Consider the following function of s: =
+4
(a) (10%) For s = -2+j4, what is || ?
(b) (10%) For s=-2+j4, what is the angle(a)?
4 + 24 + 100 = 32 + 8 (0 ) = 0.5 (0 ) = 1
u(t)
2
0
t
2+8
(g) (10%) What is the transfer function for y? 2 +6+25
(h) (10%) What are the eigenvalues? 2 + 6 + 25 = ( + 3 + 4)( + 3 4)
Eigenvalues = 3 4
(i) (10%) What is the undamped natural frequency? What is the damping ratio?
= 25 = 5/ sec 2 = 6, = 0.6
(j) (5%) What is U(s), the Laplace transform of u(t)? U(s) = 2/s
(k) (10%) Find an equation for Y(s), the Laplace transform of y(t). Check your answer using the final
value theorem and the initial value theorem.
( 2 0.5 1) + 6( 0.5) + 25 = (2 + 8)
2
( 2 + 6 + 25)() = (2 + 8) + 0.5 + 4
303
0.5 2 + 8 + 16
() =
( 2 + 6 + 25)
16
:()=0 = = 0.64
25
0.5
:()= = = 0.5
1
(l) (5%) Draw a sketch of your estimate of y(t).
y(t)
0.64
0.5
0 t
1.66
4. The modelling equations for the mass spring damper system are shown below in terms of the
force input F.
x
F
304
1
= [ ]
2 2 + 5 + 100
+2
5. Consider the following function of s: = +4
2+4+2 4 4
2. (10%) For s = -2+j4, what is || ? |2+4+4| = = = 0.894
2+4 20
3. (10%) For s=-2+j4, what is the angle(a)?
2+4+2
( ) = (4) (2 + 4) = 1.107 = 0.464
2+4+4 2
Exam 5.b
Bode Diagram
15
10
Magnitude (dB)
System: g
Frequency (rad/s): 2.91
Magnitude (dB): 10
5
-5
0
-45
Phase (deg)
System: g
Frequency (rad/s): 2.91
-90 Phase (deg): -62.1
-135
0
10
Frequency (rad/s)
2. (25%) Suppose you are going to solve the differential equation in part 1 using ode45. Also,
assume that the input in this case is a step with magnitude 0.2 and the initial conditions are y(0-)
= 2 and (0 ) = 0.3. We know that two M-files are needed to perform an ode45 simulation.
Complete the two M-files below to get a plot of y(t).
305
M-file #1
[t,x]=ode45(@exam2,[? ?],[? ?]);
y = ?;
plot(t,y)
xlabel(time, sec.)
ylabel((y(t))
M-file #2
function dx = exam2(t,x)
dx=zeros(?,1);
?
?
?
end
3. The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 2
402 = 02 (0 ) = 5
1 2 = 250 + 25(0 ) = 0
H1 H2
Q
(a) (5%) List the unknowns in these equations. Do the number of equations match the number
of unknowns?
(b) (10%) Laplace transform each of these equations.
(c) (15%) Simplify these equations to a single equation for H2(s). Check your answer using the
initial value theorem.
(d) (5%) Use the final value theorem to solve for the final value of H2(t). Does this value make
sense?
(e) (5%) Draw an estimate plot of H2(t). Showing initial and final values and time to final value.
(f) (10%) Suppose instead of Laplace transforming the original three equations, express them in
state variable format. Define the state variables and write their derivative equations. What
are the initial conditions of the state variables?
M in dB is 20Log10M { ()} = () (0 )
306
Exam 5.b Solution
Bode Diagram
15
10
Magnitude (dB)
System: g
Frequency (rad/s): 2.91
Magnitude (dB): 10
5
-5
0
-45
Phase (deg)
System: g
Frequency (rad/s): 2.91
-90 Phase (deg): -62.1
-135
0
10
Frequency (rad/s)
2. (25%) Suppose you are going to solve the differential equation in part 1 using ode45. Also,
assume that the input in this case is a step with magnitude 0.2 and the initial conditions are y(0-)
= 2 and (0 ) = 0.3. We know that two M-files are needed to perform an ode45 simulation.
Complete the two M-files below to get a plot of y(t).
1 = 2 = 1.01
1 = 2 + 1.01 2 = 91 1.012 + 7.98
Time constant = 2 sec
M-file #1
[t,x]=ode45(@exam2,[0 10],[2 0.3]);
y = x(:,1);
plot(t,y)
xlabel(time, sec.)
ylabel((y(t))
M-file #2
function dx = exam2(t,x)
dx=zeros(2,1);
307
u=0.2;
dx(1)=x(2)+1.01*u;
dx(2)=-9*x(1)-1.01*x(2)+7.98*u
end
3. The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 2
402 = 02 (0 ) = 5
1 2 = 250 + 25(0 ) = 0
5 H2
H1 H2 4
Q
t 50,000
(g) (5%) List the unknowns in these equations. Do the number of equations match the number
of unknowns? H1, H2, and Q 3 equations and 3 unknowns
(i) (15%) Simplify these equations to a single equation for H2(s). Check your answer using the
initial value theorem.
80012502 +800125+240 52 +0.5+0.0012
2 () = (8002502 +80025+60)
= (2 +0.1+0.0003) :2 ()= = 5 correct
(j) (5%) Use the final value theorem to solve for the final value of H2(t). Does this make sense?
:2 ()=0 = 4 makes sense since between initial tank levels.
(k) (5%) Draw an estimate plot of H2(t). Showing initial and final values and time to final value.
Largest time constant = 10,000 sec. So, time to steady state = 50,000 sec. See above.
(l) (10%) Suppose instead of Laplace transforming the original three equations, express them in
state variable format. Define the state variables and write their derivative equations. What
are the initial conditions of the state variables?
308
Exam 5.c
1. (15%) Use Laplace transform to solve the following differential equation for y(t). Be sure to
check your solution at t = 0 and at t = .
2 + 20 = 40(0 ) = 1
2. Consider the differential equation for w(t) shown below with input u(t).
+ 18 + 105 + 250 = 75 + 500
(a) (5%) What is the transfer function relating W(s) to U(s)?
(b) (10%) Assume 3 + 18 2 + 105 + 250 = ( + 10)[( + 4)2 + 32 ]
What are the eigenvalues? What are the time constants? Damping ratio?
(c) (10%) Suppose u(t) is a step input with magnitude of 3.
Also, assume (0 ) = 0, (0 ) = 0, (0 ) = 2.
Find an equation for W(s); check your answer using the initial value and final value
theorems.
(d) (15%) It can be shown for the correct W(s) in (c) that the inverse Laplace w(t) is of the
following form:
() = + + sin( + )
=?
=?
=?
=?
=?
(e) (5%) Using W(s) from (c), write the MATLAB commands for getting a plot of w(t) without
first finding an equation for w(t).
(f) (15%) Use the simulation diagram approach to express the differential equation in state
variable format, i.e. = + = + Note, is the output of interest.
3. The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 2
402 = 02 (0 ) = 5
1 2 = 25
309
H1 H2
Q
a. (5%) List the unknowns in these equations. Do the number of equations match the
number of unknowns?
c. (10%) Simplify these equations to a single equation for Q(s). Check your answer using
the initial and final value theorems.
2 + 20 = 40(0 ) = 1
20 +
() = () = 2 10 (0) = 1() = 2
( + 10)
1. Consider the differential equation for w(t) shown below with input u(t).
+ 18 + 105 + 250 = 75 + 500
(g) (5%) What is the transfer function relating W(s) to U(s)?
75 + 500
() =
3 + 18 2 + 105 + 250
(h) (10%) Assume 3 + 18 2 + 105 + 250 = ( + 10)[( + 4)2 + 32 ]
What are the eigenvalues? What are the time constants? Damping ratio?
Eigenvalues = -10 and -4 3
Time constants = 0.1 and 0.25
Damping ratio = 0.8
Find an equation for W(s); check your answer using the initial value and final value
theorems.
227 + 1500
() = ()=0 = 6()= = 0
( 3 + 18 2 + 105 + 250)
310
(j) (15%) It can be shown for the correct W(s) in (c) that the inverse Laplace w(t) is of the
following form:
() = + + sin( + )
=6
= 10
=4
=3
(k) (5%) Using W(s) from (c), write the MATLAB commands for getting a plot of w(t) without
first finding an equation for w(t).
1 = 2 = 3 = 75
0 1 0 0
= [ 0 0 1 ] = [ 75 ] = [0 0 1] = [75]
250 105 18 850
What are the initial conditions for your state variables if
(0 ) = 0 (0 ) = 0 (0 ) = 2(0 ) = 0
1 (0 ) = 02 (0 ) = 03 (0 ) = 2
2. The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 2
402 = 02 (0 ) = 5
1 2 = 25
H1 H2
Q
(m) (5%) List the unknowns in these equations. Do the number of equations match the number
of unknowns? H1, H2, Q
(n) (10%) Laplace transform each of these equations.
20(1 2) = 0 40(2 5) = 01 2 = 25
311
(o) (10%) Simplify these equations to a single equation for Q(s). Check your answer using the
initial value and final value theorems. The theorems confirm the equation for Q(s).
120
() = ()= = ()=0 = 0()=0 = ()= = 0.1
1000 + 3
Exam 6.a
4 + 24 + 100 = 32 + 8 (0 ) = 0.5 (0 ) = 1
u(t)
2
0
t
(a) (10%) What is the transfer function for y?
(b) (10%) What are the eigenvalues?
(c) (10%) What is the undamped natural frequency? What is the damping ratio?
(d) (5%) What is U(s), the Laplace transform of u(t)?
(e) (10%) Find an equation for Y(s), the Laplace transform of y(t). Check your answer using the
final value theorem and the initial value theorem.
0 t
2. The modelling equations for the mass spring damper system are shown below in terms of the
force input F.
312
spring damper spring force: Fs 20 100 x
damper force: Fd 5 x
mass force balance on mass: 2 x Fs Fd F 20 0
x
F
() = ()( ) = () (0 )( ) = 2 () (0 ) (0 )
FVT: () = ()=0 IVT: (0+ ) = ()=
4 + 24 + 100 = 32 + 8 (0 ) = 0.5 (0 ) = 1
u(t)
2
0
t
2+8
(b) (10%) What is the transfer function for y? 2 +6+25
(c) (10%) What are the eigenvalues? 2 + 6 + 25 = ( + 3 + 4)( + 3 4)
Eigenvalues = 3 4
(d) (10%) What is the undamped natural frequency? What is the damping ratio?
= 25 = 5/ sec 2 = 6, = 0.6
(e) (5%) What is U(s), the Laplace transform of u(t)? U(s) = 2/s
(f) (10%) Find an equation for Y(s), the Laplace transform of y(t). Check your answer using the final
value theorem and the initial value theorem.
( 2 0.5 1) + 6( 0.5) + 25 = (2 + 8)
2
( 2 + 6 + 25)() = (2 + 8) + 0.5 + 4
0.5 2 + 8 + 16
() =
( 2 + 6 + 25)
313
16
:()=0 = = 0.64
25
0.5
:()= = = 0.5
1
(g) (5%) Draw a sketch of your estimate of y(t).
y(t)
0.64
0.5
0 t
1.66
(h) The modelling equations for the mass spring damper system are shown below in terms of the
force input F.
x
F
+2
(l) Consider the following function of s: =
+4
2+4+2 4 4
(c) (10%) For s = -2+j4, what is || ? |2+4+4| = = = 0.894
2+4 20
Exam 6.b
1. (25%) The differential equation for a system is 2 + 2.02 + 18 = 2.02 + 18
If the input is () = 2sin(2.91), we know that y(t) will eventually become a sine function. i.e.
() = ( + ) The MATLAB code below was used to generate the bode plot also shown.
What are A, , and ?
Bode Diagram
15
10
Magnitude (dB)
System: g
Frequency (rad/s): 2.91
Magnitude (dB): 10
5
-5
0
-45
Phase (deg)
System: g
Frequency (rad/s): 2.91
-90 Phase (deg): -62.1
-135
0
10
Frequency (rad/s)
2. (25%) Suppose you are going to solve the differential equation in part 1 using ode45. Also,
assume that the input in this case is a step with magnitude 0.2 and the initial conditions are y(0-)
= 2 and (0 ) = 0.3. We know that two M-files are needed to perform an ode45 simulation.
Complete the two M-files below to get a plot of y(t).
M-file #1
[t,x]=ode45(@exam2,[? ?],[? ?]);
315
y = ?;
plot(t,y)
xlabel(time, sec.)
ylabel((y(t))
M-file #2
function dx = exam2(t,x)
dx=zeros(?,1);
end
3. The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 2
402 = 02 (0 ) = 5
1 2 = 250 + 25(0 ) = 0
H1 H2
Q
3.1 (5%) List the unknowns in these equations. Do the number of equations match the number of
unknowns?
3.2 (10%) Laplace transform each of these equations.
3.3 (15%) Simplify these equations to a single equation for H2(s). Check your answer using the initial
value theorem.
3.4 (5%) Use the final value theorem to solve for the final value of H2(t). Does this value make
sense?
3.5 (5%) Draw an estimate plot of H2(t). Showing initial and final values and time to final value.
316
3.6 (10%) Suppose instead of Laplace transforming the original three equations, express them in
state variable format. Define the state variables and write their derivative equations. What are
the initial conditions of the state variables?
M in dB is 20Log10M { ()} = () (0 )
Bode Diagram
15
10
Magnitude (dB)
System: g
Frequency (rad/s): 2.91
Magnitude (dB): 10
5
-5
0
-45
Phase (deg)
System: g
Frequency (rad/s): 2.91
-90 Phase (deg): -62.1
-135
0
10
Frequency (rad/s)
317
xlabel(time, sec.)
ylabel((y(t))
M-file #2
function dx = exam2(t,x)
dx=zeros(2,1);
u=0.2;
dx(1)=x(2)+1.01*u;
dx(2)=-9*x(1)-1.01*x(2)+7.98*u
end
3. The equations for the water flowing through a long line between two tanks and the height of
the water in the tanks are as follows:
201 = 01 (0 ) = 2
402 = 02 (0 ) = 5
1 2 = 250 + 25(0 ) = 0
5 H2
H1 H2 4
Q
t 50,000
3.1 (5%) List the unknowns in these equations. Do the number of equations match the number
of unknowns? H1, H2, and Q 3 equations and 3 unknowns
3.3 (15%) Simplify these equations to a single equation for H2(s). Check your answer using the
initial value theorem.
80012502 +800125+240 52 +0.5+0.0012
2 () = = :2 ()= = 5 correct
(8002502 +80025+60) (2 +0.1+0.0003)
3.4 (5%) Use the final value theorem to solve for the final value of H2(t). Does this make sense?
:2 ()=0 = 4 makes sense since between initial tank levels.
3.5 (5%) Draw an estimate plot of H2(t). Showing initial and final values and time to final value.
Largest time constant = 10,000 sec. So, time to steady state = 50,000 sec. See above.
318
3.6 (10%) Suppose instead of Laplace transforming the original three equations, express them in
state variable format. Define the state variables and write their derivative equations. What
are the initial conditions of the state variables?
1 = 1 1 (0) = 22 = 2 2 (0) = 53 = 3 (0) = 0
3 3
1 = 2 = 3 = 0.0041 0.0042 0.13
20 40
Exam 6.c
1. (15%) Use Laplace transform to solve the following differential equation for y(t). Be sure to
check your solution at t = 0 and at t = .
2 + 20 = 40(0 ) = 1
2. Consider the differential equation for w(t) shown below with input u(t).
{} = (){ } = () (0 ){} = 2 () (0 ) (0 )
{} = 3 () 2 (0 ) (0 ) (0 )
Find an equation for W(s); check your answer using the initial value and final value
theorems.
(d) (15%) It can be shown for the correct W(s) in (c) that the inverse Laplace w(t) is of the
following form:
() = + + sin( + )
=?
=?
=?
=?
=?
(e) (5%) Using W(s) from (c), write the MATLAB commands for getting a plot of w(t) without
first finding an equation for w(t).
319
(f) (15%) Use the simulation diagram approach to express the differential equation in state
variable format, i.e. = + = + Note, is the output of interest.
201 = 01 (0 ) = 2
402 = 02 (0 ) = 5
1 2 = 25
H1 H2
Q
3.a (5%) List the unknowns in these equations. Do the number of equations match the
number of unknowns?
3.b (10%) Laplace transform each of these equations.
3.c (10%) Simplify these equations to a single equation for Q(s). Check your answer
using the initial and final value theorems.
2 + 20 = 40(0 ) = 1
20 +
() = () = 2 10 (0) = 1() = 2
( + 10)
2. Consider the differential equation for w(t) shown below with input u(t).
+ 18 + 105 + 250 = 75 + 500
a. (5%) What is the transfer function relating W(s) to U(s)?
75 + 500
() =
3 + 18 2 + 105 + 250
b. (10%) Assume 3 + 18 2 + 105 + 250 = ( + 10)[( + 4)2 + 32 ]
What are the eigenvalues? What are the time constants? Damping ratio?
320
Eigenvalues = -10 and -4 3
Time constants = 0.1 and 0.25
Damping ratio = 0.8
Find an equation for W(s); check your answer using the initial value and final value
theorems.
227 + 1500
() = ()=0 = 6()= = 0
( 3 + 18 2 + 105 + 250)
d. (15%) It can be shown for the correct W(s) in (c) that the inverse Laplace w(t) is of the
following form:
() = + + sin( + )
=6
= 10
=4
=3
e. (5%) Using W(s) from (c), write the MATLAB commands for getting a plot of w(t) without
first finding an equation for w(t).
1 = 2 = 3 = 75
0 1 0 0
= [ 0 0 1 ] = [ 75 ] = [0 0 1] = [75]
250 105 18 850
What are the initial conditions for your state variables if
(0 ) = 0 (0 ) = 0 (0 ) = 2(0 ) = 0
1 (0 ) = 02 (0 ) = 03 (0 ) = 2
3. The equations for the water flowing through a long line between two tanks and the height
of the water in the tanks are as follows:
201 = 01 (0 ) = 2
402 = 02 (0 ) = 5
321
1 2 = 25
H1 H2
Q
a. (5%) List the unknowns in these equations. Do the number of equations match the
number of unknowns? H1, H2, Q
b. (10%) Laplace transform each of these equations.
20(1 2) = 0 40(2 5) = 01 2 = 25
c. (10%) Simplify these equations to a single equation for Q(s). Check your answer using
the initial value and final value theorems. The theorems confirm the equation for Q(s).
120
() = ()= = ()=0 = 0()=0 = ()= = 0.1
1000 + 3
322
Chapter 9 MATLAB M-files
% function G=pfract(Num,Den)
% The command pfract(Num,Den)generates the partial fractions
% of a ratio of polynomials with numerator Num and denominator Den.
% The poles cannot be repeated but may be real or complex.
% The output will be the partial fractions of Num/Den plus any nonzero
% remainder if the numerator order is equal to the denominator order.
% Note, the partial fraction outputs erroneously refer to input 1,
% input 2, etc; ignore these comments.
function G=pfract(Num,Den)
n=length(Den)-1;
[RR,PP,K]=residue(Num,Den);
if K~=0 % Check to see if there is a remainder.
'Remainder', K
end
m=1;
q=1;
P(n)=PP(n);
R(n)=RR(n);
while m<=n
P(q)=PP(m);
R(q)=RR(m);
q=q+1;
if imag(PP(m))~= 0 % Check to see if this pole is complex.
m=m+2;
else
m=m+1;
end
end
qn=q-1;
I=1;
while I<=qn
if imag(P(I))==0 % Check to see if this pole is real.
G(I)=tf(R(I),[1 -P(I)]); % Use this for the partial fraction if the pole is real.
I=I+1;
else % Use this for the partial fraction if the pole is complex.
G(I)=tf([2*real(R(I)) -2*(real(R(I))*real(P(I))+imag(R(I))*imag(P(I)))],[1 -2*real(P(I))
abs(P(I))^2]);
I=I+1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323
function [f,t] = PulseSeries(T,m,F,N,NumPPP)
% function [f,t] = PulseSeries(T,m,F,N,NumPPP)
% T=pulse width, sec.
% m is an integer
% mT=time between pulses, sec. (period of function)
% N=number of pulses to be generated
% NumPPP=number of points per pulse
dt=T/NumPPP;% time increment, sec.
for L=1:NumPPP
f(L)=F;
end
for L=NumPPP+1:m*NumPPP-1
f(L)=0;
end
for k=1:N-1
for L=(m*k)*NumPPP:(m*k+1)*NumPPP
f(L)=F;
end
for L=(m*k+1)*NumPPP+1:(m*(k+1))*NumPPP-1
f(L)=0;
end
end
%length(t)
%length(f)
plot(t,f,'r','Linewidth',4)
xlabel('time, sec.')
ylabel('pulse function amplitude')
axis([0 N*m*T+T/2 0 1.1*F])
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function [numa,dena]=tfapprox(num,den,dorder,wmin,wmax)
%Obtaining lower order transfer function approximations
%Transfer approximation program
%[numa,dena]=tfapprox(num,den,dorder,wmin,wmax)
%Generates a transfer function approximation with numerator "numa" and
%denominator "dena" of desired order "dorder"
%over the frequency range of wmin rad/sec to wmax rad/sec starting with
%a transfer function with numerator "num" and denominator "den".
%The approximation is achieved by curve fitting the original transfer
%function frequency response over the specified frequency range.
%file name "tfapprox.m"
%num=numerator polynomial of original transfer function
%den=denominator polynomial of original transfer function
%wmin=minimum frequency (rad/sec) for a good approximation
%wmax=maximum frequency (rad/sec) for a good approximation
%numa=numerator polynomial of the transfer function approximation
%dena=denominator polynomial of the transfer function approximation
%dorder=desired order of the transfer function approximation
function [numa,dena]=tfapprox(num,den,dorder,wmin,wmax)
324
warning off
norder=dorder-1;
Gorig=tf(num,den);
[mag,phase,w]=bode(Gorig,{wmin,wmax});
H=freqs(num,den,w);
[numa,dena]=invfreqs(H,w,norder,dorder);
Gapprox=tf(numa,dena)
wm=2*wmax;
bode(Gorig,b,Gapprox,r--,{wmin,wm})
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
error(nargchk(2,3,nargin));
error(nargoutchk(0,2,nargout));
if ~any(size(b)<=1) | ~any(size(a)<=1),
error('The numerator and denominator must be vectors.');
end
[b,a] = tfchk(b,a);
if nargin == 2,
w = 200;
end
if length(w) == 1,
wlen = w;
w_long = freqint(b,a,wlen);
% need to interpolate long frequency vector:
xi = linspace(1,length(w_long),wlen).';
325
w = 10.^interp1(1:length(w_long),log10(w_long),xi,'linear');
end
s = j*w;
hh = polyval(b,s) ./ polyval(a,s);
if nargout == 0,
newplot;
mag = abs(hh); phase = angle(hh)*180/pi;
subplot(211),loglog(w,mag),set(gca,'xgrid','on','ygrid','on')
set(gca,'xlim',[w(1) w(length(w))])
xlabel('Frequency (rad/s)')
ylabel('Magnitude')
ax = gca;
subplot(212), semilogx(w,phase),set(gca,'xgrid','on','ygrid','on')
set(gca,'xlim',[w(1) w(length(w))])
xlabel('Frequency (rad/s)')
ylabel('Phase (degrees)')
axes(ax)
elseif nargout == 1,
h = hh;
elseif nargout == 2,
h = hh;
ww = w;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function w=freqint(a,b,c,d,npts)
%FREQINT Auto-ranging algorithm for Bode frequency response
% W=FREQINT(A,B,C,D,Npts)
% W=FREQINT(NUM,DEN,Npts)
[na,ma] = size(a);
% Note: this algorithm does not handle zeros greater than 1e5
ez=[ep(find(imag(ep)>=0));tz(find(abs(tz)<1e5&imag(tz)>=0))];
326
% Round first and last frequencies to nearest decade
integ = abs(ez)<1e-10; % Cater for systems with pure integrators
highfreq=round(log10(max(3*abs(real(ez)+integ)+1.5*imag(ez)))+0.5);
lowfreq=round(log10(0.1*min(abs(real(ez+integ))+2*imag(ez)))-0.5);
function [b,a]=invfreqs(g,w,varargin)
%INVFREQS Analog filter least squares fit to frequency response data.
% [B,A] = INVFREQS(H,W,nb,na) gives real numerator and denominator
% coefficients B and A of orders nb and na respectively, where
% H is the desired complex frequency response of the system at frequency
% points W, and W contains the frequency values in radians/s.
% INVFREQS yields a filter with real coefficients. This means that it is
% sufficient to specify positive frequencies only; the filter fits the data
% conj(H) at -W, ensuring the proper frequency domain symmetry for a real
% filter.
%
% [B,A]=INVFREQS(H,W,nb,na,Wt) allows the fit-errors to the weighted
% versus frequency. LENGTH(Wt)=LENGTH(W)=LENGTH(H).
% Determined by minimization of sum |B-H*A|^2*Wt over the freqs in W.
%
% [B,A] = INVFREQS(H,W,nb,na,Wt,ITER) does another type of fit:
% Sum |B/A-H|^2*Wt is minimized with respect to the coefficients in B and
% A by numerical search in at most ITER iterations. The A-polynomial is
% then constrained to be stable. [B,A]=INVFREQS(H,W,nb,na,Wt,ITER,TOL)
% stops the iterations when the norm of the gradient is less than TOL.
% The default value of TOL is 0.01. The default value of Wt is all ones.
% This default value is also obtained by Wt=[].
%
% [B,A]=INVFREQS(H,W,nb,na,Wt,ITER,TOL,'trace') provides a textual
% progress report of the iteration.
327
%
% [B,A] = INVFREQS(H,W,'complex',NB,NA,...) creates a complex filter. In
% this case, no symmetry is enforced.
%
% See also FREQZ, FREQS, INVFREQZ.
% calling sequence is
%function [b,a]=invfreqs(g,w,nb,na,wf,maxiter,tol,pf)
% OR
%function [b,a]=invfreqs(g,w,'complex',nb,na,wf,maxiter,tol,pf)
error(nargchk(4,9,nargin))
if isstr(varargin{1})
realStr = lower(varargin{1});
varargin(1) = [];
else
realStr = 'real';
end
gaussFlag = length(varargin)>3; % run Gauss-Newton algorithm or not?
if length(varargin)<6
varargin{6} = []; % pad varargin with []'s
end
[nb,na,wf,maxiter,tol,pf] = deal(varargin{:});
switch realStr
case 'real'
realFlag = 1;
case 'complex'
realFlag = 0;
otherwise
warning(...
sprintf('String ''%s'' not recognized. I assume you meant ''complex''.',...
realStr))
realFlag = 0;
end
nb=nb+nk+1;
if isempty(pf)
verb=0;
elseif (strcmp(pf,'trace')),
verb=1;
else
error(['Trace flag ''' pf ''' not recognizable']);
end
if isempty(wf),wf=ones(length(w),1);end
wf=sqrt(wf);
328
if length(g)~=length(w),error('The lengths of H and W must coincide'),end
if length(wf)~=length(w),error('The lengths of Wt and W must coincide'),end
if any( w<0 ) & realFlag
warnStr = sprintf(...
['W has values which are negative. INVFREQS aliases such\n' ...
'values into positive ones and designs a real filter.\n' ...
'To design a complex filter, use the ''complex'' flag.']);
warning(warnStr)
end
nm=max(na+1,nb+nk);
indb=nb:-1:1; indg=na+1:-1:1; inda=na:-1:1;
OM=ones(1,length(w));
for kom=1:nm-1
OM=[OM;(i*w).^kom];
end
%
% Estimation in the least squares case:
%
Dva=(OM(inda,:).').*(g*ones(1,na));
Dvb=-(OM(indb,:).');
D=[Dva Dvb].*(wf*ones(1,na+nb));
R=D'*D;
Vd=D'*((-g.*OM(na+1,:).').*wf);
if realFlag
R=real(R);
Vd=real(Vd);
end
th=R\Vd;
a=[1 th(1:na).'];b=[zeros(1,nk) th(na+1:na+nb).'];
if ~gaussFlag,return,end
GC=((b*OM(indb,:))./(a*OM(indg,:))).';
e=(GC-g).*wf;
Vcap=e'*e; t=[a(2:na+1) b(nk+1:nk+nb)].';
if (verb),
329
clc, disp([' INITIAL ESTIMATE'])
disp(['Current fit: ' num2str(Vcap)])
disp(['par-vector'])
disp(t)
end
%
% ** the minimization loop **
%
gndir=2*tol+1;l=0;st=0;
while [norm(gndir)>tol l<maxiter st~=1]
l=l+1;
% * compute gradient *
D31=(OM(inda,:).').*(-GC./((a*OM(indg,:)).')*ones(1,na));
D32=(OM(indb,:).')./((a*OM(indg,:)).'*ones(1,nb));
D3=[D31 D32].*(wf*ones(1,na+nb));
% * compute Gauss-Newton search direction
e=(GC-g).*wf;
R=D3'*D3;
Vd=D3'*e;
if realFlag
R=real(R);
Vd=real(Vd);
end
gndir=R\Vd;
% * search along the gndir-direction *
ll=0;,k=1;V1=Vcap+1;
while [V1 > Vcap ll<20],
t1=t-k*gndir; if ll==19,t1=t;end
a=[1 t1(1:na).'];
b=[zeros(1,nk) t1(na+1:na+nb).'];
a=apolystab(a,realFlag); % Stabilizing the denominator
t1(1:na)=a(2:na+1).';
GC=((b*OM(indb,:))./(a*OM(indg,:))).';
V1=((GC-g).*wf)'*((GC-g).*wf);
if (verb),
home, disp(int2str(ll))
end;
k=k/2;
ll=ll+1; if ll==10, gndir=Vd/norm(R)*length(R);k=1;end
if ll==20,st=1;end
end
if (verb),
home
disp([' ITERATION # ' int2str(l)])
disp(['Current fit: ' num2str(V1) ' Previous fit: ' num2str(Vcap)])
disp(['Current par prev.par GN-dir'])
disp([t1 t gndir])
disp(['Norm of GN-vector: ' num2str(norm(gndir))])
if st==1,
disp(['No improvement of the criterion possible along the '...
'search ''direction''']),
disp('Iterations therefore terminated'),
end
330
end
t=t1; Vcap=V1;
end
function a = apolystab(a,realFlag)
%APOLYSTAB Stabilize filter, analog
% inputs: a - denominator polynomial
% realFlag - 1 for real, 0 for complex
% returns stabilized denoninator polynomial
if length(a)>0
v=roots(a);
vind=find(real(v)>0);
v(vind)=-v(vind);
a=poly(v);
if realFlag
a=real(a);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Necessary inputs to run the program; you may have to guess some of these
% at first until you see the frequency response and decipher the necessary
% frequency range
dorder=26;wmin=0.001;wmax=15000;wminplot=100;
norder=dorder-1;
wmaxplot=1.25*wmax;
nd=ceil(log10(wmax)-log10(wmin));%Determines the number of decades in the frequency range and rounds
up to the next integer
w=logspace(log10(wmin),log10(wmax),1000*nd);%Generates at least 1000 points per decade
Lw=length(w);
for k=1:Lw
s(k)=w(k)*1i;
[H(k)]=PressureTransducerTF(s(k));
end
[maxval,indmax]=lmax(abs(H),2);
if length(indmax)*2>dorder
Imid=floor((indmax(floor(dorder/2))+indmax(floor(dorder/2)+1))/2);% calculates freq. index between last
desirable peak and next peak
Wmax=w(Imid);%new max frequency for curve fitting
wmaxplot=1.25*Wmax;%new max frequency for plotting
nd=ceil(log10(Wmax)-log10(wmin));%Determines the number of decades in the frequency range and
rounds up to the next integer
w=logspace(log10(wmin),log10(Wmax),1000*nd);%Generates at least 1000 points per decade
Lw=length(w);
clear H s
for k=1:Lw
s(k)=w(k)*1i;
[H(k)]=PressureTransducerTF(s(k));
331
end
end
wt=ones(1,Lw);%weighting terms for curve fit
[numa,dena]=invfreqs(H,w,norder,dorder,wt,100);%curve fitting with 100 attempts if necessary
Gapprox=tf(numa,dena);%linear transfer function approximation from curve fitting frequency response
damp(Gapprox)%gives eigenvalues of the transfer function
DCGain=dcgain(Gapprox)% comparing the dcgain of the approximation and the original transfer functions
% helps to determine if wmin was low enough
%
% Generate Freq. Resp. plots to determine the accuracy of curve fit.
if wminplot>=wmaxplot, error('wmin is too small; very low non-resonant peaks are messing up the
calcualtions. Increase wmin and try again.'),end;
ndp=ceil(log10(wmaxplot)-log10(wminplot));%Determines the number of decades in the plotting frequency
range and rounds up to the next integer
wp=logspace(log10(wminplot),log10(wmaxplot),500*ndp);%Generates at least 100 points per decade for the
plots
Lwp=length(wp);
Hc=freqs(numa,dena,wp);%generates frequency response of the computed transfer function
MHc=20*log10(abs(Hc));%magnitudes of the frequency response in dB
AHc=angle(Hc)*180/pi;%angles of the frequency response in degrees
clear H s
% recompute the original function with same frequencies used for the transfer function approximation
for k=1:Lwp
s(k)=wp(k)*1i;
[H(k)]=PressureTransducerTF(s(k));
end
MH=20*log10(abs(H));
AH=angle(H)*180/pi;
% Output portion of program requiring editing for plot axes and time duration
figure
semilogx(wp,AH,'k',wp,AHc,'r:','LineWidth',2)
title('Phase Angle Comparison Plots')
%xlabel('Frequency, rad/sec');ylabel(' Phase Angle, degrees');
xlabel('Frequency, rad/sec ')
ylabel('Phase Angle, degrees')
legend('Original function','Approximation','Location','Best')
grid on
grid minor
figure
semilogx(wp,MH,'k',wp,MHc,'r:','LineWidth',2)
xlabel('Frequency, rad/sec ')
ylabel('Transfer Function Magnitude, dB')
legend('Original function','Approximation','Location','Best')
title('Magnitude Comparison Plots')
grid on
grid minor
figure
[y,t]=step(Gapprox,'r');
plot(t,y,'r','LineWidth',2)
title('Distortion of pressure measurement due to the presence of the line')
ylabel('Normalized transducer pressure, P_t/P_s')
xlabel('Time, sec.')
figure
[y,t]=step(Gapprox,0.05,'r');
332
plot(t,y,'r','LineWidth',2)
title('Distortion of pressure measurement but with a reduced time scale')
ylabel('Normalized transducer pressure, P_t/P_s')
xlabel('Time, sec.')
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
333