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.
101
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.
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
-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.
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
103
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
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
105
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,:);
The Model Info block displays revision control information about a model as an annotation block
in the model's block diagram.
106
f ( z ) = z + 4z + 3 + sin z z cos z
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
107
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
This message will be displayed on MATLABs Editor whenever we double click on the Doc Text
block in the model of Figure 10.8.
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.
109
1010
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.
1011