Page 1
Extras: Simulink Basics Tutorial Block Libraries
Contents
Commonly Used Blocks
Continuous
Discontinuities
Discrete
Logic and Bit Operations
Math Operations
Sinks
Sources
Simulink contains a large number of blocks from which models
can be build. 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.
Commonly Used Blocks
Commonly Used Blocks are used to list a lot of blocks which are
usually used. Doubleclick on the Commonly Used Blocks icon in
the main Simulink windows to bring up the Commonly Used
window.
SYSTEM
MODELING
ANALYSIS
CONTROL
PID
ROOT LOCUS
FREQUENCY
STATESPACE
DIGITAL
SIMULINK
MODELING
CONTROL
Page 2
window.
Bus Creator
The Bus Creator block combines a set of signals into a bus.
Bus Selector
The Bus Selector block outputs a specified subset of the elements
of the bus at its input. The block can output the specified elements
as separate signals or as a new bus.
Constant
The Constant block generates a real or complex constant value.
The constant output value is displayed in the middle of the block,
with a default value of 1.
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).
To use this block, drag it from the Commonly Used Blocks window
Page 3
into your new model window.
To change the constant output value, doubleclick 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.
Data Type Conversion
The Data Type Conversion block converts an input signal of any
Simulink data type to the data type you specify for the Output data
type parameter. The input can be any real or complexvalued
signal.
Demux, Mux
Page 4
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.
DiscreteTime Integrator
This is the discrete time approximation of a continuoustime
integrator. The approximation method can be specified as well as
the initial condition and saturation limits.
Gain
The Gain block multiplies the input by a constant value (gain). The
input and the gain can each be a scalar, vector, or matrix.
Ground
The Ground block connects to blocks whose input ports do not
connect to other blocks.
In1
Inport blocks are the links from outside a system into the system.
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 in Simulink.
Logical Operator
The Logical Operator block performs the specified logical
operation on its inputs. An input value is TRUE (1) if it is nonzero
and FALSE (0) if it is zero.
Out1
Outport blocks are the links from a system to a destination outside
the system.
Product
By default, the Product block outputs the result of multiplying two
inputs: two scalars, a scalar and a nonscalar, or two nonscalars
that have the same dimensions.
Relational Operator
Page 5
Relational Operator
By default, the Relational Operator block compares two inputs
using the Relational operator parameter that you specify. The first
input corresponds to the top input port and the second input to the
bottom input port.
Saturation
The Saturation block imposes upper and lower limits on an input
signal.
Scope
The Scope block displays inputs signals with respect to simulation
time.
Subsystem
A Subsystem block represents a subsystem of the system that
contains it. The Subsystem block can represent a virtual
subsystem or a nonvirtual subsystem.
Sum
The Sum block performs addition or subtraction on its inputs. This
block can add or subtract scalar, vector, or matrix inputs. It can
also collapse the elements of a signal.
Switch
The Switch block passes through the first input or the third input
based on the value of the second input. The first and third inputs
are called data inputs. The second input is called the control input.
Terminator
Use the Terminator block to cap blocks whose output ports do not
connect to other blocks.
Unit Delay
The Unit Delay block holds and delays its input by the sample
period you specify. This block is equivalent to the z1 discretetime
operator.
Vector Concatenate
The Concatenate block concatenates the signals at its inputs to
create an output signal whose elements reside in contiguous
locations in memory.
Page 6
Continuous
Continuous Blocks are elements of continuoustime dynamic
systems. Doubleclick on the Continuous icon in the main
Simulink window to bring up the Continuous window.
Derivative
The output is equal to the derivative of the input.
Integrator Limited
The Integrator Limited block is identical to the Integrator block with
the exception that the output of the block is limited based on the
upper and lower saturation limits.
Integrator, SecondOrder, Integrator, SecondOrder Limited
The SecondOrder Integrator block and the SecondOrder
Integrator Limited block solve the secondorder initial value
problem
PID Controller
The PID Controller block output is a weighted sum of the input
signal, the integral of the input signal, and the derivative of the
input signal. The weights are the proportional, integral, and
derivative gain parameters.
PID Controller (2DOF)
The PID Controller (2DOF) block generates an output signal
based on the difference between a reference signal and a
measured system output.
State Space
Page 7
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.
Transfer Function
Numerator and denominator polynomials can be specified to
create a standard SISO LTI system transfer function.
Transport Delay
The Transport Delay block delays the input by a specified amount
of time. You can use this block to simulate a time delay. The input
to this block should be a continuous signal.
Variable Time Delay, Variable Transport Delay
The Variable Transport Delay and Variable Time Delay appear as
two blocks in the Simulink block library. However, they are the
same Simulink block with different settings of a Select delay type
parameter. Use this parameter to specify the mode in which the
block operates.
ZeroPole
The ZeroPole block models a system that you define with the
zeros, poles, and gain of a Laplacedomain transfer function. This
block can model singleinput single output (SISO) and singleinput
multipleoutput (SIMO) systems.
Discontinuities
Discontinuities Blocks are elements of discontinuoustime
dynamic systems. Most of these have specialpurpose
applications and will not be used in the tutorials. Only the most
relevant Discontinuities blocks will be discussed here. Double
click on the Discontinuities icon in the main Simulink window to
bring up the Discontinuities window.
Page 8
Backlash
The Backlash block implements a system in which a change in
input causes an equal change in output. . However, when the
input changes direction, an initial change in input has no effect on
the output.
Coulomb & Viscous Friction
The Coulomb and Viscous Friction block models Coulomb (static)
and viscous (dynamic) friction. The block models a discontinuity at
zero and a linear gain otherwise.
Dead Zone
The Dead Zone block generates zero output within a specified
region, called its dead zone.
Dead Zone Dynamic
The Dead Zone Dynamic block dynamically bounds the range of
the input signal, providing a region of zero output.
Hit Crossing
The Hit Crossing block detects when the input reaches the Hit
crossing offset parameter value in the direction specified by the Hit
crossing direction property.
Quantizer
The Quantizer block passes its input signal through a stairstep
function so that many neighboring points on the input axis are
mapped to one point on the output axis.
Rate Limiter
The Rate Limiter block limits the first derivative of the signal
passing through it. The output changes no faster than the specified
limit.
Rate Limiter Dynamic
The Rate Limiter Dynamic block limits the rising and falling rates of
the signal.
Page 9
Relay
The Relay block allows its output to switch between two specified
values. When the relay is on, it remains on until the input drops
below the value of the Switch off point parameter. When the relay
is off, it remains off until the input exceeds the value of the Switch
on point parameter. The block accepts one input and generates
one output.
Saturation Dynamic
The Saturation Dynamic block bounds the range of an input signal
to upper and lower saturation values.
Wrap To Zero
The Wrap To Zero block sets the output to zero when the input is
above the Threshold value. However, the block outputs the input
when the input is less than or equal to the Threshold.
Discrete
Discrete Blocks are elements of discrete time dynamic systems.
Doubleclick on the Discrete icon in the main Simulink window to
bring up the Discrete window.
Delay
The Delay block delays an input u according to the Delay length
parameter, which you specify on the dialog box, or a delay length
that a signal supplies to the d input port.
Difference
The Difference block outputs the current input value minus the
Page 10
previous input value.
Discrete Derivative
The Discrete Derivative block computes an optionally scaled
discrete time derivative.
Discrete Filter
This is a discretetime filter in rational function form. Vectors
containing coefficients of the polynomials in z^1 are specified.
Discrete FIR Filter
The Discrete FIR Filter block independently filters each channel of
the input signal with the specified digital FIR filter. The block can
implement static filters with fixed coefficients, as well as time
varying filters with coefficients that change over time.
Discrete StateSpace
This is a discretetime dynamic system in statespace form. A, B, C,
and D matrices can be specified, as well as initial conditions.
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 ZeroPole
A discretetime transfer function can be represented as list of z
plane poles and zeros. The gain can also be specified.
FirstOrder Hold
The FirstOrder Hold block implements a firstorder sampleand
hold that operates at the specified sampling interval. This block
has little value in practical applications and is included primarily
for academic purposes.
Memory
The Memory block holds and delays its input by one integration
time step. This block accepts and outputs continuous signals. The
block accepts one input and generates one output. Each signal
can be scalar or vector.
Tapped Delay
The Tapped Delay block delays an input by the specified number
Page 11
The Tapped Delay block delays an input by the specified number
of sample periods and outputs all the delayed versions. Use this
block to discretize a signal in time or resample a signal at a
different rate.
Transfer Fcn First Order
The Transfer Fcn First Order block implements a discretetime first
order transfer function of the input. The transfer function has a
unity DC gain.
Transfer Fcn Lead or Lag
The Transfer Fcn Lead or Lag block implements a discretetime
lead or lag compensator of the input. The instantaneous gain of
the compensator is one, and the DC gain is equal to (1z)/(1p),
where z is the zero and p is the pole of the compensator.
Transfer Fcn Real Zero
The Transfer Fcn Real Zero block implements a discretetime
transfer function that has a real zero and effectively no pole.
ZeroOrder Hold
The ZeroOrder Hold block holds its input for the sample period
you specify. The block accepts one input and generates one
output. Each signal can be scalar or vector.
Logic and Bit Operations
Logic and Bit Operations Blocks are used to perform logic and
bit operations. Doubleclick on the Logic and Bit Operations icon
in the main Simulink window to bring up the Logic and Bit
Operations window.
Page 12
Bit Clear
The Bit Clear block sets the specified bit, given by its index, of the
stored integer to zero.
Bit Set
The Bit Set block sets the specified bit of the stored integer to one.
Bitwise Operator
The Bitwise Operator block performs the bitwise operation that you
specify on one or more operands.
Combinatorial Logic
The Combinatorial Logic block implements a standard truth table
for modeling programmable logic arrays (PLAs), logic circuits,
decision tables, and other Boolean expressions.
Compare To Constant
The Compare To Constant block compares an input signal to a
constant.
Compare To Zero
The Compare To Zero block compares an input signal to zero.
Detect Change
The Detect Change block determines if an input does not equal its
previous value.
Detect Decrease
The Detect Decrease block determines if an input is strictly less
than its previous value.
Detect Fall Negative
The Detect Fall Negative block determines if the input is less than
zero, and its previous value was greater than or equal to zero.
Detect Fall Nonpositive
The Detect Fall Nonpositive block determines if the input is less
than or equal to zero, and its previous value was greater than
zero.
Detect Increase
The Detect Increase block determines if an input is strictly greater
Page 13
than its previous value.
Detect Rise Nonnegative
The Detect Rise Nonnegative block determines if the input is
greater than or equal to zero, and its previous value was less than
zero.
Detect Rise Positive
The Detect Rise Positive block determines if the input is strictly
positive, and its previous value was nonpositive.
Extract Bits
The Extract Bits block allows you to output a contiguous selection
of bits from the stored integer value of the input signal.
Interval Test
The Interval Test block outputs TRUE if the input is between the
values specified by the Lower limit and Upper limit parameters.
Interval Test Dynamic
The Interval Test Dynamic block outputs TRUE if the input is
between the values of the external signals up and lo. The block
outputs FALSE if the input is outside those values. The output of
the block when the input is equal to the signal up or the signal lo is
determined by whether the boxes next to Interval closed on left
and Interval closed on right are selected in the dialog box.
Shift Arithmetic
The Shift Arithmetic block can shift the bits or the binary point of an
input signal, or both.
Math Operations
Math Operations Blocks are used to Perform math operations.
Doubleclick on the Math Operations icon in the main Simulink
window to bring up the Math Operations window.
Page 14
(1)
Abs
The Abs block outputs the absolute value of the input.
Algebraic Constraint
The Algebraic Constraint block constrains the input signal f(z) to
zero and outputs an algebraic state z.
Assignment
The Assignment block assigns values to specified elements of the
signal.
Bias
The Bias block adds a bias, or offset, to the input signal according
to
$Y = U + bias$
where U is the block input and Y is the output.
Complex to MagnitudeAngle
The Complex to MagnitudeAngle block accepts a complexvalued
signal of type double or single.
Complex to RealImage
The Complex to RealImag block accepts a complexvalued signal
of any data type that Simulink supports, including fixedpoint data
types.
Divide
The Divide block outputs the result of dividing its first input by its
second.
Dot Product
The output is equal to the dot product of two vector signals.
Find
The Find block locates all nonzero elements of the input signal
Page 15
The Find block locates all nonzero elements of the input signal
and returns the linear indices of those elements.
MagnitudeAngle to Complex
The MagnitudeAngle to Complex block converts magnitude and
phase angle inputs to a complex output.
Math Function
The Math Function block performs numerous common
mathematical functions.
MinMax
The MinMax block outputs either the minimum or the maximum
element or elements of the inputs.
MinMax Running Resettable
The MinMax Running Resettable block outputs the minimum or
maximum of all past inputs u.
Permute Dimensions
The block reorders the elements of the input signal so that they are
in the order you specify in the Order parameter.
Polynomial
You define a set of polynomial coefficients in the form that the
MATLAB polyval command accepts. The block evaluates P(u) at
each time step for the input u.
Product
The output is equal to the product of the inputs. The number of
inputs can be specified.
Product of Elements
The Product of Elements block inputs one scalar, vector, or matrix.
RealImag to Complex
The RealImag to Complex block converts real and/or imaginary
inputs to a complexvalued output signal.
Reshape
The Reshape block changes the dimensionality of the input signal
to a dimensionality that you specify, using the block's Output
dimensionality parameter.
Page 16
Rounding Function
The Rounding Function block applies a rounding function to the
input signal to produce the output signal.
Sine Wave Function
This block is the same as the Sine Wave block that appears in the
Sources library.
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.
Squeeze
The Squeeze block removes singleton dimensions from its
multidimensional input signal.
Sum, Add, Subtract, Sum of Elements
The Sum block performs addition or subtraction on its inputs. This
block can add or subtract scalar, vector, or matrix inputs. It can
also collapse the elements of a signal.
Vector Concatenate, Matrix Concatenate
The Concatenate block concatenates the signals at its inputs to
create an output signal whose elements reside in contiguous
locations in memory.
Sinks
Sink Blocks are used to display or output signals. Doubleclick on
the Sinks icon in the main Simulink window to bring up the Sinks
window.
Page 17
Notice that all of the sink blocks have inputs and no outputs. Most
have a single input.
Display
The Display Sink Block is a digital readout of a signal at the
current simulation time.
Scope
The Scope Sink Block was described earlier. It is used to display a
signal as a function of time.
Stop Simulation
This is a special control block which is triggered to stop the current
simulation when its input is nonzero.
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.
XY Graph
The XY Graph Sink Block plots one signal against another. It is
useful for phaseplane plots, etc.
Sources
Source Blocks are used to generate signals. Doubleclick on the
Sources icon in the main Simulink window to bring up the
Page 18
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 doubleclicking the block, it is best to not modify the
blocks until they have been copied into a model window.
BandLimited White Noise
The BandLimited 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.
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.
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.
Counter FreeRunning
The Counter FreeRunning block counts up until reaching the
maximum value,
$2^{Nbits}1$ , where Nbits is the number of bits. Then the
counter overflows to zero and begins counting up again.
Page 19
counter overflows to zero and begins counting up again.
Counter Limited
The Counter Limited block counts up until the specified upper limit
is reached. Then the counter wraps back to zero, and restarts
counting up.
Digital Clock
The Digital Clock Source Block generates a strictly periodic time
signal at a specified sampling interval.
Enumerated Constant
The Enumerated Constant block outputs a scalar, array, or matrix
of enumerated values.
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.
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.
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.
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.
Page 20
more than one simulation.
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.
Repeating Sequence Interpolated
The Repeating Sequence Interpolated block outputs a discrete
time sequence and then repeats it.
Repeating Sequence Stair
The Repeating Sequence Stair block outputs and repeats a stair
sequence that you specify with the Vector of output values
parameter.
Signal Generator
The Signal Generator Source Block is a generalpurpose 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.