Anda di halaman 1dari 11

Chapter 10

The ModelWide Utilities Library

his chapter is an introduction to the ModelWide Utilities library. This is the ninth library
in the Simulink group of libraries and contains the Linearization of Running Models Sub
Library, the Documentation SubLibrary, and the Modeling Guides SubLibrary. We
will describe the function of each block included in this library and we will perform simulation
examples to illustrate their application.

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

101

Chapter 10 The ModelWide Utilities Library


10.1 The Linearization of Running Models SubLibrary
The Linearization of Running Models SubLibrary contains the blocks described in Subsections
10.1.1 and 10.1.2 below.

10.1.1 The TriggerBased Linearization Block

The TriggerBased Linearization block, when triggered, invokes the MATLAB functions linmod or dlinmod to create a linear model for the system. No trimming* is performed. The linear
model is stored in the base workspace as a structure, along with information about the operating
point at which the snapshot was taken. Multiple snapshots are appended to form an array of structures.
The name of the structure used to save the snapshots is the name of the model appended by
_Trigger_Based_Linearization, for example, vdp_Trigger_Based_Linearization. The structure has
the fields shown in the Help menu for this block.
Example 10.1
We will use a TriggerBased Linearization block to extract the linear model for the model shown
in Figure 10.1.

Figure 10.1. Model for Example 10.1

This is the same model as that of Figure 3.4, Example 3.2, Chapter 3, Page 34, where with the
execution of the command [A,B,C,D]=linmod('Figure_3_4') the linear model in the form of the
statespace MATLAB displayed the four matrices as
A =
* 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 in MATLABs Command
Window.

102

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The Linearization of Running Models SubLibrary


-5

-6

-1

1
0

0
1

-2

B =
1
0
0
C =
0

D =
0
and thus the model of Figure 10.1 can be represented as
x =

5 6 1
1
x
+
1 0 0
0 u
0 1 2
0

y = 0 1 0 x+ 0 u

Next, let us reconsider the model of Figure 10.1 shown as Figure 10.2 where we have included a
TriggerBased Linearization block triggered by a Pulse Generator block whose period is arbitrarily
specified for 10 seconds.

Figure 10.2. Model for Example 10.1 with TriggerBased Linearization

For the model of Figure 10.2, we execute the simulation command, we save this model as
Figure_10_2.mdl, and in MATLABs Command Window we type and execute the command
Figure_10_2_Trigger_Based_Linearization

MATLAB displays the following:


Figure_10_2_Trigger_Based_Linearization =
a: [3x3 double]
b: [3x1 double]
Introduction to Simulink with Engineering Applications
Copyright Orchard Publications

103

Chapter 10 The ModelWide Utilities Library


c: [0 1 0]
d: 0
StateName: {3x1 cell}
OutputName: {'Figure_10_2/Out1'}
InputName: {'Figure_10_2/In1'}
OperPoint: [1x1 struct]
Ts: 0
We observe that a, b, c, and d indicate the sizes of the statespace matrices A, B, C, and D
respectively.

10.1.2 The TimeBased Linearization Block

The TimeBased Linearization block invokes the MATLAB functions linmod or dlinmod to
create a linear model for the system when the simulation clock reaches the time specified by the
Linearization time parameter. No trimming is performed. The linear model is stored in the base
workspace as a structure, along with information about the operating point at which the snapshot
was taken. Multiple snapshots are appended to form an array of structures.
The name of the structure used to save the snapshots is the name of the model appended by
_Timed_Based_Linearization, for example, vdp_Timed_Based_Linearization. The structure has
the fields shown in the Help menu for this block.
Example 10.2
The model shown in Figure 10.3 is the same model as that of Figure 10.1, Example 10.1. We will
use a Time-Based Linearization block to extract its linear model.
We begin by adding a Time-Based Linearization block with the linearization time arbitrarily set
for 2 seconds, and the new model is now as shown in Figure 10.4.

104

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The Linearization of Running Models SubLibrary

Figure 10.3. Model for Example 10.2

Figure 10.4. Model for Example 10.2 with TimedBased Linearization block

For the model of Figure 10.4, we execute the simulation command, we save this model as
Figure_10_2.mdl, and in MATLABs Command Window we type
Figure_10_4_Timed_Based_Linearization

and when this command is executed MATLAB displays the following:


Figure_10_4_Timed_Based_Linearization =
a: [3x3 double]
b: [3x1 double]
c: [0 1 0]
d: 0
StateName: {3x1 cell}
OutputName: {'Figure_10_4/Out'}
InputName: {'Figure_10_4/In'}
OperPoint: [1x1 struct]
Ts: 0
We observe that a, b, c, and d indicate the sizes of the state-space matrices A, B, C, and D
respectively.

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

105

Chapter 10 The ModelWide Utilities Library


We can use state and simulation time logging to extract the model states and inputs at operating
points. For example, suppose that we want to get the states of the Figure_10_4 model at linearization times of 3 seconds and 7 seconds. This can be done with the following steps:
1. We open the model and drag an instance of this block from the ModelWide Utilities library
and drop the instance into the model.
2. We open the block's parameter dialog box and set the Linearization time to [ 3 7 ] .
3. We open the model's Configuration Parameters dialog box from the Simulation drop menu and
we select the Data Import/Export pane.
4. We check States and Time on the Save to Workspace control panel, we leave all other parameters in their default state, and we click on OK to confirm the selections and close the dialog
box.
5. We start the simulation.
6. At the end of the simulation, we type and execute whos in MATLABs Command Window,
and the following variables appear in the MATLAB workspace:
Figure_10_4_Timed_Based_Linearization, tout, and xout.
7. We obtain the indices to the operating point times by entering and executing the following in
MATLABs Command Window:
ind1 = find(Figure_10_4_Timed_Based_Linearization(1).OperPoint.t==tout);
ind2 = find(Figure_10_4_Timed_Based_Linearization(1).OperPoint.t==tout);

We type and execute whos in MATLABs Command Window, and the indices ind1 and ind2
are now included in the MATLAB workspace:
8. We obtain the state vectors at the operating points by entering and executing the following in
MATLABs Command Window:
x1 = xout(ind1,:); x2 = xout(ind2,:);

10.2 The Documentation SubLibrary


The Documentation SubLibrary contains the blocks described in Subsections 10.2.1 and 10.2.2
below.

10.2.1 The Model Info Block

The Model Info block displays revision control information about a model as an annotation block
in the model's block diagram.

106

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The Documentation SubLibrary


Example 10.3
The model in Figure 10.5 solves the non-linear equation
2

f ( z ) = z + 4z + 3 + sin z z cos z

Figure 10.5. Model for Example 10.3

We would like to add a Model Info block to indicate that this model was created by John Smith
on 02/16/06 and was last modified by Bill Johnson on 04/27/06.
We drag a Model Info block into the model of Figure 10.5, we doubleclick it, and on the Model
Info dialog box shown in Figure 10.6 we enter the desired information. The model now appears as
shown in Figure 10.7.

Figure 10.6. Model Properties and Text for the Model Info block

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

107

Chapter 10 The ModelWide Utilities Library

Figure 10.7. Updated model for Example 10.3

10.2.2 The Doc Text Block

The Doc Text block or DocBlock allows us to create and edit text that documents a model and
save that text with the model. To create a file that contains relevant text, we doubleclick on this
block to open the file in the text editor that we have selected in the MATLAB Preferences dialog
box. We use the text editor to modify the text and save the file. Simulink stores the contents of
the saved file in the model file block.
Example 10.4
In Figure 10.8 the DOC Text block is provided to justify the necessity for the Data Type Conversion block. Let us insert appropriate text for justification.
We double-click on the DOC Text block and in the Text Editor we replace the displayed message
with the following text:
The Convert block was inserted to convert the Boolean output of the
Check Dynamic Gap to double as required by the Bus Creator block.

108

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The Modeling Guides SubLibrary

Figure 10.8. Model for Example 10.4

This message will be displayed on MATLABs Editor whenever we double click on the Doc Text
block in the model of Figure 10.8.

10.3 The Modeling Guides SubLibrary


The Modeling Guides Sub-Library contains only the Block Support Table which is described
below.

The Block Support Table block includes a table which describes the data types that are supported by blocks in the main Simulink library. All blocks that can generate code contain an "X" in
the column titled "Code Generation Support". A subset of these blocks is not recommended for
production code as flagged by Note N6. Guidelines to determine when a block is recommended
for production code are listed below the table. Some blocks include caveats and notes that should
be taken into account when they are used. Caveats and notes are indicated in the table by "C#"
and "N#", respectively, and are described below the table.
Example 10.5
For the model of Figure 10.9, we will determine the types of data the Clock, Signal Generator, and
the Scope blocks will accept.

Figure 10.9. Model for Example 10.5

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

109

Chapter 10 The ModelWide Utilities Library


We doubleclick on the Block Support Table block and from the table displayed we find that the
Clock and Signal Generator blocks will accept the double data type but as noted by Note N6 neither is recommended for production code. The Scope block will accept all data types listed in the
table.

1010

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

Summary
10.4 Summary
The TriggerBased Linearization block, when triggered, invokes the MATLAB command
linmod or dlinmod to create a linear model for the system.
The TimeBased Linearization block invokes the MATLAB command linmod or dlinmod
to create a linear model for the system when the simulation clock reaches the time specified by
the Linearization time parameter.
The Model Info block The Model Info block displays revision control information about a
model as an annotation block in the model's block diagram.
The Doc Text block or DocBlock allows us to create and edit text that documents a model
and save that text with the model.
The Block Support Table block describes the data types that are supported by blocks in the
main Simulink library.

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

1011