Sunteți pe pagina 1din 66

Table of Contents

1 Introduction to Simulink .................................................................................................11

1.1
1.2
1.3
1.4
1.5
1.6

Simulink and its Relation to MATLAB .....................................................................11


Modeling an Electric Circuit ......................................................................................11
Modeling a FourthOrder Differential Equation....................................................114
Modeling the Solution of Three Equations with Three Unknowns .......................118
Representing a Model as a Subsystem ......................................................................120
Simulink Demos .......................................................................................................120

Mathematical Applications .............................................................................................21


2.1
2.2
2.3
2.4
2.5
2.6

Bouncing Ball..............................................................................................................21
Linear Programming ...................................................................................................23
Moving Ladder ..........................................................................................................210
Conical Water Reservoir........................................................................................... 212
Comparison of Alternate Proposals.......................................................................... 215
Valuation of a Depleting Asset .................................................................................219

Dynamics Applications ....................................................................................................31


3.1
3.2
3.3
3.4
3.5
3.6

An Application of Newtons Second Law ................................................................... 3-1


Ball Thrown Vertically Upward................................................................................... 3-3
Barge Pulled by Horse Teams ...................................................................................... 3-8
Rated Speed of an Automobile on a Highway Curve ............................................... 3-10
Train Traveling on a 3 Per Cent Grade..................................................................... 3-12
Spring with Upper End Fastened to a Rigid Support ............................................... 3-17

Thermodynamics and Fluid Mechanics Applications ...................................................41


4.1
4.2
4.3
4.4
4.5

Rise of a Liquid in a Capillary Tube ..........................................................................41


An Application of a Simplified Form of the Bernoulli Equation..............................43
Takeoff Speed for an Aircraft .....................................................................................44
An Application of the Bulk Modulus.........................................................................46
Calculation of Fluid Flow in an Open Channel ...................................................... l47

Assortment of Math and Engineering Applications......................................................51


5.1
5.2
5.3
5.4
5.5
5.6

Chemical Solutions ....................................................................................................51


Heat Flow....................................................................................................................53
Cantilever Beam Deflection ......................................................................................5 4
Tractrix Curve Example .............................................................................................56
Bessel Differential Equation ......................................................................................58
Van der Pol Differential Equation .............................................................................59

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

5.7 Simple Pendulum..................................................................................................... 511


5.8 Simple Oscillator...................................................................................................... 513
5.9 ZeroOrder Hold and FirstOrder Hold as Reconstructors .................................. 514
5.10 Direct Form Realizations of a Digital Filter ........................................................... 516
5.11 Series Form Realization of a Digital Filter ............................................................. 518
5.12 Parallel Form Realization of a Digital Filter........................................................... 520
5.13 3bit Up / Down Counter..................................................................................... 523
5.14 4bit Ring Counter ................................................................................................ 524
5.15 MassSpring-Dashpot ............................................................................................. 525
5.16 Cascaded MassSpring System............................................................................... 528
5.17 Mechanical Accelerometer...................................................................................... 529
5.18 Feedback Control Systems...................................................................................... 530
5.19 Electric Circuit in Phasor Form ............................................................................. 532
5.20 Application of the Superposition Principle ........................................................... 534
5.21 Discrete Time Integration with Variable Amplitude Input ................................... 537
5.22 SFunction Example 1 ........................................................................................... 539
5.23 SFunction Example 2 ........................................................................................... 541
5.24 Concluding Remarks .............................................................................................. 544

ii

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Appendixes
A Introduction to MATLAB .......................................................................................... A1

B
C

A.1 MATLAB and Simulink..................................................................................... A1


A.2 Command Window.................................................................................................. A1
A.3 Roots of Polynomials................................................................................................ A3
A.4 Polynomial Construction from Known Roots......................................................... A4
A.5 Evaluation of a Polynomial at Specified Values....................................................... A5
A.6 Rational Polynomials................................................................................................ A7
A.7 Using MATLAB to Make Plots ................................................................................. A9
A.8 Subplots .................................................................................................................. A16
A.9 Multiplication, Division, and Exponentiation....................................................... A17
A.10 Script and Function Files ...................................................................................... A25
A.11 Display Formats ..................................................................................................... A29

Masked Subsystems ......................................................................................................... B1


B.1
B.2
B.3
B.4

Masks Defined .......................................................................................................... B1


Advantages Using Masked Subsystems..................................................................... B1
Mask Features ........................................................................................................... B1
Creating a Masked Subsystem .................................................................................. B2

Commonly Used .............................................................................................................. C1


C.1 Inport, Outport, and Subsystem.............................................................................. C1
C.2 Ground..................................................................................................................... C4
C.3 Terminator ............................................................................................................... C6
C.4 Constant and Product.............................................................................................. C7
C.5 Scope ........................................................................................................................ C9
C.6 Bus Creator and Bus Selector ................................................................................ C10
C.7 Mux and Demux .................................................................................................... C18
C.8 Switch ..................................................................................................................... C21
C.9 Sum......................................................................................................................... C23
C10 Gain........................................................................................................................ C25
C.11 Relational Operator .............................................................................................. C26
C.12 Logical Operator ................................................................................................... C27
C.13 Saturation.............................................................................................................. C28
C.14 Integrator............................................................................................................... C30
C.15 Unit Delay ............................................................................................................. C35
C.16 DiscreteTime Integrator...................................................................................... C37
C.17 Data Types and Data Type Conversion................................................................ C40
C.18 Vector Concatenate .............................................................................................. C49

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

iii

ContinuousTime ........................................................................................................... D1
D.1 Derivative ................................................................................................................. D1
D.2 Integrator.................................................................................................................. D6
D.3 Integrator Limited.................................................................................................... D6
D.4 Integrator Second Order.......................................................................................... D8
D.5 Integrator Second Order Limited .......................................................................... D11
D.6 PID Controller ....................................................................................................... D12
D.7 PID Controller (2DOF) ......................................................................................... D14
D.8 StateSpace ............................................................................................................ D19
D.9 Transfer Fcn ........................................................................................................... D22
D.10 ZeroPole .............................................................................................................. D25
D.11 Transport Delay, Variable Time Delay, Variable Transport Delay ...................... D29

Discontinuities .................................................................................................................E1
E.1 Saturation................................................................................................................... E1
E.2 Saturation Dynamic ................................................................................................... E4
E.3 Dead Zone.................................................................................................................. E5
E.4 Dead Zone Dynamic .................................................................................................. E6
E.5 Rate Limiter ............................................................................................................... E8
E.6 Rate Limiter Dynamic.............................................................................................. E10
E.7 Backlash.................................................................................................................... E11
E.8 Relay ......................................................................................................................... E13
E.9 Quantizer.................................................................................................................. E15
E.10 Hit Crossing ............................................................................................................ E16
E.11 Coulomb and Viscous Friction .............................................................................. E18
E.12 Wrap to Zero........................................................................................................... E19
E.13 Nonlinear Systems Describing Functions ........................................................... E20

Discrete ............................................................................................................................. F1
F.1 Unit Delay ................................................................................................................. F1
F.2 Integer Delay ............................................................................................................. F1
F.3 Tapped Delay ............................................................................................................ F3
F.4 Discrete Time Integrator........................................................................................... F4
F.5 Discrete Transfer Fcn Block ..................................................................................... F5
F.6 Discrete Filter............................................................................................................ F8
F.7 Discrete ZeroPole .................................................................................................. F10
F.8 Difference................................................................................................................ F11
F.9 Discrete Derivative.................................................................................................. F12
F.10 Discrete StateSpace.............................................................................................. F13
F.11 Transfer Fcn First Order........................................................................................ F16

iv

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

F.12 Transfer Fcn Lead or Lag .......................................................................................F17


F.13 Transfer Fcn Real Zero ...........................................................................................F20
F.14 Discrete FIR Filter ..................................................................................................F21
F.15 Memory...................................................................................................................F24
F.16 FirstOrder Hold ...................................................................................................F25
F.17 ZeroOrder Hold ...................................................................................................F26
F.18 Discrete PID Controller .........................................................................................F26
F.19 Discrete PID Controller (2DOF) ...........................................................................F28

Logic and Bit Operations ...............................................................................................G1


G.1 Logical Operator ......................................................................................................G1
G.2 Relational Operator ..................................................................................................G1
G.3 Interval Test .............................................................................................................G2
G.4 Interval Test Dynamic .............................................................................................G3
G.5 Combinatorial Logic................................................................................................G4
G.6 Compare to Zero......................................................................................................G6
G.7 Compare to Constant..............................................................................................G7
G.8 Bit Set.......................................................................................................................G8
G.9 Bit Clear...................................................................................................................G8
G.10 Bitwise Operator.....................................................................................................G9
G.11 Shift Arithmetic ....................................................................................................G11
G.12 Extract Bits............................................................................................................G12
G.13 Detect Increase......................................................................................................G13
G.14 Detect Decrease ....................................................................................................G14
G.15 Detect Change ......................................................................................................G14
G.16 Detect Rise Positive ..............................................................................................G15
G.17 Detect Rise Nonnegative ......................................................................................G16
G.18 Detect Fall Negative..............................................................................................G17
G.19 Detect Fall Nonpositive ........................................................................................G18

Lookup Tables ................................................................................................................. H1


H.1
H.2
H.3
H.4
H.5
H.6
H.7
H.8
H.9

Lookup Table.......................................................................................................... H1
Lookup Table (2D) ............................................................................................... H4
Lookup Table (nD).............................................................................................. H 5
Prelookup................................................................................................................ H8
Interpolation (nD) Using PreLookup .................................................................. H9
Direct Lookup Table (nD).................................................................................. H10
Lookup Table Dynamic ........................................................................................ H15
Sine and Cosine.................................................................................................... H16
Function Lookup Table Generation .................................................................... H18

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Math Operations .............................................................................................................. I1


I.1 Sum ............................................................................................................................. I1
I.2 Add ............................................................................................................................. I1
I.3 Subtract ....................................................................................................................... I2
I.4 Sum of Elements......................................................................................................... I3
I.5 Bias.............................................................................................................................. I3
I.6 Weighted Sample Time Math .................................................................................... I4
I.7 Gain ............................................................................................................................ I5
I.8 Slider Gain.................................................................................................................. I5
I.9 Product........................................................................................................................ I6
I.10 Divide......................................................................................................................... I6
I.11 Product of Elements .................................................................................................. I7
I.12 Dot Product ............................................................................................................... I8
I.13 Sign ............................................................................................................................ I9
I.14 Abs ........................................................................................................................... I10
I.15 Unary Minus............................................................................................................ I10
I.16 Math Function......................................................................................................... I11
I.17 Rounding Function ................................................................................................. I12
I.18 Polynomial ............................................................................................................... I13
I.19 MinMax....................................................................................................................I14
I.20 MinMax Running Resettable .................................................................................. I15
I.21 Trigonometric Function .......................................................................................... I16
I.22 Sine Wave Function ................................................................................................ I17
I.23 Algebraic Constraint................................................................................................ I18
I.24 Assignment .............................................................................................................. I19
I.25 Reshape.................................................................................................................... I20
I.26 Squeeze..................................................................................................................... I20
I.27 Matrix Concatenate ................................................................................................. I22
I.28 Permute Dimensions ...............................................................................................I23
I.29 Complex to MagnitudeAngle................................................................................ I23
I.30 MagnitudeAngle to Complex................................................................................ I24
I.31 Complex to RealImag............................................................................................ I25
I.32 RealImag to Complex............................................................................................ I26
I.33 Sqrt........................................................................................................................... I27
I.34 Signed Sqrt...............................................................................................................I28
I.35 Reciprocal Sqrt ........................................................................................................ I29
I.36 Find Nonzero Elements........................................................................................... I30
I.37 Vector Concatenate ................................................................................................. I33

vi

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Model Verification ........................................................................................................... J1


J.1 Check Static Lower Bound .........................................................................................J1
J.2 Check Static Upper Bound.........................................................................................J2
J.3 Check Static Range .....................................................................................................J2
J.4 Check Static Gap.........................................................................................................J3
J.5 Check Dynamic Lower Bound....................................................................................J4
J.6 Check Dynamic Upper Bound ...................................................................................J5
J.7 Check Dynamic Range................................................................................................J6
J.8 Check Dynamic Gap ...................................................................................................J7
J.9 Assertion......................................................................................................................J8
J.10 Check Discrete Gradient............................................................................................J9
J.11 Check Input Resolution...........................................................................................J10

ModelWide Utilities ..................................................................................................... K1


K.1
K.2
K.3
K.4
K.5

TriggerBased Linearization .................................................................................... K1


TimeBased Linearization........................................................................................ K3
Model Info................................................................................................................ K6
Doc Text ................................................................................................................... K8
Block Support Table................................................................................................. K8

Ports & Subsystems ...........................................................................................................L1


L.1 Inport, Outport, and Subsystem .............................................................................. L1
L.2 Trigger....................................................................................................................... L1
L.3 Enable (description).................................................................................................. L1
L.4 FunctionCall Generator......................................................................................... L2
L.5 Atomic Subsystem .................................................................................................... L3
L.6 Virtual and Nonvirtual Subsystems.......................................................................... L7
L.7 Code Reuse Subsystem............................................................................................. L7
L.8 Enable (added to subsystem block)......................................................................... L11
L.9 Model...................................................................................................................... L16
L.10 Configurable Subsystem ........................................................................................ L17
L.11 Triggered Subsystem .............................................................................................. L23
L.12 Enabled Subsystem ................................................................................................ L26
L.13 Enabled and Triggered Subsystem ........................................................................ L28
L.14 FunctionCall Subsystem...................................................................................... L32
L.15 For Iterator Subsystem........................................................................................... L35
L.16 While Iterator Subsystem ...................................................................................... L36
L.17 If and If Action Subsystem .................................................................................... L38
L.18 Switch Case and Switch Case Action Subsystem.................................................. L40
L.19 Model Variants ...................................................................................................... L42

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

vii

L.20 Variant Subsystem.................................................................................................. L49


L.21 For Each Subsystem ............................................................................................... L52
L.22 FunctionCall Split ............................................................................................... L57
L.23 FunctionCall Feedback Latch.............................................................................. L58
L.24 Subsystem Examples ..............................................................................................L59
L.25 SFunction............................................................................................................. L62

M Signal Attributes ............................................................................................................. M1

M.1 Data Type Conversion............................................................................................M1


M.2 Data Type Duplicate...............................................................................................M4
M.3 Data Type Propagation...........................................................................................M6
M.4 Data Type Scaling Strip ..........................................................................................M7
M.5 Data Conversion Inherited ....................................................................................M8
M.6 IC (Initial Condition).............................................................................................M8
M.7 Signal Conversion ..................................................................................................M9
M.8 Rate Transition.....................................................................................................M10
M.9 Signal Specification ..............................................................................................M12
M.10 Bus to Vector .......................................................................................................M13
M.11 Data Type Propagation Examples .......................................................................M14
M.12 Probe....................................................................................................................M15
M.13 Weighted Sample Time .......................................................................................M17
M.14 Width...................................................................................................................M18

Signal Routing ................................................................................................................. N1


N.1 Bus Creator ..............................................................................................................N1
N.2 Bus Selector..............................................................................................................N1
N.3 Bus Assignment .......................................................................................................N1
N.4 Mux ..........................................................................................................................N4
N.5 Demux......................................................................................................................N4
N.6 Selector.....................................................................................................................N5
N.7 Index Vector ............................................................................................................N8
N.8 Merge .......................................................................................................................N9
N.9 Environmental Controller.....................................................................................N10
N.10 Manual Switch ......................................................................................................N12
N.11 Multiport Switch...................................................................................................N13
N.12 Switch....................................................................................................................N14
N.13 From......................................................................................................................N14
N.14 Goto Tag Visibility................................................................................................N15
N.15 Goto ......................................................................................................................N16
N.16 Data Store Read....................................................................................................N18
N.17 Data Store Memory...............................................................................................N18

viii

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

N.18 Data Store Write ..................................................................................................N18


N.19 Vector Concatenate..............................................................................................N20

Sinks..................................................................................................................................O1
O.1
O.2
O.3
O.4
O.5
O.6
O.7
O.8
O.9

Outport ................................................................................................................... O1
Terminator.............................................................................................................. O1
To File..................................................................................................................... O1
To Workspace......................................................................................................... O3
Scope....................................................................................................................... O4
Floating Scope ........................................................................................................ O5
XY Graph................................................................................................................ O9
Display .................................................................................................................. O11
Stop Simulation.................................................................................................... O12

Sources ...............................................................................................................................P1
P.1 Inport ........................................................................................................................P1
P.2 Ground......................................................................................................................P1
P.3 From File ...................................................................................................................P1
P.4 From Workspace .......................................................................................................P1
P.5 Constant....................................................................................................................P2
P.6 Enumerated Constant...............................................................................................P2
P.7 Signal Generator .......................................................................................................P7
P.8 Pulse Generator.........................................................................................................P9
P.9 Signal Builder ..........................................................................................................P10
P.10 Ramp ......................................................................................................................P12
P.11 Sine Wave...............................................................................................................P12
P.12 Step.........................................................................................................................P14
P.13 Repeating Sequence ...............................................................................................P14
P.14 Chirp Signal ...........................................................................................................P15
P.15 Random Number ...................................................................................................P16
P.16 Uniform Random Number....................................................................................P17
P.17 Band Limited White Noise....................................................................................P18
P.18 Repeating Sequence Stair.......................................................................................P21
P.19 Repeating Sequence Interpolated ..........................................................................P22
P.20 Counter FreeRunning .........................................................................................P23
P.21 Counter Limited ....................................................................................................P24
P.22 Clock ......................................................................................................................P25
P.23 Digital Clock ..........................................................................................................P26

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

ix

UserDefined Functions................................................................................................. Q1
Q.1
Q.2
Q.3
Q.4
Q.5
Q.6
Q.7

Additional Discrete ..........................................................................................................R1


R.1 Transfer Fcn Direct Form II.....................................................................................R1
R.2 Transfer Fcn Direct Form II Time Varying .............................................................R2
R.3 Fixed-Point StateSpace ...........................................................................................R3
R.4 Unit Delay External IC ............................................................................................R4
R.5 Unit Delay Resettable...............................................................................................R5
R.6 Unit Delay Resettable External IC...........................................................................R6
R.7 Unit Delay Enabled..................................................................................................R7
R.8 Unit Delay Enabled Resettable ................................................................................R8
R.9 Unit Delay Enabled External IC..............................................................................R9
R.10 Unit Delay Enabled Resettable External IC .........................................................R10
R.11 Unit Delay With Preview Resettable ....................................................................R11
R.12 Unit Delay With Preview Resettable External RV ...............................................R12
R.13 Unit Delay With Preview Enabled........................................................................R13
R.14 Unit Delay With Preview Enabled Resettable ......................................................R14
R.15 Unit Delay With Preview Enabled Resettable External RV.................................R15

Additional Math Increment / Decrement .................................................................. S1


S.1
S.2
S.3
S.4
S.5
S.6

Increment Real World .............................................................................................. S1


Decrement Real World............................................................................................. S1
Increment Stored Integer.......................................................................................... S2
Decrement Stored Integer......................................................................................... S3
Decrement to Zero Block.......................................................................................... S3
Decrement Time To Zero ......................................................................................... S4

Simulink Extras................................................................................................................ T1
T.1
T.2
T.3
T.4
T.5

Fcn........................................................................................................................... Q1
Interpreted MATLAB Function ............................................................................. Q2
MATLAB Function ................................................................................................ Q2
SFunction.............................................................................................................. Q6
Level2 MATLAB SFunction............................................................................... Q6
SFunction Builder ................................................................................................ Q9
SFunction Examples ........................................................................................... Q10

Discrete Transfer Fcn with Initial States .................................................................. T1


Discrete Transfer Fcn with Initial Outputs .............................................................. T2
Discrete ZeroPole (with initial states) ..................................................................... T4
Discrete ZeroPole (with initial outputs) ................................................................. T5
Idealized ADC Quantizer ......................................................................................... T7

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

T.6 Transfer Fcn (with initial states)............................................................................... T8


T.7 Transfer Fcn (with initial outputs) ........................................................................... T9
T.8 ZeroPole (with initial states) ................................................................................. T10
T.9 ZeroPole (with initial outputs) ............................................................................. T11
T.10 StateSpace (with initial outputs) ......................................................................... T11
T.11 Auto Correlator..................................................................................................... T12
T.12 Cross Correlator.................................................................................................... T13
T.13 Power Spectral Density.......................................................................................... T14
T.14 Averaging Power Spectral Density......................................................................... T16
T.15 Spectrum Analyzer................................................................................................. T17
T.16 Averaging Spectrum Analyzer ............................................................................... T17
T.17 Floating Bar Plot.................................................................................................... T18
T.18 Clock...................................................................................................................... T20
T.19 D Latch .................................................................................................................. T20
T.20 D Flip Flop ............................................................................................................ T21
T.21 SR Flip Flop......................................................................................................... T21
T.22 JK Flip Flop ......................................................................................................... T22
T.23 Switched Derivative for Linearization................................................................... T23
T.24 Switched Transport Delay for Linearization ......................................................... T25
T.25 Polar to Cartesian Transformation ....................................................................... T27
T.26 Cartesian to Polar Transformation ....................................................................... T27
T.27 Spherical to Cartesian Transformation................................................................. T28
T.28 Cartesian to Spherical Transformation................................................................. T29
T.29 Fahrenheit to Celsius Transformation.................................................................. T29
T.30 Celsius to Fahrenheit Transformation.................................................................. T29
T.31 Degrees to Radians Transformation ..................................................................... T30
T.32 Radians to Degrees Transformation ..................................................................... T30

Random Number Generation.........................................................................................U1


U.1 Random Numbers...................................................................................................U1
U.2 An Example.............................................................................................................U1

V Exercises............................................................................................................................ V1
W Solutions to the Exercises ............................................................................................... W1
X Weighted Moving Average .............................................................................................. X1
Y

Table of Simulink Blocks ................................................................................................ Y1

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

xi

References....................................................................................................................... Ref1
Index................................................................................................................................ IN1

xii

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Chapter 1
Introduction to Simulink

his chapter is an introduction to Simulink. This author feels that it is best to introduce Simulink in this chapter with a few examples. Tools for simulation and modelbased designs are
presented in the subsequent chapters. Some familiarity with MATLAB is essential in understanding Simulink, and for this purpose, Appendix A is included as an introduction to MATLAB.

1.1 Simulink and its Relation to MATLAB


The MATLAB and Simulink environments are integrated into one entity, and thus we can analyze, simulate, and revise our models in either environment at any point. We invoke Simulink from
within MATLAB. We begin with a few examples and we will discuss generalities in subsequent
chapters. Throughout this text, a left justified horizontal bar will denote the beginning of an example, and a right justified horizontal bar will denote the end of the example. These bars will not be
shown whenever an example begins at the top of a page or at the bottom of a page. Also, when one
example follows immediately after a previous example, the right justified bar will be omitted.

1.2 Modeling an Electric Circuit


Example 1.1
For the electric circuit of Figure 1.1, u 0 ( t ) *is the input and the initial conditions are i L ( 0 ) = 0 ,
and v c ( 0 ) = 0.5 V . We will compute v C ( t ) .

14 H

i(t)

+
C

43 F

vC ( t )

vs ( t ) = u0 ( t )

For this example,

Figure 1.1. Circuit for Example 1.1


dv
i = i L = i C = C --------Cdt

(1.1)

and by Kirchoffs voltage law (KVL),


* Throughout this text, the designation u 0 ( t ) will be used to denote the unit step function. We will use u ( t ) to denote
any other input to be consistent with the MATLAB and Simulink designations.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

11

Chapter 1 Introduction to Simulink


The initials conditions [ x1 x2 ]' are specified at the MATLAB command prompt as
x1=0; x2=0.5;

As before, to start the simulation we click the

icon, and to see the output waveform, we double

click the Scope block. Then we click on the Autoscale


icon, and we scale the vertical axis as we
did with the waveform of Figure 1.13. The waveform shown in Figure 1.16.

Figure 1.16. The waveform for the function v C ( t ) for Example 1.1 with the StateSpace block.

1.3 Modeling a FourthOrder Differential Equation


The statespace block is the best choice when we need to display the output waveform of three or
more variables as illustrated by the following example.
Example 1.2
A fourthorder network is described by the differential equation
4

d
y
d y
d y
dy
--------+ a 3 --------3- + a 2 -------2- + a 1 ------ + a 0 y ( t ) = u ( t )
4
dt
dt
dt
dt

(1.27)

where y ( t ) is the output representing the voltage or current of the network, and u ( t ) is any input,
and the initial conditions are y ( 0 ) = y' ( 0 ) = y'' ( 0 ) = y''' ( 0 ) = 0 .
a. We will express (1.27) as a set of state equations
b. It is known that the solution of the differential equation
4

d y
d y
-------- + 2 -------- + y ( t ) = sin t
4
2
dt
dt

114

(1.28)

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Modeling a Fourth-Order Differential Equation


subject to the initial conditions y ( 0 ) = y' ( 0 ) = y'' ( 0 ) = y''' ( 0 ) = 0 , has the solution
2

y ( t ) = 0.125 [ ( 3 t ) 3t cos t ]

(1.29)

In our set of state equations, we will select appropriate values for the coefficients
a 3, a 2, a 1, and a 0 so that the new set of the state equations will represent the differential equation of (1.28) and using Simulink, we will display the waveform of the output y ( t ) .
1. The differential equation of (1.28) is of fourthorder; therefore, we must define four state variables that will be used with the four firstorder state equations.
We denote the state variables as x 1, x 2, x 3 , and x 4 , and we relate them to the terms of the given
differential equation as

We observe that

dy
x 2 = -----dt

x1 = y ( t )

d y
x 3 = --------2dt

d y
x 4 = --------3dt

x 1 = x 2
x 2 = x 3
x 3 = x 4

(1.30)

(1.31)

d y
--------- = x 4 = a 0 x 1 a 1 x 2 a 2 x 3 a 3 x 4 + u ( t )
4
dt

and in matrix form


x 1
x 2

0
0
=
0
a0

x 3
x 4

1
0
0
a1

0
1
0
a2

x1

0
0
1
a3

0
x2
+ 0 u(t)
0
x3
1
x4

(1.32)

In compact form, (1.32) is written as


Also, the output is

x = Ax + bu

(1.33)

y = Cx + du

(1.34)

where

x =

x 1
x 2
x 3
x 4

0
0
A=
0
a0

1
0
0
a1

0
1
0
a2

0
0
,
1
a3

x1
x=

x2
x3
x4

0
b= 0,
0
1

and u = u ( t )

(1.35)

and since the output is defined as


y ( t ) = x1

relation (1.34) is expressed as


Introduction to Simulink with Engineering Applications, Third Edition
Copyright Orchard Publications

115

Chapter 1 Introduction to Simulink


x1
x2

y = [1 0 0 0]

x3

+ [ 0 ]u ( t )

(1.36)

x4

2. By inspection the differential equation of (1.27) will be reduced to the differential equation of
(1.28) if we let
a3 = 0

a2 = 2

a1 = 0

a0 = 1

u ( t ) = sin t

and thus the differential equation of (1.28) can be expressed in statespace form as
x 1
x 2

0
0
=
0
a0

x 3
x 4

1
0
0
0

0
1
0
2

0
0
1
0

x1

0
+ 0 sin t
0
x3
1
x4
x2

(1.37)

where

x =

x 1
x 2
x 3
x 4

0
0
A=
0
a0

1
0
0
0

0
1
0
2

0
0
,
1
0

x1
x=

x2
x3

x4

0
b= 0,
0
1

and u = sin t

(1.38)

Since the output is defined as


y ( t ) = x1

in matrix form it is expressed as


x1
y = [1 0 0 0]

x2
x3

+ [ 0 ] sin t

(1.39)

x4

We invoke MATLAB, we start Simulink by clicking on the Simulink icon, on the Simulink
Library Browser, we click the Create a new model (blank page icon on the left of the top bar),
and we save this model as Example_1_2. On the Simulink Library Browser we select Sources,
we drag the Signal Generator block on the Example_1_2 model window, we click and drag the
StateSpace block from the Continuous on Simulink Library Browser, and we click and drag
the Scope block from the Commonly Used Blocks on the Simulink Library Browser. We also

116

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Modeling a Fourth-Order Differential Equation


add the Display block found under Sinks on the Simulink Library Browser. We connect these
four blocks and the complete block diagram is as shown in Figure 1.17.

Figure 1.17. Model for Example 1.2 with the parameters specified below

We now doubleclick the Signal Generator block and we enter the following in the Function
Block Parameters dialog box the following:
Wave form: sine
Time (t): Use simulation time
Amplitude: 1
Frequency: 2
Units: Hertz
Next, we doubleclick the StateSpace block and we enter the following parameter values in the
Function Block Parameters:
A: [0 1 0 0; 0 0 1 0; 0 0 0 1; a0 a1 a2 a3]
B: [0 0 0 1]
C: [1 0 0 0]
D: [0]

Initial conditions: x0
Absolute tolerance: auto
Now, we switch to the MATLAB command window and at the command prompt we type the following values:
a0=1; a1=0; a2=2; a3=0; x0=[0 0 0 0];

We change the Simulation Stop time to 25 , and we start the simulation by clicking on the
icon. To see the output waveform, we doubleclick the Scope block, then we click the Autoscale
icon, and we obtain the waveform shown in Figure 1.18.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

117

Chapter 1 Introduction to Simulink

Figure 1.18. Waveform for Example 1.2

The Display block in Figure 1.17 shows the value at the end of the simulation time.
Examples 1.1 and 1.2 have clearly illustrated that the StateSpace is indeed a powerful block. We
could have also obtained the solution of Example 1.2 using four Integrator blocks.

1.4 Modeling the Solution of Three Equations with Three Unknowns


Example 1.3
We will create a model that will produce the simultaneous solution of three equations with three
unknowns using Algebraic Constraint blocks found in the Math Operations library, Display
blocks found in the Sinks library, and Gain blocks found in the Commonly Used Blocks library.
The model will display the values for the unknowns z 1 , z 2 , and z 3 for the system of the equations
a1 z1 + a2 z2 + a3 z3 + k1 = 0
a4 z1 + a5 z2 + a6 z3 + k2 = 0

(1.40)

a7 z1 + a8 z2 + a9 z3 + k3 = 0

The model is shown in Figure 1.19.

118

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Modeling the Solution of Three Equations with Three Unknowns

Figure 1.19. Model for Example 1.3 with the entries specified below

Next, at the MATLAB command prompt we enter the following values:


a1=2; a2=3; a3=1; a4=1; a5=5; a6=4; a7=6; a8=1; a9=2; k1=8; k2=7; k3=5;

After clicking on the simulation icon, we obtain the values of the unknowns as z 1 = 2 , z 2 = 3 ,
and z 3 = 5 as shown in the Display blocks in Figure 1.19.
An Algebraic Constraint block constrains the input signal f ( z ) to zero, outputs a value for z , and
this value eventually produces a zero at the input. Thus, output is fed back to the input via a feedback path. We can improve the efficiency of the algebraic loop solver by providing an initial guess
for the algebraic state z that is close to the final solution value. By default, the initial guess value is
zero.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

119

Chapter 1 Introduction to Simulink


1.5 Representing a Model as a Subsystem
An outstanding feature in Simulink is the representation of a large model consisting of many blocks
and lines, to be shown as a single Subsystem block.
Example 1.4
For instance, to group all blocks and lines in the model of Figure 1.19 except the display blocks,
from the Edit drop menu we choose Create Subsystem and this model will be shown as in Figure
1.20* where at the MATLAB command prompt we have entered the following values:
a1=5; a2=1; a3=4; a4=11; a5=6; a6=9; a7=8; a8=4; a9=15; k1=14; k2=6; k3=9;

Figure 1.20. The model in Figure 1.19 represented as a subsystem

The Display blocks in Figure 1.20 show the values of z 1 , z 2 , and z 3 for the values that we specified
at the MATLAB command prompt above.

1.6 Simulink Demos


At this time, the reader with no prior knowledge of Simulink, should be ready to learn Simulinks
additional capabilities. We will explore other features in the subsequent chapters. However, it is
highly recommended that the reader becomes familiar with the block libraries found in the Simulink Library Browser. Then, the reader can follow the steps delineated in The MathWorks Simulink Users Manual to run the Demo Models beginning with the thermo model. This model can
invoked by typing thermo at the MATLAB command prompt.

* The contents of the Subsystem block are not lost. We can doubleclick on the Subsystem block to see its contents. The
Subsystem block replaces the inputs and outputs of the model with Inport and Outport blocks. These blocks along
with the Subsystem block are described in Section 2.1, Chapter 2, Page 22.

120

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Chapter 2 Mathematical Applications

Clock
20
Constant 1

Sum 1

Scope
Mux

24
Constant 2

Sum 2

1/3
Constant 3

Product

Figure 2.4. Simulink model for the constraints

aa

Figure 2.5. Plot of the constraints as displayed in Scope block in Figure 2.4

26

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Chapter 2 Mathematical Applications


With the model in Figure 2.18 open, we enter the following values at the MATLAB command
prompt:
PP=90000; SV=45000; n=15; AE=40950; i=0.045;

and the Display block in Figure 2.19 displays the value of the cost if Route A is chosen.

Figure 2.19. Model for Comparison of Alternate Proposals - Route A

Next we enter the following values at the MATLAB command prompt:


PP=155000; SV=30000; n=15; AE=9400; i=0.045;

Figure 2.20. Model for Comparison of Alternate Proposals - Route B

218

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Ball Thrown Vertically Upward

Figure 3.4. Model for the ball thrown vertically upward

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

37

Chapter 4 Thermodynamics and Fluid Mechanics Applications

Figure 4.2. Model for the rise of water in a capillary tube at temperature T in

For the model in Figure 4.2, we have entered the values


temp_table=[ 0

42

10

15

20

30

40

50

60

70

80

90 100];

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Chapter 5 Assortment of Math and Engineering Applications

Figure 5.6. The MATLAB Function block with the userdefined function

To the MATLAB Function block model we add the Clock block from the Sources library, and the
Scope block from the Sinks library. We connect the three blocks and the model is now as shown in
Figure 5.7, and we execute the simulation command.

Figure 5.7. Model for the beam deflection example

The waveform indicates the maximum deflection occurs when x 0.58L . The exact result is
obtained by taking the first derivative of the given function and setting it equal to zero as shown
below.
3

dy dx = 8x 15 Lx + 6L x = x ( 8x 15Lx + 6L ) = 0

Since x = 0 is not a viable solution, with L = 100 , we obtain


2

8x 1500x + 60000 = 0
2

x 187.5x + 7500 = 0

and
syms x y; y=solve('x^2187.5*x+7500')

yields x = 57.85 , and y = 2.5997

5.4 Tractrix Curve


A heavy object P is dragged along a rough horizontal plane by a string PQ of length a as shown in
Figure 5.8.

56

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Discrete Time Integration with Variable Amplitude Input


The final step is to add V ' C2 with V '' C2 . This addition is performed with the model in Figure 5.53
where the models of Figures 5.51 and 5.52 have been converted to Subsystems 1 and 2 respectively.

Figure 5.53. Model for the addition of V'C2 with V''C2

The model in Figure 5.53 can now be used with the circuit of Figure 5..48 for any values of the
impedances Z .

5.21 Discrete Time Integration with Variable Amplitude Input


It is showm in Appendix V, Exercise 16, that when the input signal is a pulse, a Discrete Forward
Euler Integrator and a Discrete Trapezoidal Integrator will produce the same result. The model in
Figure 5.54 uses an input that varies in amplitude during a sample period.

Figure 5.54. Model for Discrete Time Integration with variable amplitude input

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

537

SFunction Example 2
The syntax for the diode_sfcn.m file above is the similar to that in Example L.20, Page L62,
Appendix L
Next, we open a new model window, from the UserDefined Functions Library we drag an SFunction block into it, we doubleclick this block, in the Function Block Parameters dialog box we
name it diode_sfcn, and we add and interconnect the other blocks shown in Figure 5.74.

Scope 1

Scope 2

Figure 5.56. Model and waveforms for temperature coefficients in semiconducto diodes using an SFunction block

5.23 SFunction Example 2


Equation (5.50) below is same as equation (5.20) in Section 5.7, Page 512
2

d
d
M = J -------2- + c ------ + mgL sin
dt
dt

or

(5.50)

d
-------2- = 1--- M c d
------ mgL sin

J
dt
dt

(5.51)

Let = x 1 , and d dt = x 2 . Then x 1 = x 2 , and x 2 = d 2 dt 2 = ( 1 J ) ( M cx 2 mgLx 1 ) .


For this example we let J = 2 , M = 1 , c = 0.2 , and mgL = 2 . Then, our statespace equations
are:

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

541

Appendix A Introduction to MATLAB


600

Imaginary part of Z

400
200
0
-200
-400
-600

200

400

600

800 1000 1200


radian frequency w

1400

1600

1800

2000

Figure A.12. Plot for the imaginary part of the impedance in Example A.15
% The last six statements (next five lines) below produce the polar plot of z
mag=abs(z);% Computes |Z|;...
rndz=round(abs(z));% Rounds |Z| to read polar plot easier;...
theta=angle(z);% Computes the phase angle of impedance Z;...
polar(theta,rndz);% Angle is the first argument
ylabel('Polar Plot of Z'); grid
90
120

1500

60

1000

Polar Plot of Z

150

30
500

180

210

330
240

300
270

Figure A.13. Polar plot of the impedance in Example A.15

Example A.15 clearly illustrates how powerful, fast, accurate, and flexible MATLAB is.

A24

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Appendix B Masked Subsystems

Figure B.9. The Function Block Parameters window with the values of the constants

With the variables defined as above, the masked subsystem implements the quadratic equation
2

y = x 5x + 6

and the roots of this equation are x 1 = 2 and x 2 = 3 . Our model is tested for the first root as
shown in Figure B.10.

Figure B.10.

The Mask Editor also contains the Initialization tab that allows us to enter MATLAB commands
that initialize the masked subsystem, and the Documentation tab that lets us define or modify the
type description and help text for a masked subsystem. These tabs are not used in this example.

B8

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Appendix C Commonly Used


Example C.10
For the model in Figure C.26, at the MATLAB command prompt we have entered the statement
T=75; the Function Block Parameters dialog box for the Switch block has been set for u2>Threshold, Threshold =T, in the Source Block Parameters dialog box for the y = 75 + sin x function
block we have entered Amplitude=1, Bias=75, Frequency =1, Phase = 0 , and for the
z = 75 sin x function block we have entered Amplitude=1, Bias=75, Frequency =1 ,
Phase = . Unlisted parameters are left in their default states. With the simulation time set at
10 sec , the waveforms indicated on the Scope block in Figure C.27 show that at the end of the simulation time the z = 75 sin x function has attained the value of 75.54 and the y = 75 + sin x
function has attained the value of 74.46 . Since the Threshold value is set at 75 and the criterion is
u2>Threshold, the Switch block outputs the value of 75.54 , that is, the value of the Display 3 block
at the end of the simulation time.

Figure C.26. Switch block set for u2>Threshold, Threshold T=75

Figure C.27. Input waveforms for the model in Figure C.26

C22

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Vector Concatenate

Figure C.59. Model for Example C.21

The Data Type Demonstration Simulink demo is another model using Data Type Conversion
blocks. It can be accessed by typing datatypedemo at the MATLAB command prompt.
Note: The MATLAB and Simulink builtin integer data types are limited to 32 bits. If we want to
output fixedpoint numbers in the range 33 and 53 bits, we can break the number into
pieces using Gain blocks. For details please refer to the Simulink Help menu for an example.

C.18 Vector Concatenate


The Vector Concatenate block is a special case of the Matrix Concatenate block described in
Appendix I, where the block operates in Vector Concatenation Mode, Horizontal Matrix Concatenation Mode, or Vertical Matrix Concatenation Mode. In Vector Concatenation Mode, all input
signals must be either row vectors ( 1 m matrices) or column vectors ( m 1 matrices) or a combination of vectors and either row or column vectors. The output is a vector if all inputs are vectors.
The output is a row or column vector if any of the inputs are row or column vectors, respectively.
Example C.22
We will create a model using a Vector Concatenate block to concatenate vertically the column vecIntroduction to Simulink with Engineering Applications, Third Edition
Copyright Orchard Publications

C49

PID Controller
absence of an integral value prevents the system from reaching its target value due to the control
action.
In general, we add a proportional control to improve the rise time, we add a derivative control to
improve the overshoot, and we add an integral control to eliminate the steady-state error. Then, we
adjust each of Kp, Ki, and Kd until we obtain a desired overall response.
Example D.4
The model in Figure D.18 produces the outputs of a transfer function without and with PID control. The output waveforms are shown in Figure D19.

Figure D.18. Model for Example D.4

Figure D.19. Output waveforms for the model in Figure D.18 without and with PID control

The Simulink documentation contains the Anti-Windup Control Using a PID Controller, and Bumpless
Control Transfer Between Manual and PID Control demos.They can be accessed by typing
sldemo_antiwindup and sldemo_bumpless at the MATLAB command prompt.
Introduction to Simulink with Engineering Applications, Third Edition
Copyright Orchard Publications

D13

PID Controller (2DOF)


La s

Ra

Jm s
Tm ( s ) = Ki Ia ( s )

Va ( s )

Ia ( s )

m ( s )

Vb ( s ) = Kb m ( s )

m ( s )
( shaft angle )

Bm
Armature circuit

Inertial load

Figure D.20. Armature circuit and inertial load for a DC motor

Figure D.21 is the block diagram of the DC motor where T L ( s ) = load torque , i.e., the torque that
the motor has to overcome for motion to occur, and Figure D.22 is a model for this block diagram
where the integrator block on the right side has been omitted for simplicity.
TL ( s )
Va ( s )

1
---------------------- I a ( s )
La s + Ra

Ki

Tm ( s )

1
---------------------Jm s + Bm

m ( s )

1
--s

m ( s )

Vb ( s )

Kb

Figure D.21. Block diagram of a DC motor

Figure D.22. Model for the block diagram in Figure D.21

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

D15

Appendix D ContinuousTime

Figure D.45. Model to illustrate the use of the Variable Time Delay block

Figure D.46. Input and output waveforms for the model in Figure D.45

Example D.12
The model in this example compares the distance traveled by two automobiles that departed from
point A, one three hours after the other at different speeds, and stopped at point B ten hours later.

D30

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Appendix E
Discontinuities

his appendix is an introduction to the Discontinuities Blocks library. This is the third
library in the Simulink group of libraries and contains the blocks shown below. Their functions are illustrated with examples. In this appendix we will briefly describe the function of
each block included in this group, and their application will be illustrated with examples. The complete description of each block can be found in the Simulink documentation. For emphasis, the
icon of each Simulink block described in its section is shown in drop shadows.

E.1 Saturation
The Saturation block sets upper and lower bounds on a signal. When the input signal is within the
range specified by the Lower limit and Upper limit parameters, the input signal passes through
unchanged. When the input signal is outside these bounds, the signal is clipped to the upper or
lower bound. When the Lower limit and Upper limit parameters are set to the same value, the
block outputs that value. This block is also described in Section 2.13, Chapter 2, Page 221.
Example E.1

The model shown in Figure E.1 uses a Saturation block whose upper limit is clipped at +0.25 and
the lower limit is clipped at 0.25 . The input is a sine function with amplitude 1 and frequency
0.25 Hz . The input and output waveforms are shown in Figure E.2.

Figure E.1. Model for Example E.1

* Another example with the Saturation block is presented as Example 2.13, Chapter 2, Page 221.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

E1

Appendix E Discontinuities
E.11 Coulomb and Viscous Friction
As we know from physics, friction is a force that resists the relative motion or tendency to such
motion of two bodies in contact. Friction is undesirable in some parts of rotating machinery such
as bearings and cylinders, but very beneficial in the automotive industry such as the design of
brakes and tires. Theoretically, there should be no friction in a motor with zero velocity, but in reality, a small amount of static (no velocity) friction known as Coulomb friction, is always present
even in roller or ball type antifriction bearings. Viscous friction, on the other hand, is friction
force caused by the viscosity of lubricants.
The Coulomb friction function, the Viscous friction function, and the combined Coulomb plus
Viscous friction functions are illustrated in Figure E.21.
Friction force F fc

Friction force

C Fn

Friction force F fcv

V v Fn

v
Sliding velocity

v
Sliding velocity

v
Sliding velocity

(a) Coulomb friction

F fv

(b) Viscous friction

(c) Coulomb plus Viscous friction

Figure E.31. Coulomb friction and Viscous friction functions

The Coulomb friction function is defined as


F fc = C F n

(E.4)

where C is the Coulomb friction coefficient.


The Viscous friction function is defined as
F fv = v vF n

(E.5)

and the Coulomb plus Viscous friction is defined as


F fc + fv = v vF n C F n

(E.6)

The Coulomb and Viscous Friction block produces an offset at zero and a linear gain elsewhere.
The offset corresponds to the Coulombic friction; the gain corresponds to the viscous friction.
Coulomb friction force can be represented by at least four different continuous functions. Each of
these functions involves one constant that controls the level of accuracy of that function's representation of the friction force. Simulink uses the default values [ 1 3 2 0 ] for the offset (Coulomb
friction value). For the signal gain (coefficient of viscous friction) at nonzero input points the
default is 1. For a detailed description, please refer to the Simulink documentation.

E18

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Transfer Fcn Lead or Lag


ans =
(5*z + 5)/(6*z + 4)
or
2.5 ( z + 1 )
-----------------------3z + 2

The model and the outputs are shown in Figure F.22.

Figure F.22. Model and waveforms for Example F.11

F.12 Transfer Fcn Lead or Lag


Lead and lag compensators are used quite extensively in control systems. A lead compensator can
increase the stability or speed of response of a system; a lag compensator can reduce (but not eliminate) the steady state error. Depending on the effect desired, one or more lead and lag compensators may be used in various combinations. Lead, lag, and lead/lag compensators are usually
designed for a system in transfer function form.
The Transfer Fcn Lead or Lag block is a discretetime lead or lag compensator. The instantaneous
gain of the compensator is unity, and the DC gain is equal to ( 1 z ) ( 1 p ) , where z is the zero
and p is the pole of the compensator. The block performs as a lead compensator when
0 < z < p < 1 , and performs as a lag compensator when 0 < p < z < 1 .
In general, the transfer function of a lead compensator is defined as
Introduction to Simulink with Engineering Applications, Third Edition
Copyright Orchard Publications

F17

Discrete FIR Filter


That is, the number of moving average sequence is equal to n k + 1 values. Thus, with k = 4 of a
ten-value ( n = 10 ) sequence, the moving average sequence has n k + 1 = 10 4 + 1 = 7 values.
Example F.14
The price of a particular security (stock) over a 10day trading period is as follows:
77 80 82 85 90 84 81 82 86 79

where the last value is the most recent. We will create a model of moving averages with k = 5 over
t h i s 10 d ay t r a d i n g p e r i o d . Fo r t h i s e x a mp l e , t h e m ov i n g ave r a g e s e qu e n c e h a s
n k + 1 = 10 5 + 1 = 6 values.
The model is shown in Figure F.30, and the settings for the Function Block Parameters dialog box
for the Discrete FIR Filter 1 block is shown in Figure F.31. The settings for the remaining Discrete
FIR Filter blocks are shown in the model.

Figure F.30. Model for Example F.14

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

F23

Appendix G Logic and Bit Operations


Example G.2
Let x represent an array of numbers or a time-varying signal. The model in Figure G.2 proves that
2

in general, ave ( x ) ( x ave ) . The term on the left implies that x must first be squared and the
average value is then to be found. The term on the right implies that the average value of x must be
found first, and then the average must be squared. For this model each of the elements of the array
[1 2 3 4 5] is first squared and the mean (average) value is found to be 11 . Then, the mean is first
found and its square is computed and found to be 9 . Since the results are different, the Relational
Operator block outputs logical 0 .

Figure G.2. Model for Example G.2

G.3 Interval Test


The Interval Test block performs a test to determine if a signal is in a specified interval. The block
outputs TRUE if the input is between the values specified by the Lower limit and Upper limit
parameters. The block outputs FALSE if the input is outside those values. The output of the block
when the input is equal to the Lower limit or the Upper limit is determined by whether the boxes
next to Interval closed on left and Interval closed on right are selected in the dialog box.
Example G.3
For the model shown in Figure G.3 the Upper limit parameter for the Interval Test block is set to
the binary value [ 01111111 ] , the Lower limit is set to the binary value [ 10000000 ] , and the boxes
next to Interval closed on left and Interval closed on right are selected in the dialog box. The largest
positive value and the smallest negative value have been selected and the Interval Test block outputs TRUE (1).

G2

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Appendix H
Lookup Tables

his appendix is an introduction to the Lookup Tables Group of blocks and only a brief
description is given. A complete description of each block can be found in the The MathWorks Simulink documentation. Their functions are illustrated with examples. The terminology monotonically increasing * is used throughout this chapter, and it is defined in the footnote
below.

H.1 Lookup Table


The Lookup Table block computes an approximation to a function y = f ( x ) where the data vectors x and y are given, and it is required that the x data vector must be monotonically increasing.
Moreover, the length of the x and y data vectors must be the same.
The Simulink documentation states that in a future release, the Lookup Table block will be
removed from the Lookup Tables library and replaced with a 1D version of the Lookup Table
(nD) block. Existing models that contain the Lookup Table block continue to work for backward
compatibility.
Example H.1
The model in Figure H.1 uses a Lookup Table block to find the radioactive material left after
5

1.5 10 yr if a U

234

isotope initially containing 3 10

the halflife ( T 1 2 ) of the Uranium isotope 234 ( U


14

234

gm of that material. It is known that


5

) is approximately 2.48 10 yr and has a

disintegration constant = 8.8 10 sec . The number of radioactive atoms of the original
kind still present at any time t is computed from the relation
N = N0 e

= N0 e

(H.1)

* Monotonically increasing and monotonically decreasing sequences are sequences in which the successive values either consistently

increase or decrease but do not oscillate in relative value. Each value of a monotonic increasing sequence is greater than, or equal
to the preceding value; likewise, each value of a monotonic decreasing sequence is less than, or equal to the preceding value.
Stated in other words, a monotonically increasing function is one resulting from a partially ordered domain to a partially ordered
range such that x y implies that f ( x ) f ( y ) . Likewise, a monotonically decreasing function is one resulting from a partially
ordered domain to a partially ordered range such that x y implies that f ( x ) f ( y ) .
Isotopes are atoms which have the same atomic number (number of protons) but different number of neutrons. The sum of the
number of protons and neutrons in the nucleus is referred to as the mass number. The superscript 234 represents the mass number.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

H1

Lookup Table

Figure H.1. Model for Example H.1

Another example using this block appears in the Simulink Modeling AntiLock Braking System
demo. It can be accessed by typing sldemo_absbrake at the MATLAB command prompt.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

H3

Sum of Elements
I.4 Sum of Elements
The Sum of Elements block is another form of the Add block described above with one input and
one output.
Example I.4
The model in Figure I.4 illustrates Gibbs phenomenon.*

Figure I.4. Model for Example I.4

I.5 Bias
The Bias block adds a bias (offset) to the input signal.

* The Gibbs phenomenon shows that Fourier series sums overshoot at a jump discontinuity, and that this overshoot does
not disappear as the number of harmonics increases. For a detailed discussion please refer to Chapter 7, Signals and
Systems, ISBN 978-1-934404-11-9.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

I3

Polynomial

Figure I.17. Model for Example I.17

I.18 Polynomial
The Polynomial block accepts the real coefficients a polynomial in the Parameters dialog box and
at the input we specify real values at which the polynomial will be evaluated. It is equivalent to the
MATLAB polyval function.
Example I.18
We will create a model using the Polynomial block to evaluate the polynomial
6

p ( x ) = x 3x + 5x 4x + 3x + 2

at x = 3.7 , x = 4.0 , and x = 8.1 .


The model is shown in Figure I.18 where at the MATLAB command prompt we have entered the
coefficients of p ( x ) , i.e.,
px=[1 3 0 5 4 3 2];

and in the Parameters dialog box for the Polynomial block we have typed px.
Introduction to Simulink with Engineering Applications, Third Edition
Copyright Orchard Publications

I13

Check Dynamic Upper Bound


value of 1 volt . This model is configured to display error messages when the amplitude exceeds
1 volt .
The Signal Generator block has been specified as a sine waveform with the amplitude set at 1.1, frequency at 0.1 Hz, Constant block with the value shown, in the Check Dynamic Lower Bound
block the Enable assertion and Output assertion signal are checked, and the icon type is selected as
graphic. The Convert block was inserted to convert the Boolean output of the Lower Bound block
to double as required by the Mux block.

Figure J.5. Model for Example J.5

J.6 Check Dynamic Upper Bound


The Check Dynamic Upper Bound block performs checks to verify that the amplitude of a test signal is greater than the amplitude of a reference signal. The test signal is the signal connected to the
input labeled sig. If the verification condition is true, the block takes no action. If not, simulation
is halted and an error message is displayed.
Example J.6
For the model in Figure J.6 the amplitude of a sinusoidal signal may vary 10% from its nominal
value of 1 volt . The model is configured to display error messages when the amplitude exceeds
+1 volt .
Introduction to Simulink with Engineering Applications, Third Edition
Copyright Orchard Publications

J5

Appendix K
ModelWide Utilities

his appendix presents a brief description of the Simulink ModelWide Utilities group. The
function of each block and their inputoutput signals are illustrated with examples. For
more information please refer to the Simulink documentation for each block.

K.1 TriggerBased Linearization


The TriggerBased Linearization block, when triggered (by an external signal, e.g., a Pulse Generator), invokes the MATLAB functions linmod or dlinmod to create a linear model for the system at
the current operating point. No trimming* is performed. The linear model is stored in the base
workspace with the name of the model appended by _Trigger_Based_Linearization, for instance,
Example01_Trigger_Based_Linearization. The structure has the fields shown in the Help menu
for this block.
Example K.1
We will use a TriggerBased Linearization block to extract the linear model for the model shown
in Figure K.1.

Figure K.1. Model for Example K.1

This is the same model as that in Figure D.4, Example D.3, Page D4, Appendix D, where with the
execution of the command [A,B,C,D]=linmod('Fig_D_04') the linear model in the form of the
statespace MATLAB displayed the four matrices as

* The trim function uses a Simulink model to determine steadystate points of a dynamic system that satisfy input, output, and state conditions that we can specify. For details please type help trim at the MATLAB command prompt.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

K1

Enable (added to subsystem block)

Figure L.18. Outputs when the Pulse Generator block is removed from the subsystem of Figure L.17

Figure L.19. The Enable block with the Show output selected

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

L15

Appendix L Ports & Subsystems


The library is saved, and a Configurable Subsystem block in the library which now appears as
shown in Figure L.28.

Figure L.28. The library with the addition of the Configurable Subsystem

We double click on Configurable Subsystem block in Figure L.28 and in the Configuration dialog
box we place check marks in the Member squares as shown in Figure L.29. The Port names pane
shows the inputs indicated as Inports. To see the outputs, we click the Outports tab.

Figure L.29. The Configuration dialog for the library of Example L.6

The Configurable Subsystem block now appears as shown in Figure L.30.

Figure L.30. Inports and outports of the Configurable subsystem block

We can now select either Subsystem 1A or Subsystem 2A from the Configuration dialog to implement the 4bit Adder by cascading four onebit adders. For this example we choose Subsystem 1A.

L20

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Configurable Subsystem
This is done by unselecting Subsystem 2A on the Configuration dialog box of Figure L.29 which
now appears as shown in Figure L.31.

Figure L.31. Configuration dialog box with Subsystem 1A selected

Now, a new model is created as shown in Figure L.32 by dragging the Configurable Subsystem 1A
block* from this library into this model, copy and paste this block three times, and we interconnect
these as shown in Figure L.32.

Figure L.32. Fourbit binary adder for Example L.6 with Subsystem 1A blocks

In the model of Figure L.32, the carry bit of the rightmost onebit adder is set to zero since there
is no previous onebit adder. We observe that Simulink displays small arrows on the bottom left
corner of each of the subsystem blocks. A small arrow indicates that each subsystem block represents a library link in the model, and it is only visible if the Library Link Display option of the Format menu is selected All.
* All four subsystem and constant blocks are flipped to indicate that the addition begins at the right side and proceeds to
the left.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

L21

Bus to Vector

Figure M.19. Model with the Signal Specification block acting as a virtual block

Figure M.20. Model where the attributes (sample times) of the Signal Specification block do not agree

M.10 Bus to Vector


The Bus to Vector block converts a virtual bus signal to a vector signal. The input bus signal must
consist of scalar, 1D, or either row or column vectors having the same data type, signal type, and
sampling mode. If the input bus contains row or column vectors, this block outputs a row or column vector, respectively; otherwise, it outputs a 1D array.
Example M.11
The Model (a) in Figure M.21 below uses the Bus Creator 1 block to Display the Pulse Generator 1
and Repeating Sequence 1 blocks in Scope 1 where we observe that the input to that Scope block is
a signal bus. In Model (b) the Bus Creator 1 block is replaced by a Mux block and we observe that
the input in Scope 2 block is a vector. In Model (c), instead of replacing the Bus Creator 3 block
with a Mux block, we have inserted the Bus to Vector block so that the input to the Scope 3 block
is now a vector. The parameters are as annotated in the model and all three Scope blocks display
the waveforms shown in Figure M.22.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

M13

Appendix N Signal Routing


Example N.3
The model in Figure N.9 computes and displays the 5-day moving averages of three particular securities. It performs the same function as the model in Example L.17, Section L.21, Page L-52, Appendix, using three Selector blocks, one for the moving average of each security.

Figure N.9. Model for Example N.3

For this model, the row vectors A, B, and C are entered at the MATLAB command prompt as follows:
A=[90 85 82 80 77]; B=[84 90 85 82 80]; C=[81 84 90 86 82];

The parameter dialog box for the Selector 1 block is shown in Figure N.10.

Figure N.10. Parameter dialog box for the Selector 1 block in Figure N.9

N6

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Appendix O Sinks

Figure O.12. Updated waveform for the model in Figure O.11

Example O.7
The model in Figure O.13 produces the curve in Figure O.15 and it is known as nephroid. It is
described by the equations
x = 0.5a ( 3 cos cos 3 )
y = 0.5a ( 3 sin sin 3 )

For this model, the value of a is entered at the MATLAB command prompt as a=2;

Figure O.13. Model for Example O.7

Two more examples with the XY Graph block presented in Section 5.1.6, Page 512, Chapter 5,
and Section 5.1.7, Page 515, Chapter 5.

O10

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Signal Builder
7. When we select a line segment on the time axis (xaxis) we observe that at the lower end of the
waveform display window the Left Point and Right Point fields become visible. We can then
reshape the given waveform by specifying the Time (T) and Amplitude (Y) points.
8. We can choose one of several waveforms listed in New under the Signal drop menu.
The menu bar at the top contains several icons that we could use to choose from and/or modify
our waveform.
Example P.5
We begin with a new model, we drag a Signal Builder block, we click it, and on the top bar we click
Signal>Replace with>Triangle wave>OK. We would like to change it to a symmetric triangle with
Period 2, and Amplitude varying from 1 to +1 as shown in Figure P.16 where we have specified
that the Time (T) and Amplitude (Y) points as (0,1), (1,1), (2,1), (3,1), (4,1), (5,1), (6,1), (7,1),
(8,1), (9,1), and (10,1). We could also use the Repeating Sequence block discussed in Section
P.13.

Figure P.16. Triangular waveform for Example P.4

To this model we add an Integrator block and a Scope block, and after the simulation command is
executed, the model of Figure P.17 displays the triangular waveform and its integrated waveform in
as shown.

Figure P.17. Model for Example P.5

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

P11

Appendix Q UserDefined Functions


y=(1/4)*cos(2*u(1))*log(sec(2*u(1))+tan(2*u(1)))+(2)*cos(2*u(1))+(3)*cos(2*u(1));

The Simulink documentation includes the Modeling Engine Timing Using Triggered Subsystems
demo. It can be accessed by typing sldemo_engine at the MATLAB command prompt, and clicking the Combustion block.

Q.2 Interpreted MATLAB Function


The MATLAB Fcn block applies the specified MATLAB function or expression to the input. For a
detailed description please refer to the Simulink documentation.
Example Q.2
In the model of Figure Q.2, the function in the parameters dialog box for the Interpreted MATLAB Function block is specified as eig and outputs the eigenvalues of Matrix A defined at the
MATLAB command prompt as:
A=[1 2 3; 2 3 4; 3 5 7];

Figure Q.2. Model for Example Q.2

Q.3 MATLAB Function


The MATLAB Function block contains a MATLAB language function in a Simulink model. For
more information and an example, please refer to the Simulink documentation.
Example Q.3
This example requires that a C or C++ compiler is installed in your system. To locate one or to
determine whether one is installed, at the MATLAB command prompt type
mex setup

For this example, the author used the Microsoft Visual C++ 2010 compiler.
In this example we will create a model using a MATLAB Function block to accept a 3 3 matrix
and output the value of its determinant and its inverse matrix.

Q2

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Appendix R
Additional Discrete

his appendix presents a brief description of the Simulink Additional Discrete group. The
function of each block and their inputoutput signals are illustrated with examples. For
more information please refer to the Simulink documentation for each block.

R.1 Transfer Fcn Direct Form II


The Transfer Fcn Direct Form II block implements a Direct Form II realization of the transfer
function specified by the Numerator coefficients and the Denominator coefficients without the
leading* coefficient in the Denominator.
Example R.1
The model in Figure R.1 implements the discretetime function
1

0.5276 1.5828z + 1.5828z H ( z ) = --------------------------------------------------------------------------1


2
1 1.7600z + 1.1829z

(R.1)

Figure R.1. Model for Example R.1

In Figure R.1, the Sample time for the Sine Wave block is specified as 0.1. The numerator and
denominator coefficients for the Transfer Fcn Direct Form II block are entered in the parameters
dialog box and the leading coefficient 1 in the denominator is excluded, that is, it is entered as
[ 1.7600 1.1829 ] .
The input and output waveforms are shown in Figure R.2.

* By lead we mean that the leading coefficient 1 in the denominator which has the form 1 + z1 + z 2 .

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

R 1

Appendix S Additional Math Increment / Decrement

Figure S.2. Model for Example S.2

S.3 Increment Stored Integer


The Increment Stored Integer block increases the stored integer value of a signal by one.
Example S.3
The model of Figure S.3 implements the function y = ( 2 + x ) sin x 1 for 0 x 10

Figure S.3. Model for Example S.3

S2

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Cross Correlator

Figure T.11. Model for Example T.11

The auto correlation signal above justifies the following two properties of the auto correlation function:
1. The auto correlation function is an even function, i.e., R xx ( ) = R xx ( )
2. The auto correlation function is maximum at the origin, i.e., R xx ( 0 ) R xx ( ) .

T.12 Cross Correlator


The crosscorrelation is similar in nature to the convolution* of two functions. Whereas convolution involves reversing a signal, then shifting it and multiplying by another signal, correlation only
involves shifting it and multiplying. The cross correlation of two signals x and y denoted as R xy ( )
where represents a time delay is defined as
1
R xy ( ) = lim --tp t p

tp

x ( t )y ( t ) dt

(19.2)

The cross correlation R xy ( ) is an indication of how well the signals x and y are correlated for a
particular value of the delay . If the cross correlation function peaks for a particular value of ,
this would indicate a very good correlation, which means that the two signals match each other very
* Convolution is discussed in Signals and Systems with MATLAB Computing and Simulink Modeling, ISBN 9781
934404119, Chapter 6.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

T13

Appendix U
Random Number Generation

his appendix is a short tutorial on Random Number Generation. An example is presented to


illustrate the sequence which most random generators use.

U.1 Random Numbers


Random numbers are used in many applications. Random number generation is the production of
an unpredictable sequence of numbers in which no number is any more likely to occur at a given
time or place in the sequence than any other. Truly random number generation is generally viewed
as impossible. The process used in computers would be more properly called pseudorandom number generation.

U.2 An Example
A typical random number generator creates a sequence in accordance with the following recurrence:
x n + 1 = P 1 x n + P 2 ( mod N ) n=0,1,2,

x 0 = seed

(U.1)

where mod N is used to indicate that the sum P 1 x n + P 2 is divided by N and then is replaced by the
remainder of that division. The values of x 0 (seed), P 1 , P 2 , and N must be specified. As an example, let
x0 = 1

P 1 = 281

P 2 = 123

N = 75

then, in MATLAB notation


x0=1, P1=281, P2=123, N=75
x1=P1*x0+P2, y1=mod(x1,N)
x2=P1*y1+P2, y2=mod(x2,N)
.............
xn=P1*y(n-1)+P2, yn=mod(xn,N)

To find the sequence of numbers for the random number generator, we use the following MATLAB
script:
P1=281; P2=123; N=75; x=1:100; y=zeros(100,2);
y(:,1)=x'; y(:,2)=mod((P1.*x+P2),N)'; fprintf(' x y \n'); disp(' ------');
fprintf('%3.0f\t %3.0f\n',y')

MATLAB outputs the following table:


Introduction to Simulink with Engineering Applications, Third Edition
Copyright Orchard Publications

U1

Appendix V
Exercises
Dear Reader:
The solutions to the exercises in this appendix can be found in Appendix W.
You must, for your benefit, make an honest effort to solve these exercises without first looking at the
solutions. You may need to review Appendices C through U and / or the blocks in the Simulink
documentation to locate suitable blocks for your models.
1. Use Simulink with the Step function block, the ContinuousTime Transfer Fcn block, and the
Scope block shown, to simulate and display the output waveform v C of the electric RLC circuit*
shown below where u 0 ( t ) is the unit step function, and the initial conditions are i L ( 0 ) = 0 , and
vC ( 0 ) = 0 .

+
u0 t

1H

iL

vC

1F

2. Repeat Exercise 1 using integrator blocks in lieu of the transfer function block.

* The electric circuits presented in this texts can be easily converted to their mechanical equivalent circuits where a voltage source can be replaced by a force f, a resistor can be replaced by a dashpot B, an inductor can be replaced by a
mass M, and a capacitor can be replaced by an inverse spring constant 1/K. Thus the mechanical analog of the electric circuit above can be converted to the mechanical system shown below.
1K

B
f

M
x1

x2

x3

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

V1

Appendix W
Solutions to the Exercises
1.
The sdomain equivalent circuit is shown below.

1 +
--s

Ls
V IN ( s )

+
1/sC

V C ( s ) = V OUT ( s )

and by substitution of the given circuit constants,

1 +
--s

s
V IN ( s )

+
1/s

V C ( s ) = V OUT ( s )

By the voltage division expression,


(s 1 s) (s + 1 s)
s
- V IN ( s )
V OUT ( s ) = --------------------------------------------------------- V IN ( s ) = --------------------2
(s 1 s) (s + 1 s) + 1
s +s+1

from which

V OUT ( s )
s
- = --------------------Transfer function = G ( s ) = ------------------2
V IN ( s )
s +s+1

We invoke Simulink from the MATLAB environment, we open a new file by clicking on the
blank page icon at the upper left on the task bar, we name this file Fig_W_01, and from the
Sources, Continuous, and Commonly Used Blocks in the Simulink Library Browser, we select
and interconnect the desired blocks as shown below.

As we know, the unit step function is undefined at t = 0 . Therefore, we double click the Step
block, and in the Source Block Parameters dialog box shown below we enter the values indicated. Likewise, we double click the Transfer Fcn block and in the Source Block Parameters dialog box we enter the values indicated.

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

W1

Appendix X Weighted Moving Average


2
Exponential Percentage = --------------------------------------------Time Periods + 1

(X.2)

For example, if we wanted a 20 period EMA, we would use


2
--------------- = 9.52 %
20 + 1

(X.3)

Example X.1
The price of a particular security (stock) over a 5day period is as follows:
77 80 82 85 90

where the last value is the most recent. We will create single-input / single output (SISO) model
with a Discrete FIR Filter block to simulate the weighted moving average over this 5day period.
For this example, we will represent the SISO output as follows:
y1 ( k ) = a1 u ( k ) + b1 u ( k 1 ) + c1 u ( k 2 ) + d1 u ( k 3 ) + e1 u ( k 4 )

(X.4)

u ( k ) = 5 15 u ( k 1 ) = 4 15 u ( k 2 ) = 3 15 u ( k 3 ) = 2 15 u ( k 4 ) = 1 15

(X.5)

where

The model is shown in Figure X.1 where in the Function Block Parameters dialog box for the Discrete FIR Filter block we have entered the parameters shown in Figure X.2.

Figure X.1. Model for Example X.1

Figure X.2. Parameters for the Discrete FIR Filter block in Figure X.1

X2

Introduction to Simulink with Engineering Applications, Third Edition


Copyright Orchard Publications

Index
Symbols

% (percent) symbol in MATLAB A-2


10^u I-11
3-bit Up / Down Counter model 5-23
4-bit Ring Counter model 5-24
A
Abs block I-10
abs(z) function in MATLAB A-22
accuracy J-10
acos I-16
acosh I-16
acquisition costs 2-19
Add block I-1
algebraic constraint block I-18
algebraic loop C-33
analog-to-digital conversion 2-9, 5-1, 5-3
angle(z) function in MATLAB A-22
annuity 2-16
applications to differential
equations 3-3, 4-1
asin I-16
asinh I-16
Assertion block J-8, L-17
Assignment block I-19
atan I-16
atan2 I-16
atanh I-16
Atomic Subsystem block L-3
auto correlator T-12
autoscale icon 1-12
Averaging Power Spectral Density T-16
Averaging Spectrum Analyzer T-17
axis command in MATLAB A-15
B
backlash E-11
ball thrown vertically upward 3-3
Band-Limited White Noise P-18
barge pulled by two horse groups 3-8
Bernoullis equation, example of 4-3
Bessel functions 5-8
bias block I-3
bilinear transformation F- 9, P-19
bilinear(Z,P,K,Fs) function P-20
Bit Clear block G-8, H-16
Bit Set block G-8
Bitwise Operator block G-9
Block Support Table block K-8, L-17
bouncing ball 2-1
box command in MATLAB A-12
bulk modulus 4-6
Bus Assignment block N-1
Bus Creator block C-10, N-1
bus editor C-16

Bus Selector block C-10, N-1


Bus to Vector block M-13

C
C MEX-file S-function Q-9
c2d function in MATLAB F-14
callback methods Q-8
canonical form 5-31
cantilever beam deflection 5-4
capillary tube 4-1
capital investment 2-20
Cartesian to Polar Transformation T-27
Cartesian to Spherical Transformation T-29
Cascade Form Realization 5-18
cascaded mass-spring system
Celsius to Fahrenheit Transformation T-29
Check Discrete Gradient block J-9, K-8
Check Dynamic Gap block J-7
Check Dynamic Lower Bound block J-4
Check Dynamic Range block J-6
Check Dynamic Upper Bound block J-5
Check Input Resolution block J-10
Check Static Gap block J-3
Check Static Lower Bound block J-1
Check Static Range Block J-2
Check Static Upper Bound block J-2
chemical solutions example 5-1
Chirp Signal block P-15
clc command in MATLAB A-2
clear command in MATLAB A-2
Clock block P-25
Clock for digital systems block T-20
closed-loop control systems 5-30
Code Reuse Subsystem block L-7
column vector in MATLAB A-17
Combinatorial Logic block G-4
command screen in MATLAB A-1
command window in MATLAB A-1
commas in MATLAB A-7
comment line in MATLAB A-2
commonly used blocks C-1
compare to constant block G-7
compare to zero block G-6
comparison of alternate proposals 2-15
complex conjugate in MATLAB A-4
complex numbers in MATLAB A-2
complex to magnitude-angle block I-23
complex to real-imag block I-25
configurable subsystem block L-17
Configuration Parameters 1-12
configuration parameters C-15
conical reservoir 12
conj (complex conjugate) I-11
Constant block C-7, P-2
Contents Pane 1-7
continuous mode I-17
control element 5-30

control input N-13


control signal L-1
controller 5-30
conv(a,b) function in MATLAB A-6
correlation time P-19
cosh I-16
cosine block H-16
cosine I-16
Coulomb and Viscous Friction E-18
Coulomb Friction E-18
Counter Free-Running block P-23
Counter Limited block P-24
critically damped motion 3-19
cross correlator T-13
D
D Flip Flop T-21
D Latch T-20
data inputs N-13
data points in MATLAB A-13
Data Store Memory block N-18
Data Store Read block N-18
Data Store Write block N-18
Data Type Conversion block C-40, M-1
data type conversion inherited M-8
data type duplicate M-4
Data Type Propagation block M-6
Data Type Propagation Examples M-14
Data Type Scaling Strip block M-7
data types C-40
dead zone block E-5
Dead Zone Dynamic block E-6
decimal-to-bcd encoder L-8
deconv(c,d) function in MATLAB A-6, 7
Decrement Real World block S-1
Decrement Stored Integer block S-3
Decrement Time To Zero block S-4
Decrement To Zero block S-3
default color in MATLAB A-14
default in MATLAB A-11
default line in MATLAB A-14
default marker in MATLAB A-14
Degrees to Radians Transformation T-30
demo in MATLAB A-2
Demux block C-18, N-4
depreciation 2-16
Derivative block D-1
Derivative for Linearization block D-5
describing functions E-20
Detect Change block G-14
Detect Decrease block G-14
Detect Fall Negative block G-17
Detect Fall Nonpositive block G-18
Detect Increase block G-13
Detect Rise Nonnegative block G-16
Detect Rise Positive block G-15
development costs 2-19

IN-1

Difference block F-11


differential equations 2-1
Direct Form Realizations of a
Digital Filter 5-16
Digital Clock block P-26
Digital Filter Realization Forms 5-16
digital multiplexer L-3
Direct Form-II Realization 5-17
Direct Lookup Table (n-D) block H-10
Discrete Derivative block F-12
Discrete Filter block F-8
discrete FIR filter F-21
discrete mode I-17
Discrete PID Controller block F-26
Discrete PID Controller (2DOF) F-28
Discrete State-Space block F-13
Discrete Time Integration model 5-37
discrete time system transfer function C-35
Discrete Transfer Fcn block F-5
Discrete Transfer Fcn with Initial Outputs T-2
Discrete Transfer Fcn with Initial States T-1
Discrete Zero-Pole (with initial outputs) T-5
Discrete Zero-Pole (with initial states) T-4
Discrete Zero-Pole block F-10
Discrete-Time Integrator block C-37
Discrete-Time Integrator block F-4
Display block 1-18, O-11
display formats in MATLAB A-29
Divide block I-6
Doc Text block K-8
dot multiplication operator in MATLAB A-19
Dot Product block I-8
E
Electric Circuit in Phasor Form
economic analysis 2-15
editor window in MATLAB A-1
editor/debugger in MATLAB A-1, 2
effective purchase price 2-16
electrical and mechanical
components - analogies of 5-25
element-by-element division
in MATLAB A-20
element-by-element exponentiation
in MATLAB A-20
element-by-element multiplication
in MATLAB A-17, A-19
Enable (added to subsystem block) L-11
Enable (description) L-1
Enable Subsystem block L-26
Enabled and Triggered Subsystem
block L-28
Enumerated Constant block P-2
Environmental Controller block N-10
eps in MATLAB A-21, 25
execution context bars L-32
execution context indicators L-31
exit command in MATLAB A-2
exp function I-11
exploration costs 2-19
exponential moving average F-22
Extract Bits block G-12

IN-2

F
Fahrenheit to Celsius Transformation T-29
Fcn block Q-1
Feedback Control Systems 5-30
figure window in MATLAB A-13
Find Nonzero Elements block I-30
finite impulse response (FIR)
digital filter F-8
first harmonic 16
First-Order Hold block F-25
Fixed-Point State-Space block R-3
flip block command 1-11
Floating Bar Plot T-18
Floating Scope block O-5
For Each Subsystem block L-52
For Iterator Subsystem block L-35
format command in MATLAB A-29
fplot command in MATLAB A-25
From block N-14
From File block P-1
From Workspace block P-1
Function Block Parameters 1-9
Function Call Split block L-57
function file in MATLAB A-25
Function Lookup Table Generation
block H-17
Function-Call Feedback Latch L-58
Function-Call Generator block L-2
Function-Ccall Subsystem block L-32
fundamental frequency H-16
fzero command in MATLAB A-25, 27
G
Gain block 1-18, C-25, I-5
geometric series 2-1
Goto block N-16
Goto tag visibility block N-15
grid command in MATLAB A-11
Ground block C-4, P-1
gtext(string) command in MATLAB A-13
H
half-wave symmetry H-17
heat flow example 5-3
help matlab ofun command in MATLAB A-2
hermitian function I-11
hide name C-2
Hit Crossing block E-16
hypot function I-11
I
IC (Initial Condition) block M-8
Idealized ADC Quantizer block T-7
If Action Subsystem block L-38
If block L-38
imag(z) function in MATLAB A-22
impulse response duration F-8
Increment Real World block S-1

Increment Stored Integer block S-2


increments between points in MATLAB A-13
Index Vector block N-8
infinite impulse response (IIR)
digital filter F-8
infinite series 2-1
Inport block C-1, L-1, P-1
insurance costs 2-16
Integer delay block F-1, F-3
Integrator block C-30, D-6
Integrator limited block D-6
Integrator second order D-8
Integrator second order limited D-11
interest 2-16
Interpolation (n-D) using prelookup block H-9
Interpreted MATLAB Function block Q-2
Interval test block G-2
Interval test dynamic block G-3
J
J-K Flip Flop T-22
L
labor costs 2-16
lag compensator F-18
lead compensator F-17
lead-lag compensator F-18
Legendres equation 5-9
Level-1 M-file S-functions L-59, Q-7
Level-2 M-file S-functions L-59, Q-7
linear programming 2-3
linearization. D-2
link library display L-21
linmod(x) D-2, D-4
linspace command in MATLAB A-13
liquid in a capillary tube 4-1
log I-11
log(x) function in MATLAB A-12
log10 function I-11
log10(x) function in MATLAB A-12
log2(x) function in MATLAB A-12
Logical operator block C-27, G-1
loglog(x,y) command in MATLAB A-12
Lookup table block H-1
Lookup table (2-D) block H-4
Lookup table (n-D) block H-5
Lookup table dynamic block H-15
M
magic sinewaves H-17
magnitude^2 function I-11
Magnitude-Angle to Complex block I-24
maintenance costs 2-16
Manual switch block N-12
mask B-1
mask editor B-1
mask icon B-1
mask parameters B-1
masked subsystem B-1

mass-spring-dashpot 5-25
materials costs 2-16
Math function block I-11
MATLAB demos A-2
MATLAB Fcn block Q-2
Matrix Concatenation block I-22
matrix multiplication in MATLAB A-17
mechanical accelerometer 5-29
mechanical and electrical
components - analogies of 5-25
Memory block F-24
Merge block N-9
mesh(x,y,z) command in MATLAB A-15
meshgrid(x,y) command in MATLAB A-16
Method of Frobenius 5-8
Method of Picard 5-8
m-file in MATLAB A-1, 25
M-file S-Functions L-59
MinMax block I-14
MinMax Running Resettable block I-15
mod I-11
Model block L-16, L-42
Model Info block K-6
Model Variants L-42
moving average F-22
moving ladder 2-10
Multiport Switch block N-13
Mux block C-18, N-4
N
NaN in MATLAB A-25
nephroid O-10
Newtons Second Law 3-1
nonlinear systems E-20
non-recursive realization
digital filter F-8
nonvirtual subsystems L-7, L-62
O
open--loop control systems 5-30
oscillatory motion 3-20
Outport block C-1, L-1, O-1
overdamped motion 3-20

Polar to Cartesian Transformation


block T-27
polar(theta,r) function in MATLAB A-22
poly(r) function in MATLAB A-4
polyder(p) function in MATLAB A-6, 7
Polynomial block I-13
polynomial construction from known
roots in MATLAB A-4
polyval(p,x) function in MATLAB A-5
port data types C-43, M-1
pow (power) function I-11
Power Spectral Density block T-14
precedence over C-28
Prelookup Index Search block H-8
Probe block M-15
Product block C-7, I-6
Product of Elements block I-7
pseudocode L-40
pseudorandom number generation. U-1
Pulse Generator block C-39, P-9
Q
Quantizer block E-15
quarter wave symmetry H-16
quit command in MATLAB A-2
R
Radians to Degrees Transformation T-30
Ramp block P-12
Random Number block P-16
random number generation example U-1
Random Number Generation U-1
Random numbers U-1
rate limiter block E-8
rate limiter dynamic block E-10
Rate Transition block M-10
rated speed of an automobile on a
highway curve 3-10
real world value C-41
real(z) function in MATLAB A-22
Real-Imag to C omplex block I-26

Parallel Form Realization of a


Digital Filter 5-20
paste duplicate inport C-4
Permute Dimensions block I-23
PID Controller Block D-12
PID Controller (2DOF) Block D-14
plant 5-30
plot(x,y) command in MATLAB A-9, 12
plot(x,y,'m*') command in MATLAB A-14
plot(x,y,'rs') command in MATLAB A-14
plot(x,y,'rs-') command in MATLAB A-14
plot(x,y,s) command in MATLAB A-14
plot3 command in MATLAB A-14
plot3(x,y,z) command in MATLAB A-14

real-time workshop L-62


reciprocal I-11
reciprocal sqrt I-29
recursive realization digital filter F-8
refresh button N-1
Relational Operator block C-26, G-1
relay block E-13
rem I-11
repairs costs 2-16
Repeating Sequence block P-14
Repeating Sequence Interpolation
block P-22
Repeating Sequence Stair block P-21
Reshape block I-20
resolution J-10
restoration costs 2-19
roots of polynomials in MATLAB A-3
roots(p) function in MATLAB A-3, 7, 8
round(n) function in MATLAB A-22

polar plot in MATLAB A-23

Rounding Function block I-12

row vector in MATLAB A-3, 17


Running Simulink 1-7
rwv (real world value) C-41
S
Saturation block C-28, E-1
Saturation Dynamic block E-4
Scope block 1-12, C-9, O-4
script file in MATLAB A-25
second harmonic H-16
seed U-1
Selector block N-5
semicolons in MATLAB A-7
semilogx command in MATLAB A-12
semilogx(x,y) command in MATLAB A-12
semilogy command in MATLAB A-12
semilogy(x,y) command in MATLAB A-12
Series Form Realization of a Digital Filter
S-Function block L-62, Q-6
S-Function Builder block Q-9
S-Function Examples block Q-10
S-Function Examples 5-39, 5-41
S-functions L-59
Shift Arithmetic block G-11
SI (Stored Integer) C-41
Sign block I-9
Signal Builder block P-10
Signal Conversion block M-9
signal displays C-43, M-1
Signal Generator block P-7
Signal Specification block M-12
signals in the bus N-1
signals that are being assigned N-1
Signed Sqrt blockI-28
simout To Workspace block 1-13, C13
simple oscillator 5-13
simple pendulum 5-11
Simulation drop menu 1-12
simulation start icon 1-12
Simulink icon 1-7
Sine Lookup block H-16
sine trig function I-16
Sine Wave block P-12
Sine Wave function block I-17
sinh function-16
Sinks library 1-18
slew rate E-8
Slider Gain block I-5
Spectrum Analyzer block T-17
Spherical to Cartesian Transformation
block T-28
spring fastened to a rigid support 3-17
Sqrt block I-27
Square bIock I-11
Squeeze block I-20
S-R Flip Flop T-21
start simulation 1-12, C-8
State-Space (with initial outputs)
block T-11
State-Space block 1-12, D-9
Step block P-14
Stop Simulation block O-12

IN-3

stored integer (SI) C-41


string command in MATLAB A-15
subplot(m,n,p) command in MATLAB A-16
subsystem C-1
Subsystem block L-1
Subsystem Examples block L-59
subsystem semantics L-61
Subtract block I-2
Sum block C-23, I-1
Sum of Elements block I-3
Superposition Principle, example of 5-34
supplies costs 2-16
Switch block C-21, N-14
Switch Case Action Subsystem L-40
Switch Case block L-40
Switched Derivative for Linearization T-23
block T-23
Switched Transport Delay for Linearization
block T-25
T
tangent function I-16
tanh function I-16
Tapped Delay block F-3
Taylor series D-2
terminator block C-6
Terminator block C-6, O-1
text(x,y,string) command in MATLAB A-13
text(x,y,z,string) command in MATLAB A-15
thermal noise P-18
third harmonic H-16
Time-based Linearization block K-3, L-28
title(string) command in MATLAB A-12
To File block O-1
To Workspace block O-3
tractrix curve example 5-7
train traveling on a 3 per cent grade 3-12
Transfer Fcn block D-22
Transfer Fcn (with initial outputs)
block T-9
Transfer Fcn (with initial states)
block T-8
Transfer Fcn Direct Form II block 5-17
Transfer Fcn Direct Form II block R-1
Transfer Fcn Direct Form II Time Varying
block R-2
Transfer Fcn First Order block F-16
Transfer Fcn Lead or Lag block F-17
Transfer Fcn Real Zero block F-20
Transport Delay block D-29
transpose function I-11
Tree Pane 7
Trigger block L-1
Trigger-Based Linearization block M-8
block K-1, L-35, M-8
Triggered Subsystem block L-23
Trigonometric Function block I-16
U
Unary minus block I-10
IN-4

underdamped motion 3-20


Uniform Random Number block P-17
Unit Delay block C-35, F-1
Unit Delay Enabled block R-7
Unit Delay Enabled External
IC (Initial Condition) block R-9
Unit Delay Enabled Resettable block R-8
Unit Delay Enabled Resettable
External IC block R-10
Unit Delay External IC block R-4
Unit Delay Resettable block R-5
Unit Delay Resettable External IC block R-6
Unit Delay With Preview Enabled block R-13
Unit Delay With Preview Enabled
Resettable block R-14
Unit Delay With Preview Enabled
Resettable External RV block R-15
Unit Delay With Preview
Resettable block R-11
Unit Delay With Preview Resettable
External RV block R-12
unity feedback system 5-30
update diagram C-2
utilities costs 2-16
V
valuation of depleting asset 2-19
Van der Pol Differential Equation
Variable Time Delay block D-29
Variable Transport delay blok D-29
Variant Subsystem L-49
Vector Concatenate block C-49, I33, N-20
viscous friction E-18
W
weighted moving average F-22
Weighted Sample Time block M-17
weighted sample time math block I-4
while iterator subsystem block L-36
white light P-18
white noise P-18
Width block M-18
Workspace block C-13
Wrap to Zero block E-19
X
xlabel(string) command in MATLAB A-12
XY Graph block O-9
Y
ylabel(string) command in MATLAB A-12

Z
Zero-Order Hold and First-Order Hold
as Reconstructors 5-14
Zero-Order Hold block F-26
Zero-Pole (with initial outputs) block T-11

Zero-Pole (with initial states) block T-10


Zero-Pole block D-25

S-ar putea să vă placă și