Simulink Basics Tutorial - Block Libraries
Sources
Sinks
Discrete
Linear
Nonlinear
Connections
Simulink contains a large number of blocks from which models can be
built. These blocks are arranged in Block Libraries which are
accessed in the main Simulink window shown below

Each icon in the main Simulink window can be double clicked to bring
up the corresponding block library. Blocks in each library can then
be dragged into a model window to build a model.
Sources
Source Blocks are used to generate signals. Double-click on
the Sources icon in the main Simulink window to bring up the
Sources window.

Notice that all of the source blocks have a single output and no
inputs. While parameters in each of these blocks in the library can be
modified by double-clicking the block, it is best to not modify the
blocks until they have been copied into a model window.
In order to examine these blocks, create a new model window (select
New from the File menu in the Simulink window or
hit Ctrl+N).

Constant
The Constant Source Block simply generates a constant signal. The
constant output value is displayed in the middle of the block, with a
default value of 1.
To use this block, drag it from the Sources window into your new model
window.

To change the constant output value, double-click on the block in your
model window to bring up the following dialog box.

Change the constant value field from 1 to some other value, say, 5,
and close the dialog box. Your model window will reflect the update by
displaying a 5 in the middle of the constant block.
Signal Generator
The Signal Generator Source Block is a general-purpose source which
encompasses some of the other blocks' functions. It generates periodic
waveforms such as sine, square, and sawtooth waves as well as a random
signal. Drag this block from the Sources window to your model
window.

By default, the Signal Generator generates a sine wave with an
amplitude of 1 and a frequency of 1 Hz. To change this, double-click
the Signal Generator in your model window to bring up the following
dialog box.

The Amplitude and Frequency can be changed in this dialog box, as well
as the type of waveform. To change the waveform, click on the
Waveform field to bring up a list of possible waveforms.

The desired waveform can be selected from this list.
Ramp
The Ramp Source Block generates a signal which is initially constant and
begins to increase (or decrease) at a constant rate at a specified
time. The slope, start time, and initial output can be specified.
Sine Wave
The Sine Wave Source Block generates a sinusoidal signal. The
Amplitude and Frequency can be specified, as well as the Phase (unlike
the Signal Generator). There is a fourth parameter, the Sample Time,
which can be used to force the Sine Wave Source to operate in
discrete-time mode (more about Discrete Time systems
in Simulink later.)
Step
As described earlier, the Step Source Block generates a step
function. The initial and final values can be specified, as well as
the step time.
Chirp Signal
The Chirp Signal Source Block generates a sinusoidal signal which
scans over a range of frequencies. The initial and final frequencies
as well as the scan time can be specified. The amplitude is always 1,
and the chirp signal repeats itself after each frequency scan.
Pulse Generator
The Pulse Generator Source Block generates a pulse train of varying
duty cycle. The signal switches between 0 and the specified value
starting at a particular time. The Period, Duty Cycle, Amplitude, and
Start Time can be specified.
Repeating Sequence
An arbitrary set of points (t,y) can be specified. These points are
entered as a vector specifying the time values, and a vector
specifying the corresponding output values at those times. The output
is linearly interpolated between the specified time values. At the
last time value, the output immediately starts over, possibly with a
discontinuous transition.
Clock
The Clock Source Block generates a signal equal to the current time in
the simulation. This is useful when the output of a simulation is
exported to MATLAB but occurs at uneven time steps. The clock's
output reflects the times at which the other signals outputs occur.
Digital Clock
The Digital Clock Source Block generates a strictly periodic time
signal at a specified sampling interval.
From File
The From File Source Block outputs a signal taken from a specified
.mat file. A matrix saved in MATLAB as a .mat file will become a
signal where the first row of the matrix specifies the time values.
This is similar to the Repeating Sequence Source Block.
From Workspace
The From Workspace Source Block is identical to the From File Source
Block except the values are taken from a variable (or expression) in
the MATLAB Workspace.
Random Number
The Random Number Source Block generates a sequence of random numbers
generated with the specified random number seed. Because of the seed,
the same sequence can be applied to more than one simulation.
Band-Limited White Noise
The Band-Limited White Noise Source Block generates a random signal
which changes at a specified sample period. The strength of the
signal and a random number seed can also be specified.
Sinks
Sink Blocks are used to display or output signals.
Double-click on the Sinks icon in the main Simulink window to
bring up the Sinks window.

Notice that all of the sink blocks have inputs and no outputs. Most
have a single input.
Scope
The Scope Sink Block was described earlier. It is used to display a
signal as a function of time.
XY Graph
The XY Graph Sink Block plots one signal against another. It is
useful for phase-plane plots, etc.
Display
The Display Sink Block is a digital readout of a signal at the current
simulation time.
To File
The To File Sink Block saves a signal to a .mat file in the same way
that the From File Source Block reads from a file. The sampling time
can be specified, but is not necessary.
To Workspace
The To Workspace Sink Block stores a signal in a specified workspace
variable. Unlike the To File Sink Block, the time is not saved in the
variable, and must be stored separately.
Stop Simulation
This is a special control block which is triggered to stop the current
simulation when its input is non-zero.
Discrete
Discrete Blocks are elements of discrete time dynamic systems.
Double-click on the Discrete icon in the main Simulink window to
bring up the Discrete window.

In order for these block to interact with continuous time blocks
(sources and sinks, for example) the sample time can be specified in
all of the Discrete Blocks.
Unit Delay
The Unit Delay's output is equal to the input delayed by one sample time.
Discrete-Time Integrator
This is the discrete time approximation of a continuous-time integrator. The
approximation method can be specified as well as the initial condition
and saturation limits.
Zero-Order Hold
Outputs a stepwise-constant version of the input signal with a
specified sampling period.
First-Order Hold
Outputs a piecewise-linear version of the input signal with a
specified sampling period.
Discrete State-Space
This is a discrete-time dynamic system in state-space form. A, B, C,
and D matrices can be specified, as well as initial conditions.
Discrete Filter
This is a discrete-time filter in rational function form. Vectors
containing coefficients of the polynomials in z^-1 are specified.
Discrete Transfer Fcn
This is the standard form of a SISO LTI discrete time system. The
transfer function polynomials are represented as coefficient vectors in
terms of z.
Discrete Zero-Pole
A discrete-time transfer function can be represented as list of z-plane
poles and zeros. The gain can also be specified.
Linear
Linear Blocks are elements of linear continuous-time dynamic
systems. Double-click on the Linear icon in the main
Simulink window to bring up the Linear window.

Gain
This is a scalar or vector gain. The specified gain multiplies the
input. The output is either a scalar or vector signal following
normal vector-scalar multiplication rules.
Sum
The Sum Block adds (or subtracts) two (or more) signals and outputs
their sum (or difference). The two inputs must either all be scalars,
or all be vectors of the same dimension. The output is the same
dimension as the inputs.
Drag this block into your model window and double click on it,
bringing up the following dialog box.

By default, the Sum block adds two signals. The list of signs field
represents both the number of inputs and whether to add or subtract
them. To make the Sum block add two signals and subtract a third,
change the list of signs to the following:
++-
Each element in the list corresponds to one of the signals. Close the
dialog box. The Sum block in your model window should now have three
inputs, one of which has a minus sign as shown below.

Integrator
The output of the Integrator is the integral of the input. An initial
condition can be specified, as well as saturation limits. This block
is very useful for modeling systems.
Transfer Function
Numerator and denominator polynomials can be specified to create a
standard SISO LTI system transfer function.
State Space
A, B, C, and D matrices can be specified to create a LTI state space
system. Inputs and outputs may be vector signals depending on the
sizes of the matrices.
Zero-Pole
Vector lists of zeros and poles can be specified to create a transfer
function. DC gain is also specified.
Derivative
The output is equal to the derivative of the input.
Dot Product
The output is equal to the dot product of two vector signals.
Matrix Gain
The output is equal to the input times a specified constant matrix.
The size of the input and output vector signals must match the size of
the matrix.
Slider Gain
This multiplies the input by a scalar constant which is specified by
moving a slider on the screen as shown below. The limits of the
slider can be specified.

Nonlinear
Nonlinear Blocks are elements of nonlinear continuous-time
dynamic systems. Most of these have special-purpose applications and
will not be used in the tutorials. Only the most relevant Nonlinear
blocks will be discussed here. Double-click on the Nonlinear
icon in the main Simulink window to bring up the Nonlinear window.

Elementary Math
The output of this block is a basic mathematical function applied to
the input. Copy this block into your model window and double click on
it. The resulting dialog box has one field, which when clicked on,
give the following menu of functions.

The desired function can be selected from the list, and the choice
will be displayed in the block in your model window.
Product
The output is equal to the product of the inputs. The number of
inputs can be specified.
Fcn
Arbitrary MATLAB expressions can be represented by this block.
Connections
Connection Blocks are used to organize and combine signals and
systems. These also have special purpose applications, and only some
of these will be described here. Double-click on the Connections
icon in the main Simulink window to bring up the Connections window.

Subsystem, In, Out
The Subsystem block is used as a system "macro", where one Subsystem
block can be used to represent an entire set of blocks. When
double-clicked, the subsystem block brings up a blank model window.
Note that the Subsystem block has no inputs or outputs. For each input
a Subsystem has, an In block is used. For each output a Subsystem
has, an Out block is used. For more information on Subsystems and In
and Out blocks, see the Interaction with
MATLAB tutorial page. For an example of the creation of a
subsystem, see the DC Motor
Speed Modeling in Simulink example (as well as other examples.)
Mux, Demux
The Mux (Multiplexer) block is used to combine two or more scalar
signals into a single vector signal. Similarly, a Demux
(Demultiplexer) block breaks a vector signal into scalar signal
components. The number of vector components must be specified in each
case. For an example of the use of a Mux block see the Bus Suspension Modeling in
Simulink example.
- Tutorials
-
MATLAB Basics |
MATLAB Modeling |
PID |
Root Locus |
Frequency Response |
State Space |
Digital Control |
Simulink Basics" |
Simulink Modeling |
Examples
