Simulink
Simulink®
Reference
R2012b
How to Contact MathWorks
Web
Newsgroup
www.mathworks.com/contact_TS.html Technical Support
www.mathworks.com
comp.soft-sys.matlab
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Product enhancement suggestions
Bug reports
Documentation error reports
Order status, license renewals, passcodes
Sales, pricing, and general information
508-647-7000 (Phone)
508-647-7001 (Fax)
The MathWorks, Inc.
3 Apple Hill Drive
Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
Simulink® Reference
© COPYRIGHT 2002–2012 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or documentation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern
the use, modification, reproduction, release, performance, display, and disclosure of the Program and
Documentation by the federal government (or other entity acquiring for or through the federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government’s needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
July 2002
April 2003
April 2004
June 2004
October 2004
March 2005
September 2005
March 2006
September 2006
March 2007
September 2007
March 2008
October 2008
March 2009
September 2009
March 2010
September 2010
April 2011
September 2011
March 2012
September 2012
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
Revised for Simulink 5 (Release 13)
Revised for Simulink 5.1 (Release 13SP1)
Revised for Simulink 5.1.1 (Release 13SP1+)
Revised for Simulink 6 (Release 14)
Revised for Simulink 6.1 (Release 14SP1)
Revised for Simulink 6.2 (Release 14SP2)
Revised for Simulink 6.3 (Release 14SP3)
Revised for Simulink 6.4 (Release 2006a)
Revised for Simulink 6.5 (Release 2006b)
Revised for Simulink 6.6 (Release 2007a)
Revised for Simulink 7.0 (Release 2007b)
Revised for Simulink 7.1 (Release 2008a)
Revised for Simulink 7.2 (Release 2008b)
Revised for Simulink 7.3 (Release 2009a)
Revised for Simulink 7.4 (Release 2009b)
Revised for Simulink 7.5 (Release 2010a)
Revised for Simulink 7.6 (Release 2010b)
Revised for Simulink 7.7 (Release 2011a)
Revised for Simulink 7.8 (Release 2011b)
Revised for Simulink 7.9 (Release 2012a)
Revised for Simulink 8.0 (Release 2012b)
Contents
Block Reference
1
Commonly Used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-2
.......................................
1-4
Discontinuities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-5
..........................................
1-6
Logic and Bit Operations . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-8
Lookup Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-10
..................................
1-11
Model Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-13
Model-Wide Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-14
Ports & Subsystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-15
Signal Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-16
Signal Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-17
Sinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-19
Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-20
User-Defined Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-22
Continuous
Discrete
Math Operations
v
Additional Math & Discrete . . . . . . . . . . . . . . . . . . . . . . . . .
Additional Discrete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Additional Math: Increment — Decrement . . . . . . . . . . . . .
1-23
1-23
1-23
Run on Target Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . .
Target for Use with Arduino Hardware . . . . . . . . . . . . . . . .
Target for Use with BeagleBoard Hardware . . . . . . . . . . . .
Target for Use with LEGO MINDSTORMS NXT
Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-24
1-24
1-25
1-26
Blocks — Alphabetical List
2
Function Reference
3
vi
Contents
Model Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3-2
Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3-7
Linearization and Trimming . . . . . . . . . . . . . . . . . . . . . . . .
3-10
Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3-11
Functions — Alphabetical List
4
Mask Icon Drawing Commands
5
Simulink Debugger Commands
6
Simulink Classes
7
Model and Block Parameters
8
Model Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
About Model Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . .
Examples of Setting Model Parameters . . . . . . . . . . . . . . . .
8-2
8-2
8-95
Common Block Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 8-96
About Common Block Parameters . . . . . . . . . . . . . . . . . . . . 8-96
Examples of Setting Block Parameters . . . . . . . . . . . . . . . . 8-107
Block-Specific Parameters
. . . . . . . . . . . . . . . . . . . . . . . . . 8-109
Mask Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-259
About Mask Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-259
Notes on Mask Parameter Storage . . . . . . . . . . . . . . . . . . . 8-265
vii
Simulink Identifier
9
Simulink Identifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9-2
Model Advisor Checks
10
Simulink Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Simulink Check Overview . . . . . . . . . . . . . . . . . . . . . . . . . .
Identify unconnected lines, input ports, and output
ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Check root model Inport block specifications . . . . . . . . . . .
Check optimization settings . . . . . . . . . . . . . . . . . . . . . . . . .
Check for parameter tunability information ignored for
referenced models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Check for implicit signal resolution . . . . . . . . . . . . . . . . . . .
Check for optimal bus virtuality . . . . . . . . . . . . . . . . . . . . .
Check for Discrete-Time Integrator blocks with initial
condition uncertainty . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Identify disabled library links . . . . . . . . . . . . . . . . . . . . . . .
Identify parameterized library links . . . . . . . . . . . . . . . . . .
Identify unresolved library links . . . . . . . . . . . . . . . . . . . . .
Identify model reference variants and variant subsystems
that override variant choice . . . . . . . . . . . . . . . . . . . . . . .
Identify configurable subsystem blocks for converting to
variant subsystem blocks . . . . . . . . . . . . . . . . . . . . . . . . .
Check usage of function-call connections . . . . . . . . . . . . . . .
Check signal logging save format . . . . . . . . . . . . . . . . . . . . .
Check Data Store Memory blocks for multitasking, strong
typing, and shadowing issues . . . . . . . . . . . . . . . . . . . . . .
Check if read/write diagnostics are enabled for data store
blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Check data store block sample times for modeling errors . .
Check for potential ordering issues involving data store
access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Check for partial structure parameter usage with bus
signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Check for calls to slDataTypeAndScale . . . . . . . . . . . . . . . .
Check for proper bus usage . . . . . . . . . . . . . . . . . . . . . . . . .
viii
Contents
10-2
10-4
10-5
10-6
10-7
10-10
10-11
10-12
10-13
10-14
10-15
10-16
10-17
10-18
10-18
10-19
10-21
10-23
10-25
10-26
10-28
10-30
10-32
Check for potentially delayed function-call subsystem
return values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Identify block output signals with continuous sample time
and non-floating point data type . . . . . . . . . . . . . . . . . . .
Check for proper Merge block usage . . . . . . . . . . . . . . . . . .
Check consistency of initialization parameters for Outport
and Merge blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Check for non-continuous signals driving derivative
ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Runtime diagnostics for S-functions . . . . . . . . . . . . . . . . . .
Check file for foreign characters . . . . . . . . . . . . . . . . . . . . .
Check model for known block upgrade issues . . . . . . . . . . .
Check model for known block upgrade issues requiring
compile time information . . . . . . . . . . . . . . . . . . . . . . . . .
Check that the model is saved in SLX format . . . . . . . . . . .
Check Model History properties . . . . . . . . . . . . . . . . . . . . . .
Analyze model hierarchy for upgrade issues . . . . . . . . . . . .
Check and update masked blocks in library to use promoted
parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10-34
10-35
10-36
10-37
10-55
10-57
10-59
10-64
10-65
10-68
10-70
10-72
10-74
Performance Advisor Checks
11
Simulink Performance Advisor Checks . . . . . . . . . . . . . .
Simulink Performance Advisor Check Overview . . . . . . . .
Baseline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Check Preupdate Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Checks that need Update Diagram . . . . . . . . . . . . . . . . . . .
Checks that require simulation to run . . . . . . . . . . . . . . . . .
Check Accelerator Settings . . . . . . . . . . . . . . . . . . . . . . . . . .
Create Baseline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Identify resource intensive diagnostic settings . . . . . . . . . .
Check optimization settings . . . . . . . . . . . . . . . . . . . . . . . . .
Identify inefficient lookup table blocks . . . . . . . . . . . . . . . .
Identify Interpreted MATLAB Function blocks . . . . . . . . .
Check MATLAB Function block debug settings . . . . . . . . .
Check Stateflow block debug settings . . . . . . . . . . . . . . . . .
Identify simulation target settings . . . . . . . . . . . . . . . . . . .
Check model reference rebuild setting . . . . . . . . . . . . . . . . .
Check Model Reference parallel build . . . . . . . . . . . . . . . . .
Check solver type selection . . . . . . . . . . . . . . . . . . . . . . . . . .
11-2
11-2
11-3
11-3
11-3
11-3
11-3
11-4
11-4
11-4
11-5
11-5
11-5
11-5
11-6
11-6
11-6
11-8
ix
Select normal or accelerator simulation mode
..........
11-9
Simulink Limits
12
Maximum Size Limits of Simulink Models
...........
12-2
Index
x
Contents
1
Block Reference
Commonly Used (p. 1-2)
Commonly used blocks
Continuous (p. 1-4)
Define continuous states
Discontinuities (p. 1-5)
Define discontinuous states
Discrete (p. 1-6)
Define discrete states
Logic and Bit Operations (p. 1-8)
Perform logic and bit operations
Lookup Tables (p. 1-10)
Support lookup tables
Math Operations (p. 1-11)
Perform math operations
Model Verification (p. 1-13)
Perform model verification
Model-Wide Utilities (p. 1-14)
Support model-wide operations
Ports & Subsystems (p. 1-15)
Support ports and subsystems
Signal Attributes (p. 1-16)
Support signal attributes
Signal Routing (p. 1-17)
Support signal routing
Sinks (p. 1-19)
Receive output from other blocks
Sources (p. 1-20)
Input to other blocks
User-Defined Functions (p. 1-22)
Support custom functions
Additional Math & Discrete (p. 1-23)
Provide additional math and discrete
support
Run on Target Hardware (p. 1-24)
1
Block Reference
Commonly Used
1-2
Bus Creator
Create signal bus
Bus Selector
Select signals from incoming bus
Constant
Generate constant value
Data Type Conversion
Convert input signal to specified
data type
Demux
Extract and output elements of
vector signal
Discrete-Time Integrator
Perform discrete-time integration or
accumulation of signal
Gain
Multiply input by constant
Ground
Ground unconnected input port
Inport
Create input port for subsystem or
external input
Integrator, Integrator Limited
Integrate signal
Logical Operator
Perform specified logical operation
on input
Mux
Combine several input signals into
vector
Outport
Create output port for subsystem or
external output
Product
Multiply and divide scalars and
nonscalars or multiply and invert
matrices
Relational Operator
Perform specified relational
operation on inputs
Saturation
Limit range of signal
Scope and Floating Scope
Display signals generated during
simulation
Commonly Used
Subsystem, Atomic Subsystem,
Nonvirtual Subsystem, CodeReuse
Subsystem
Represent system within another
system
Sum, Add, Subtract, Sum of
Elements
Add or subtract inputs
Switch
Switch output between first input
and third input based on value of
second input
Terminator
Terminate unconnected output port
Unit Delay
Delay signal one sample period
Vector Concatenate, Matrix
Concatenate
Concatenate input signals of same
data type to create contiguous output
signal
1-3
1
Block Reference
Continuous
1-4
Derivative
Output time derivative of input
Integrator, Integrator Limited
Integrate signal
PID Controller
Simulate continuous- or
discrete-time PID controllers
PID Controller (2 DOF)
Simulate continuous- or
discrete-time two-degree-of-freedom
PID controllers
Second-Order Integrator,
Second-Order Integrator Limited
Integrate input signal twice
State-Space
Implement linear state-space system
Transfer Fcn
Model linear system by transfer
function
Transport Delay
Delay input by given amount of time
Variable Time Delay, Variable
Transport Delay
Delay input by variable amount of
time
Zero-Pole
Model system by zero-pole-gain
transfer function
Discontinuities
Discontinuities
Backlash
Model behavior of system with play
Coulomb and Viscous Friction
Model discontinuity at zero, with
linear gain elsewhere
Dead Zone
Provide region of zero output
Dead Zone Dynamic
Set inputs within bounds to zero
Hit Crossing
Detect crossing point
Quantizer
Discretize input at specified interval
Rate Limiter
Limit rate of change of signal
Rate Limiter Dynamic
Limit rising and falling rates of
signal
Relay
Switch output between two constants
Saturation
Limit range of signal
Saturation Dynamic
Bound range of input
Wrap To Zero
Set output to zero if input is above
threshold
1-5
1
Block Reference
Discrete
1-6
Delay
Delay input signal by fixed or
variable sample periods
Difference
Calculate change in signal over one
time step
Discrete Derivative
Compute discrete-time derivative
Discrete Filter
Model Infinite Impulse Response
(IIR) filters
Discrete FIR Filter
Model FIR filters
Discrete State-Space
Implement discrete state-space
system
Discrete Transfer Fcn
Implement discrete transfer function
Discrete Zero-Pole
Model system defined by zeros and
poles of discrete transfer function
Discrete-Time Integrator
Perform discrete-time integration or
accumulation of signal
First-Order Hold
Implement first-order
sample-and-hold
Memory
Output input from previous time
step
PID Controller
Simulate continuous- or
discrete-time PID controllers
PID Controller (2 DOF)
Simulate continuous- or
discrete-time two-degree-of-freedom
PID controllers
Resettable Delay
Delay input signal by variable
sample period and reset with
external signal
Tapped Delay
Delay scalar signal multiple sample
periods and output all delayed
versions
Discrete
Transfer Fcn First Order
Implement discrete-time first order
transfer function
Transfer Fcn Lead or Lag
Implement discrete-time lead or lag
compensator
Transfer Fcn Real Zero
Implement discrete-time transfer
function that has real zero and no
pole
Unit Delay
Delay signal one sample period
Variable Integer Delay
Delay input signal by variable
sample period
Zero-Order Hold
Implement zero-order hold of one
sample period
1-7
1
Block Reference
Logic and Bit Operations
1-8
Bit Clear
Set specified bit of stored integer to
zero
Bit Set
Set specified bit of stored integer to
one
Bitwise Operator
Specified bitwise operation on inputs
Combinatorial Logic
Implement truth table
Compare To Constant
Determine how signal compares to
specified constant
Compare To Zero
Determine how signal compares to
zero
Detect Change
Detect change in signal value
Detect Decrease
Detect decrease in signal value
Detect Fall Negative
Detect falling edge when signal
value decreases to strictly negative
value, and its previous value was
nonnegative
Detect Fall Nonpositive
Detect falling edge when signal
value decreases to nonpositive value,
and its previous value was strictly
positive
Detect Increase
Detect increase in signal value
Detect Rise Nonnegative
Detect rising edge when signal value
increases to nonnegative value,
and its previous value was strictly
negative
Detect Rise Positive
Detect rising edge when signal
value increases to strictly positive
value, and its previous value was
nonpositive
Extract Bits
Output selection of contiguous bits
from input signal
Logic and Bit Operations
Interval Test
Determine if signal is in specified
interval
Interval Test Dynamic
Determine if signal is in specified
interval
Logical Operator
Perform specified logical operation
on input
Relational Operator
Perform specified relational
operation on inputs
Shift Arithmetic
Shift bits or binary point of signal
1-9
1
Block Reference
Lookup Tables
1-10
1-D Lookup Table
Approximate one-dimensional
function
2-D Lookup Table
Approximate two-dimensional
function
Direct Lookup Table (n-D)
Index into N-dimensional table to
retrieve element, column, or 2-D
matrix
Interpolation Using Prelookup
Use precalculated index and fraction
values to accelerate approximation
of N-dimensional function
Lookup Table Dynamic
Approximate one-dimensional
function using dynamic table
n-D Lookup Table
Approximate N-dimensional function
Prelookup
Compute index and fraction for
Interpolation Using Prelookup block
Sine, Cosine
Implement fixed-point sine or cosine
wave using lookup table approach
that exploits quarter wave symmetry
Math Operations
Math Operations
Abs
Output absolute value of input
Algebraic Constraint
Constrain input signal to zero
Assignment
Assign values to specified elements
of signal
Bias
Add bias to input
Complex to Magnitude-Angle
Compute magnitude and/or phase
angle of complex signal
Complex to Real-Imag
Output real and imaginary parts of
complex input signal
Divide
Divide one input by another
Dot Product
Generate dot product of two vectors
Find
Find nonzero elements in array
Gain
Multiply input by constant
Magnitude-Angle to Complex
Convert magnitude and/or a phase
angle signal to complex signal
Math Function
Perform mathematical function
MinMax
Output minimum or maximum input
value
MinMax Running Resettable
Determine minimum or maximum of
signal over time
Permute Dimensions
Rearrange dimensions of
multidimensional array dimensions
Polynomial
Perform evaluation of polynomial
coefficients on input values
Product
Multiply and divide scalars and
nonscalars or multiply and invert
matrices
Product of Elements
Copy or invert one scalar input, or
collapse one nonscalar input
1-11
1
1-12
Block Reference
Real-Imag to Complex
Convert real and/or imaginary
inputs to complex signal
Reshape
Change dimensionality of signal
Rounding Function
Apply rounding function to signal
Sign
Indicate sign of input
Sine Wave Function
Generate sine wave, using external
signal as time source
Slider Gain
Vary scalar gain using slider
Sqrt, Signed Sqrt, Reciprocal Sqrt
Calculate square root, signed square
root, or reciprocal of square root
Squeeze
Remove singleton dimensions from
multidimensional signal
Sum, Add, Subtract, Sum of
Elements
Add or subtract inputs
Trigonometric Function
Specified trigonometric function on
input
Unary Minus
Negate input
Vector Concatenate, Matrix
Concatenate
Concatenate input signals of same
data type to create contiguous output
signal
Weighted Sample Time Math
Support calculations involving
sample time
Model Verification
Model Verification
Assertion
Check whether signal is zero
Check Discrete Gradient
Check that absolute value of
difference between successive
samples of discrete signal is less
than upper bound
Check Dynamic Gap
Check that gap of possibly varying
width occurs in range of signal’s
amplitudes
Check Dynamic Lower Bound
Check that one signal is always less
than another signal
Check Dynamic Range
Check that signal falls inside range
of amplitudes that varies from time
step to time step
Check Dynamic Upper Bound
Check that one signal is always
greater than another signal
Check Input Resolution
Check that input signal has specified
resolution
Check Static Gap
Check that gap exists in signal’s
range of amplitudes
Check Static Lower Bound
Check that signal is greater than
(or optionally equal to) static lower
bound
Check Static Range
Check that signal falls inside fixed
range of amplitudes
Check Static Upper Bound
Check that signal is less than (or
optionally equal to) static upper
bound
1-13
1
Block Reference
Model-Wide Utilities
1-14
Block Support Table
View data type support for Simulink®
blocks
DocBlock
Create text that documents model
and save text with model
Model Info
Display model properties and text in
model
Timed-Based Linearization
Generate linear models in base
workspace at specific times
Trigger-Based Linearization
Generate linear models in base
workspace when triggered
Ports & Subsystems
Ports & Subsystems
1-15
1
Block Reference
Signal Attributes
1-16
Bus to Vector
Convert virtual bus to vector
Data Type Conversion
Convert input signal to specified
data type
Data Type Conversion Inherited
Convert from one data type to
another using inherited data type
and scaling
Data Type Duplicate
Force all inputs to same data type
Data Type Propagation
Set data type and scaling of
propagated signal based on
information from reference signals
Data Type Scaling Strip
Remove scaling and map to built in
integer
IC
Set initial value of signal
Probe
Output signal attributes, including
width, dimensionality, sample time,
and complex signal flag
Rate Transition
Handle transfer of data between
blocks operating at different rates
Signal Conversion
Convert signal to new type without
altering signal values
Signal Specification
Specify desired dimensions, sample
time, data type, numeric type, and
other attributes of signal
Weighted Sample Time
Support calculations involving
sample time
Width
Output width of input vector
Signal Routing
Signal Routing
Bus Assignment
Replace specified bus elements
Bus Creator
Create signal bus
Bus Selector
Select signals from incoming bus
Data Store Memory
Define data store
Data Store Read
Read data from data store
Data Store Write
Write data to data store
Demux
Extract and output elements of
vector signal
Environment Controller
Create branches of block diagram
that apply only to simulation or only
to code generation
From
Accept input from Goto block
Goto
Pass block input to From blocks
Goto Tag Visibility
Define scope of Goto block tag
Index Vector
Switch output between different
inputs based on value of first input
Manual Switch
Switch between two inputs
Merge
Combine multiple signals into single
signal
Multiport Switch
Choose between multiple block
inputs
Mux
Combine several input signals into
vector
Selector
Select input elements from vector,
matrix, or multidimensional signal
1-17
1
1-18
Block Reference
Switch
Switch output between first input
and third input based on value of
second input
Vector Concatenate, Matrix
Concatenate
Concatenate input signals of same
data type to create contiguous output
signal
Sinks
Sinks
Display
Show value of input
Outport
Create output port for subsystem or
external output
Scope and Floating Scope
Display signals generated during
simulation
Stop Simulation
Stop simulation when input is
nonzero
Terminator
Terminate unconnected output port
To File
Write data to file
To Workspace
Write data to MATLAB® workspace
XY Graph
Display X-Y plot of signals using
MATLAB figure window
1-19
1
Block Reference
Sources
1-20
Band-Limited White Noise
Introduce white noise into
continuous system
Chirp Signal
Generate sine wave with increasing
frequency
Clock
Display and provide simulation time
Constant
Generate constant value
Counter Free-Running
Count up and overflow back to zero
after reaching maximum value for
specified number of bits
Counter Limited
Count up and wrap back to zero after
outputting specified upper limit
Digital Clock
Output simulation time at specified
sampling interval
Enumerated Constant
Generate enumerated constant value
From File
Read data from MAT-file
From Workspace
Read data from workspace
Ground
Ground unconnected input port
Inport
Create input port for subsystem or
external input
Pulse Generator
Generate square wave pulses at
regular intervals
Ramp
Generate constantly increasing or
decreasing signal
Random Number
Generate normally distributed
random numbers
Repeating Sequence
Generate arbitrarily shaped periodic
signal
Repeating Sequence Interpolated
Output discrete-time sequence and
repeat, interpolating between data
points
Sources
Repeating Sequence Stair
Output and repeat discrete time
sequence
Signal Builder
Create and generate interchangeable
groups of signals whose waveforms
are piecewise linear
Signal Generator
Generate various waveforms
Sine Wave
Generate sine wave, using
simulation time as time source
Step
Generate step function
Uniform Random Number
Generate uniformly distributed
random numbers
1-21
1
Block Reference
User-Defined Functions
1-22
Fcn
Apply specified expression to input
Interpreted MATLAB Function
Apply MATLAB function or
expression to input
Level-2 MATLAB S-Function
Use Level-2 MATLAB S-function in
model
MATLAB Function
Include MATLAB code in models
that generate embeddable C code
S-Function
Include S-function in model
S-Function Builder
Create S-function from C code that
you provide
Additional Math & Discrete
Additional Math & Discrete
Additional Discrete (p. 1-23)
Provide additional discrete math
support
Additional Math: Increment —
Decrement (p. 1-23)
Increment or decrement value of
signal by one
Additional Discrete
Additional Math: Increment — Decrement
1-23
1
Block Reference
Run on Target Hardware
Target for Use with Arduino
Hardware (p. 1-24)
Generate applications for Arduino®
hardware
Target for Use with BeagleBoard
Hardware (p. 1-25)
Generate applications for
BeagleBoard™ hardware
Target for Use with LEGO
MINDSTORMS NXT Hardware
(p. 1-26)
Generate applications for LEGO®
MINDSTORMS® NXT™ hardware
Target for Use with Arduino Hardware
1-24
Arduino Analog Input
Measure voltage of analog input pin
Arduino Continuous Servo Write
Set shaft speed of continuous
rotation servo motor
Arduino Digital Input
Get logical value of digital input pin
Arduino Digital Output
Set logical value of digital output pin
Arduino PWM
Generate PWM waveform on analog
output pin
Arduino Serial Receive
Get one byte of data from serial port
Arduino Serial Transmit
Send buffered data to serial port
Arduino Standard Servo Read
Get position of standard servo motor
shaft in degrees
Arduino Standard Servo Write
Set shaft position of standard servo
motor
targetinstaller
Open Target Installer and install
support for third-party hardware or
software
Run on Target Hardware
Target for Use with BeagleBoard Hardware
BeagleBoard ALSA Audio Capture
Capture audio from sound card using
ALSA
BeagleBoard ALSA Audio
Playback
Send audio to sound card for
playback using ALSA
BeagleBoard SDL Video Display
Display video using SDL
BeagleBoard UDP Receive
Receive UDP packets over IP
network
BeagleBoard UDP Send
Send UDP packets over IP network
BeagleBoard V4L2 Video Capture
Capture video from USB camera
using V4L2
PandaBoard ALSA Audio Capture
Capture audio from sound card using
ALSA
PandaBoard ALSA Audio Playback
Send audio to sound card for
playback using ALSA
PandaBoard SDL Video Display
Display video using SDL
PandaBoard UDP Receive
Receive UDP packets over IP
network
PandaBoard UDP Send
Send UDP packets over IP network
PandaBoard V4L2 Video Capture
Capture video from USB camera
using V4L2
targetinstaller
Open Target Installer and install
support for third-party hardware or
software
targetupdater
Open Target Installer and update
firmware on third-party hardware
1-25
1
Block Reference
Target for Use with LEGO MINDSTORMS NXT
Hardware
1-26
LEGO MINDSTORMS NXT
Acceleration Sensor
Measure acceleration along three
axes
LEGO MINDSTORMS NXT Battery
Measure voltage of battery in NXT
brick
LEGO MINDSTORMS NXT Button
Output state of button on NXT brick
LEGO MINDSTORMS NXT Color
Sensor
Measure color or light intensity
LEGO MINDSTORMS NXT Encoder
Measure encoder rotation from NXT
Interactive Servo Motor
LEGO MINDSTORMS NXT Gyro
Sensor
Measure rate of rotation
LEGO MINDSTORMS NXT LCD
Display number on single line of
NXT LCD screen
LEGO MINDSTORMS NXT Light
Sensor
Measure light intensity
LEGO MINDSTORMS NXT Motor
Set motor speed and stopping action
LEGO MINDSTORMS NXT Receive
via Bluetooth Connection
Receive data from another NXT
brick over Bluetooth®
LEGO MINDSTORMS NXT Send via
Bluetooth Connection
Send data to another NXT brick over
Bluetooth
LEGO MINDSTORMS NXT Sound
Sensor
Measure sound level
LEGO MINDSTORMS NXT Speaker
Play tones on speaker in NXT brick
LEGO MINDSTORMS NXT Timer
Measure elapsed time from timer in
NXT brick
LEGO MINDSTORMS NXT Touch
Sensor
Output state of touch sensor
LEGO MINDSTORMS NXT Ultrasonic
Sensor
Measure distance from object in
centimeters
Run on Target Hardware
targetinstaller
Open Target Installer and install
support for third-party hardware or
software
targetupdater
Open Target Installer and update
firmware on third-party hardware
1-27
1
1-28
Block Reference
2
Blocks — Alphabetical List
Abs
Purpose
Output absolute value of input
Library
Math Operations
Description
The Abs block outputs the absolute value of the input.
For signed-integer data types, the absolute value of the most negative
value is not representable by the data type. In this case, the Saturate
on integer overflow check box controls the behavior of the block:
If you...
The block...
And...
Select this
check box
Saturates to the
most positive value
of the integer data
type
• For 8-bit signed integers,
-128 maps to 127.
• For 16-bit signed integers,
-32768 maps to 32767.
• For 32-bit signed integers,
-2147483648 maps to
2147483647.
Do not select
this check box
Wraps to the most
negative value of
the integer data
type
• For 8-bit signed integers,
-128 remains -128.
• For 16-bit signed integers,
-32768 remains -32768.
• For 32-bit signed integers,
-2147483648 remains
-2147483648.
The Abs block supports zero-crossing detection. However, when you
select Enable zero-crossing detection on the dialog box, the block
does not report the simulation minimum or maximum in the Fixed-Point
Tool. If you want to use the Fixed-Point Tool to analyze a model, disable
zero-crossing detection for all Abs blocks in the model first.
2-2
Abs
Data Type
Support
The Abs block accepts real signals of the following data types:
• Floating point
• Built-in integer
• Fixed point
The block also accepts complex floating-point inputs. For more
information, see “Data Types Supported by Simulink” in the Simulink
documentation.
Parameters
and
Dialog
Box
The Main pane of the Abs block dialog box appears as follows:
2-3
Abs
Enable zero-crossing detection
Select to enable zero-crossing detection. For more information,
see “Zero-Crossing Detection” in the Simulink documentation.
Sample time (-1 for inherited)
Enter the time interval between sample time hits or specify
another appropriate sample time such as continuous. By default,
the block inherits its sample time based upon its context within
the model. For more information, see “Sample Time”.
The Signal Attributes pane of the Abs block dialog box appears as
follows:
2-4
Abs
Output minimum
Specify the minimum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
2-5
Abs
Output maximum
Specify the maximum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output data type
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output data type parameter.
See “Specify Block Output Data Types” in Simulink User’s Guide
for more information.
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point™
documentation.
2-6
Abs
Saturate on integer overflow
Action
Reason for Taking
This Action
What Happens
Example
Select this
check box.
Your model has
possible overflow and
you want explicit
saturation protection
in the generated code.
Overflows saturate to
the maximum value
that the data type can
represent.
The number 130 does
not fit in a signed 8-bit
integer and saturates
to 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
-126.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result. In
general, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
Examples
Usage as an Input to a MinMax Block
The sldemo_hardstop model shows how you can use the Abs block
as an input to the MinMax block.
2-7
Abs
In the sldemo_hardstop model, the Abs block is in the Friction Model
subsystem.
2-8
Abs
Usage as an Input to a Switch Block
The sldemo_zeroxing model shows how you can use the Abs block
as an input to the Switch block.
Characteristics Direct Feedthrough
Yes
Sample Time
Specified in the Sample time parameter
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
Yes, if enabled
2-9
Action Port
Purpose
Implement Action subsystems used in if and switch control flow
statements
Library
Ports & Subsystems
Description
Action Port blocks implement Action subsystems used in if and switch
control flow statements. The Action Port block is available in the If
Action Subsystem and the Switch Case Action Subsystem.
Use Action Port blocks to create Action subsystems as follows:
1 Place a subsystem in the system containing the If or Switch Case
block.
You can use an ordinary subsystem or an atomic subsystem. In
either case, the resulting Action subsystem is atomic.
2 Add an Action Port to the new subsystem.
This block adds an input port named Action to the subsystem, which
is now an Action subsystem.
Action subsystems execute their programming in response to the
conditional outputs of an If or Switch Case block. Use Action
subsystems as follows:
1 Create an Action subsystem for each output port configured for an
If or Switch Case block.
2 Connect each output port to the Action port on an Action subsystem.
• if, else, or elseif ports for the If block
• case or default ports for the Switch Case block
When you make a connection, the icon changes for the subsystem and
the Action Port block it contains to the name of the output port for
the If or Switch Case block (for example, if{ }, else{ }, elseif{ },
case{ }, or default{ }).
2-10
Action Port
3 Open the new subsystem and add the diagram that you want to
execute in response to the condition this subsystem covers.
Note All blocks in an Action subsystem driven by an If or Switch Case
block must run at the same rate as the driving block.
Data Type
Support
Parameters
and
Dialog
Box
Action Port blocks do not have data inputs or outputs.
• “States when execution is resumed” on page 2-11
• “Propagate sizes of variable-size signals” on page 2-14
States when execution is resumed
Specify how to handle internal states when a subsystem with an Action
Port block reenables.
Settings
Default: held
2-11
Action Port
held
When the subsystem reenables, retains the states of the Action
subsystem with their previous values. Retains the previous
values of states between calls even if calling other member Action
subsystems of an if-else or switch control flow statement.
reset
Reinitializes the states of the Action subsystem to initial values
when the subsystem reenables.
Reenablement of a subsystem occurs when called and the
condition of the call is true after having been previously false.
In the following example, the Action Port blocks for both Action
subsystems A and B have the States when execution is
resumed parameter set to reset.
If case[1] is true, call Action subsystem A. This result implies
that the default condition is false. When later calling B for the
default condition, its states are reset. In the same way, Action
subsystem A states are reset when calling A right after calling
Action subsystem B.
Repeated calls to the Action subsystem of a case does not reset
its states. If calling A again right after a previous call to A, this
action does not reset the states of A. This behavior is because the
2-12
Action Port
condition of case[1] was not previously false. The same applies
to B.
Command-Line Information
Parameter: InitializeStates
Type: string
Value: 'held' | 'reset' |
Default: 'held'
2-13
Action Port
Propagate sizes of variable-size signals
Specify when to propagate a variable-size signal.
Settings
Default: Only when execution is resumed
Only when execution is resumed
Propagates variable-size signals only when reenabling the
subsystem containing the Action Port block.
During execution
Propagates variable-size signals at each time step.
Command-Line Information
Parameter: PropagateVarSize
Type: string
Value: 'Only when execution is resumed' | 'During
execution'
Default: 'Only when execution is resumed'
Characteristics Sample Time
See Also
2-14
Inherited from driving If or Switch Case
block
If, If Action Subsystem, Switch Case, and Switch Case Action
Subsystem blocks for examples using Action Port blocks
Algebraic Constraint
Purpose
Constrain input signal to zero
Library
Math Operations
Description
The Algebraic Constraint block constrains the input signal f(z) to
zero and outputs an algebraic state z. The block outputs the value
that produces a zero at the input. The output must affect the input
through a direct feedback path, that is, the feedback path contains only
blocks with direct feedthrough. For example, you can specify algebraic
equations for index 1 differential-algebraic systems (DAEs).
Algorithm
The Algebraic Constraint block uses a dogleg trust-region algorithm to
solve algebraic loops [1], [2].
Data Type
Support
The Algebraic Constraint block accepts and outputs real values of type
double.
2-15
Algebraic Constraint
Parameters
and
Dialog
Box
Example
Initial guess
An initial guess for the solution value. The default is 0.
By default, the Initial guess parameter is zero. You can improve the
efficiency of the algebraic-loop solver by providing an Initial guess for
the algebraic state z that is close to the solution value.
For example, the following model solves these equations:
z2 + z1 = 1
z2 - z1 = 1
The solution is z2 = 1, z1 = 0, as the Display blocks show.
2-16
Algebraic Constraint
Characteristics Direct Feedthrough
References
Yes
Sample Time
Inherited from driving block
Scalar Expansion
No
Dimensionalized
Yes
Zero-Crossing Detection
No
[1] Garbow, B. S., K. E. Hillstrom, and J. J. Moré. User Guide for
MINPACK-1. Argonne, IL: Argonne National Laboratory, 1980.
[2] Rabinowitz, P. H. Numerical Methods for Nonlinear Algebraic
Equations. New York, NY: Gordon and Breach, 1970.
2-17
Assertion
Purpose
Check whether signal is zero
Library
Model Verification
Description
The Assertion block checks whether any of the elements of the input
signal is zero. If all elements are nonzero, the block does nothing. If any
element is zero, the block halts the simulation, by default, and displays
an error message. Use the block parameter dialog box to:
• Specify that the block should display an error message when the
assertion fails but allow the simulation to continue.
• Specify a MATLAB expression to evaluate when the assertion fails.
• Enable or disable the assertion.
You can also use the Model Verification block enabling setting on
the Data Validity diagnostics pane of the Configuration Parameters
dialog box to enable or disable all Assertion blocks in a model.
The Assertion block and its companion blocks in the Model Verification
library are intended to facilitate creation of self-validating models. For
example, you can use model verification blocks to test that signals do
not exceed specified limits during simulation. When you are satisfied
that a model is correct, you can turn error checking off by disabling the
verification blocks. You do not have to physically remove them from the
model. If you need to modify a model, you can temporarily turn the
verification blocks back on to ensure that your changes do not break
the model.
Note For information about how Simulink Coder™ generated code
handles Model Verification blocks, see “Debug”.
Data Type
Support
2-18
The Assertion block accepts input signals of any dimensions and any
numeric data type that Simulink supports, including fixed-point data
types.
Assertion
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
Enable assertion
Clearing this check box disables the Assertion block, that is,
causes the model to behave as if the Assertion block did not
exist. The Model Verification block enabling setting under
Debugging on the Data Validity diagnostics pane of the
Configuration Parameters dialog box lets you enable or disable all
Assertion blocks in a model regardless of the setting of this option.
2-19
Assertion
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Assertion block to halt the
simulation when the block input is zero and display an error
message in the Simulation Diagnostics Viewer. Otherwise, the
block displays a warning message in the MATLAB Command
Window and continues the simulation.
Sample time (-1 for inherited)
Enter the time interval between sample time hits or specify
another appropriate sample time such as continuous. By default,
the block inherits its sample time based upon its context within
the model. For more information, see “Sample Time”.
Characteristics Direct Feedthrough
2-20
No
Sample Time
Specified in the Sample time parameter
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Assignment
Purpose
Assign values to specified elements of signal
Library
Math Operations
Description
The Assignment block assigns values to specified elements of the signal.
You can specify the indices of the elements to be assigned values either
by entering the indices in the block’s dialog box or by connecting an
external indices source or sources to the block. The signal at the block’s
data port, labeled U, specifies values to be assigned to Y. The block
replaces the specified elements of Y with elements from the data signal.
Based on the value you enter for the Number of output dimensions
parameter, a table of index options is displayed. Each row of the table
corresponds to one of the output dimensions in Number of output
dimensions. For each dimension, you can define the elements of the
signal to work with. Specify a vector signal as a 1-D signal and a matrix
signal as a 2-D signal. When you configure the Assignment block for
multidimensional signal operations, the block icon changes.
For example, assume a 5-D signal with a one-based index mode. The
table in the Assignment block dialog changes to include one row for each
dimension. If you define each dimension with the following entries:
• 1
Index Option, select Assign all
• 2
Index Option, select Index vector (dialog)
Index, enter [1 3 5]
2-21
Assignment
• 3
Index Option, select Starting index (dialog)
Index, enter 4
• 4
Index Option, select Starting index (port)
• 5
Index Option, select Index vector (port)
The assigned values will be Y(1:end,[1 3
5],4:3+size(U,3),Idx4:Idx4+size(U,4)-1,Idx5)=U, where Idx4
and Idx5 are the input ports for dimensions 4 and 5.
The Assignment block’s data port is labeled U. The rest of this section
refers to the data port as U to simplify the explanation of the block’s
usage.
You can use the block to assign values to vector, matrix, or
multidimensional signals.
You can use an array of buses as an input signal to an Assignment
block. For details about defining and using an array of buses, see
“Combine Buses into an Array of Buses”.
Iterated Assignment
You can use the Assignment block to assign values computed in a
For or While Iterator loop to successive elements of a vector, matrix,
or multidimensional signal in a single time step. For example, the
following model uses a For Iterator block to create a vector signal each
of whose elements equals 3*i where i is the index of the element.
2-22
Assignment
Iterated assignment uses an iterator (For or While) block to generate
indices for the Assignment block. On the first iteration of an iterated
assignment, the Assignment block copies the first input (Y0) to the
output (Y) and assigns the second input (U) to the output Y(E1). On
successive iterations, the Assignment block assigns the current value of
U to Y(Ei), that is, without first copying Y0 to Y. These actions occur in
a single time step.
Data Type
Support
The data and initialization ports of the Assignment block accept signals
of any data type that Simulink supports, including fixed-point and
enumerated data types. The external indices port accepts any built-in
data type, except Boolean data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-23
Assignment
Parameters
and
Dialog
Box
2-24
Number of output dimensions
Enter the number of dimensions of the output signal.
Index mode
Select the indexing mode: One-based or Zero-based. If
One-based is selected, an index of 1 specifies the first element of
the input vector, 2, the second element, and so on. If Zero-based
is selected, an index of 0 specifies the first element of the input
vector, 1, the second element, and so on.
Assignment
Index Option
Define, by dimension, how the elements of the signal are to be
indexed. From the list, select:
• Assign all
This is the default. All elements are assigned.
• Index vector (dialog)
Enables the Index column. Enter the indices of elements.
• Index vector (port)
Disables the Index column. The index port defines the indices
of elements.
• Starting index (dialog)
Enables the Index column. Enter the starting index of the
range of elements to be assigned values.
• Starting index (port)
Disables the Index column. The index port defines the starting
index of the range of elements to be assigned values.
If you choose Index vector (port) or Starting index (port)
for any dimension in the table, you can specify the value for the
Initialize output (Y) parameter to be one of the following:
• Initialize using input port <Y0>
• Specify size for each dimension in table
Otherwise, Y0 always initializes output port Y.
The Index and Output Size columns are displayed as relevant.
Index
If the Index Option is Index vector (dialog), enter the index
of each element you are interested in.
2-25
Assignment
If the Index Option is Starting index (dialog), enter the
starting index of the range of elements to be selected. The number
of elements from the starting point is determined by the size of
this dimension at U.
Output Size
Enter the width of the block output signal. If you select Specify
size for each dimension in table for the Initialize output
(Y) parameter, this column is enabled.
Initialize output (Y)
Specify how to initialize the output signal. The Initialize output
parameter appears when you set Index Option to Index vector
(port) or Starting index (port).
• Initialize using input port <Y0>
The signal at the input port Y0 initializes the output.
• Specify size for each dimension in table
The block requires you to specify the width of the block’s
output signal in the Output Size parameter. If the output has
unassigned elements, the value of those elements is undefined.
Action if any output element is not assigned
Specify whether to produce a warning or error if you have not
assigned all output elements. Options include:
• Error
• Warning
• None
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink documentation.
2-26
Assignment
Characteristics Direct Feedthrough
Yes
Sample Time
Specified in the Sample time parameter
Scalar Expansion
Yes
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
2-27
Backlash
Purpose
Model behavior of system with play
Library
Discontinuities
Description
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. The
amount of side-to-side play in the system is referred to as the deadband.
The deadband is centered about the output. This figure shows the
block’s initial state, with the default deadband width of 1 and initial
output of 0.
A system with play can be in one of three modes:
• Disengaged — In this mode, the input does not drive the output and
the output remains constant.
• Engaged in a positive direction — In this mode, the input is
increasing (has a positive slope) and the output is equal to the input
minus half the deadband width.
• Engaged in a negative direction — In this mode, the input is
decreasing (has a negative slope) and the output is equal to the input
plus half the deadband width.
If the initial input is outside the deadband, the Initial output
parameter value determines whether the block is engaged in a positive
or negative direction, and the output at the start of the simulation is
the input plus or minus half the deadband width.
For example, the Backlash block can be used to model the meshing of
two gears. The input and output are both shafts with a gear on one
end, and the output shaft is driven by the input shaft. Extra space
2-28
Backlash
between the gear teeth introduces play. The width of this spacing is the
Deadband width parameter. If the system is disengaged initially,
the output (the position of the driven gear) is defined by the Initial
output parameter.
The following figures illustrate the block’s operation when the initial
input is within the deadband. The first figure shows the relationship
between the input and the output while the system is in disengaged
mode (and the default parameter values are not changed).
The next figure shows the state of the block when the input has reached
the end of the deadband and engaged the output. The output remains
at its previous value.
The final figure shows how a change in input affects the output while
they are engaged.
If the input reverses its direction, it disengages from the output. The
output remains constant until the input either reaches the opposite end
of the deadband or reverses its direction again and engages at the same
end of the deadband. Now, as before, movement in the input causes
equal movement in the output.
2-29
Backlash
For example, if the deadband width is 2 and the initial output is 5, the
output, y, at the start of the simulation is as follows:
• 5 if the input, u, is between 4 and 6
• u + 1 if u < 4
• u – 1 if u > 6
Data Type
Support
2-30
The Backlash block accepts and outputs real values of single, double,
and built-in integer data types.
Backlash
Parameters
and
Dialog
Box
Deadband width
Specify the width of the deadband. The default is 1.
2-31
Backlash
Initial output
Specify the initial output value. The default value is 0. This
parameter is tunable. Simulink does not allow the initial output
of this block to be inf or NaN.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
Note Frame-based processing requires a DSP System
Toolbox™ license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
2-32
Backlash
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
Yes
Inherited
Yes
Yes
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
Enable zero-crossing detection
Select to enable zero-crossing detection. For more information,
see “Zero-Crossing Detection” in the Simulink documentation.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink documentation.
2-33
Backlash
Examples
The following model shows the effect of a sine wave passing through a
Backlash block.
The Backlash block uses default parameter values: the deadband
width is 1 and the initial output is 0. The following plot shows that
the Backlash block output is zero until the input reaches the end of
the deadband (at 0.5). Now the input and output are engaged and
the output moves as the input does until the input changes direction
(at 1.0). When the input reaches 0, it again engages the output at the
opposite end of the deadband.
2-34
Backlash
Characteristics Direct Feedthrough
Yes
Sample Time
Specified in the Sample time parameter
Scalar Expansion
Yes
Dimensionalized
Yes
Zero-Crossing Detection
Yes, if enabled
2-35
Bad Link
Purpose
Indicate unresolved reference to library block
Description
This block indicates an unresolved reference to a library block (see
“Create a Linked Block”). You can use this block’s parameter dialog box
to fix the reference to point to the actual location of the library block.
Parameters
and
Dialog
Box
Source block
Path of the library block that this link represents. To fix a bad
link, edit this field to reflect the actual path of the library block.
Then select Apply or OK to apply the fix and close the dialog box.
Source type
Type of library block that this link represents.
2-36
Band-Limited White Noise
Purpose
Introduce white noise into continuous system
Library
Sources
Description
Simulation of White Noise
The Band-Limited White Noise block generates normally distributed
random numbers that are suitable for use in continuous or hybrid
systems.
Theoretically, continuous white noise has a correlation time of 0, a flat
power spectral density (PSD), and a total energy of infinity. In practice,
physical systems are never disturbed by white noise, although white
noise is a useful theoretical approximation when the noise disturbance
has a correlation time that is very small relative to the natural
bandwidth of the system.
In Simulink software, you can simulate the effect of white noise by
using a random sequence with a correlation time much smaller than the
shortest time constant of the system. The Band-Limited White Noise
block produces such a sequence. The correlation time of the noise is the
sample rate of the block. For accurate simulations, use a correlation
time much smaller than the fastest dynamics of the system. You can
get good results by specifying
tc ≈
1 2
,
100 fmax
where fmax is the bandwidth of the system in rad/sec.
Comparison with the Random Number Block
The primary difference between this block and the Random Number
block is that the Band-Limited White Noise block produces output at
a specific sample rate. This rate is related to the correlation time of
the noise.
2-37
Band-Limited White Noise
Usage with the Averaging Power Spectral Density Block
The Band-Limited White Noise block specifies a two-sided spectrum,
where the units are Hz. The Averaging Power Spectral Density block
specifies a one-sided spectrum, where the units are the square of the
magnitude per unit radial frequency: Mag^2/(rad/sec). When you feed
the output of a Band-Limited White Noise block into an Averaging
Power Spectral Density block, the average PSD value is π times smaller
than the Noise power of the Band-Limited White Noise block. This
difference is the result of converting the units of one block to the units
of the other: 1/(1/2)(2π) = 1/π, where:
• 1/2 is the factor for converting from a two-sided to one-sided spectrum
• 2π is the factor for converting from Hz to rad/sec
2-38
Algorithm
To produce the correct intensity of this noise, the covariance of the noise
is scaled to reflect the implicit conversion from a continuous PSD to a
discrete noise covariance. The appropriate scale factor is 1/tc, where
tc is the correlation time of the noise. This scaling ensures that the
response of a continuous system to the approximate white noise has the
same covariance as the system would have to true white noise. Because
of this scaling, the covariance of the signal from the Band-Limited
White Noise block is not the same as the Noise power (intensity)
parameter. This parameter is actually the height of the PSD of the
white noise. This block approximates the covariance of white noise as
the Noise power divided by tc.
Data Type
Support
The Band-Limited White Noise block outputs real values of type double.
Band-Limited White Noise
Parameters
and
Dialog
Box
Noise power
Specify the height of the PSD of the white noise. The default
value is 0.1.
Sample time
Specify the correlation time of the noise. The default value is 0.1.
For more information, see “Specify Sample Time” in the Simulink
documentation.
2-39
Band-Limited White Noise
Seed
Specify the starting seed for the random number generator. The
default value is 23341.
Interpret vector parameters as 1-D
Select to output a 1-D array when the block parameters are
vectors. Otherwise, output a 2-D array one of whose dimensions is
1. See “Determining the Output Dimensions of Source Blocks” in
the Simulink documentation.
Examples
The following Simulink examples show how to use the Band-Limited
White Noise block:
• sldemo_f14
• sldemo_radar_eml
Characteristics Sample Time
See Also
2-40
Specified in the Sample time parameter
Scalar Expansion
Yes, of the Noise power and Seed
parameters and output
Dimensionalized
Yes
Multidimensionalized
No
Zero-Crossing Detection
No
Random Number
Bias
Purpose
Add bias to input
Library
Math Operations
Description
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.
Data Type
Support
The Bias block accepts and outputs real or complex values of the
following data types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-41
Bias
Parameters
and
Dialog
Box
Bias
Specify the value of the offset to add to the input signal.
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow,
and you want explicit
saturation protection
in the generated code.
Overflows saturate to
either the minimum
or maximum value
that the data type can
represent.
An overflow associated
with a signed 8-bit
integer can saturate to
–128 or 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
–126.
You want to avoid
overspecifying how
a block handles
2-42
Bias
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
out-of-range signals.
For more information,
see “Checking for
Signal Range Errors”.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result.
Usually, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
Characteristics Direct Feedthrough
Yes
Sample Time
Inherited from the driving block
Scalar Expansion
Yes
States
0
Dimensionalized
Yes
Zero-Crossing Detection
No
2-43
Bit Clear
Purpose
Set specified bit of stored integer to zero
Library
Logic and Bit Operations
Description
The Bit Clear block sets the specified bit, given by its index, of the
stored integer to zero. Scaling is ignored.
You can specify the bit to be set to zero with the Index of bit parameter,
where bit zero is the least significant bit.
Data Type
Support
Parameters
and
Dialog
Box
2-44
The Bit Clear block supports Simulink integer, fixed-point, and Boolean
data types. The block does not support true floating-point data types
or enumerated data types.
Index of bit
Index of bit where bit 0 is the least significant bit.
Bit Clear
Examples
If the Bit Clear block is turned on for bit 2, bit 2 is set to 0. A vector of
constants 2.^[0 1 2 3 4] is represented in binary as [00001 00010
00100 01000 10000]. With bit 2 set to 0, the result is [00001 00010
00000 01000 10000], which is represented in decimal as [1 2 0 8 16].
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes
Bit Set
2-45
Bit Set
Purpose
Set specified bit of stored integer to one
Library
Logic and Bit Operations
Description
The Bit Set block sets the specified bit of the stored integer to one.
Scaling is ignored.
You can specify the bit to be set to one with the Index of bit parameter,
where bit zero is the least significant bit.
Data Type
Support
Parameters
and
Dialog
Box
2-46
The Bit Set block supports Simulink integer, fixed-point, and Boolean
data types. The block does not support true floating-point data types
or enumerated data types.
Index of bit
Index of bit where bit 0 is the least significant bit.
Bit Set
Examples
If the Bit Set block is turned on for bit 2, bit 2 is set to 1. A vector of
constants 2.^[0 1 2 3 4] is represented in binary as [00001 00010
00100 01000 10000]. With bit 2 set to 1, the result is [00101 00110
00100 01100 10100], which is represented in decimal as [5 6 4 12 20].
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes
Bit Clear
2-47
Bitwise Operator
Purpose
Specified bitwise operation on inputs
Library
Logic and Bit Operations
Description
Bitwise Operations
The Bitwise Operator block performs the bitwise operation that you
specify on one or more operands. Unlike logic operations of the Logical
Operator block, bitwise operations treat the operands as a vector of bits
rather than a single value.
You can select one of the following bitwise operations:
Bitwise
Operation
Description
AND
TRUE if the corresponding bits are all TRUE
OR
TRUE if at least one of the corresponding bits is
TRUE
NAND
TRUE if at least one of the corresponding bits is
FALSE
NOR
TRUE if no corresponding bits are TRUE
XOR
TRUE if an odd number of corresponding bits are
TRUE
NOT
TRUE if the input is FALSE (available only for
single input)
Restrictions on Block Operations
The Bitwise Operator block does not support shift operations. For shift
operations, use the Shift Arithmetic block.
When configured as a multi-input XOR gate, this block performs
modulo-2 addition according to the IEEE® Standard for Logic Elements.
2-48
Bitwise Operator
Behavior of Inputs and Outputs
The output data type, which the block inherits from the driving block,
must represent zero exactly. Data types that satisfy this condition
include signed and unsigned integer data types.
The size of the block output depends on the number of inputs, the vector
size, and the operator you select:
• The NOT operator accepts only one input, which can be a scalar or
a vector. If the input is a vector, the output is a vector of the same
size containing the bitwise logical complements of the input vector
elements.
• For a single vector input, the block applies the operation (except the
NOT operator) to all elements of the vector.
-
If you do not specify a bit mask, the output is a scalar.
If you do specify a bit mask, the output is a vector.
• For two or more inputs, the block performs the operation between
all of the inputs. If the inputs are vectors, the block performs the
operation between corresponding elements of the vectors to produce a
vector output.
Bit Mask Behavior
Block behavior changes depending on whether you use a bit mask.
2-49
Bitwise Operator
If the Use bit
mask check
box is...
The block
accepts...
And you
specify...
By using...
Selected
One input
Bit Mask
Any valid
MATLAB
expression,
such as
2^5+2^2+2^0
for the bit mask
00100101
Not selected
Multiple
inputs, all
having the
same base data
type
Number of
input ports
Any positive
integer greater
than 1
Tip You can also use strings to specify a hexadecimal bit mask such as
{'FE73','12AC'}.
Bit Set and Bit Clear Operations
You can use the bit mask to set or clear a bit on the input.
2-50
To perform a...
Set the Operator
parameter to...
And create a bit
mask with...
Bit set
OR
A 1 for each
corresponding input
bit that you want to
set to 1
Bit clear
AND
A 0 for each
corresponding input
bit that you want to
set to 0
Bitwise Operator
Suppose you want to set the fourth bit of an 8-bit input vector. The
bit mask would be 00010000, which you can specify as 2^4 for the Bit
Mask parameter. To clear the bit, the bit mask would be 11101111,
which you can specify as 2^7+2^6+2^5+2^3+2^2+2^1+2^0 for the Bit
Mask parameter.
Data Type
Support
The Bitwise Operator block supports the following data types:
• Built-in integer
• Fixed point
• Boolean
The block does not support floating-point data types or enumerated data
types. For more information, see “Data Types Supported by Simulink”
in the Simulink documentation.
2-51
Bitwise Operator
Parameters
and
Dialog
Box
Operator
Specify the bitwise logical operator for the block operands.
Use bit mask
Select to use the bit mask. Clearing this check box enables
Number of input ports and disables Bit Mask and Treat
mask as.
Number of input ports
Specify the number of inputs. The default value is 1.
2-52
Bitwise Operator
Bit Mask
Specify the bit mask to associate with a single input. This
parameter is available only when you select Use bit mask.
Tip Do not use a mask greater than 53 bits. Otherwise, an error
message appears during simulation.
Treat mask as
Specify whether to treat the mask as a real-world value or a
stored integer. This parameter is available only when you select
Use bit mask.
The encoding scheme is V = SQ + B, as described in “Scaling” in the
Simulink Fixed Point documentation. Real World Value treats
the mask as V. Stored Integer treats the mask as Q.
Examples
Unsigned Inputs for the Bitwise Operator Block
The following model shows how the Bitwise Operator block works for
unsigned inputs.
2-53
Bitwise Operator
Each Constant block outputs an 8-bit unsigned integer (uint8). To
determine the binary value of each Constant block output, use the
dec2bin function. The results for all logic operations appear in the
next table.
Operation
Binary Value
Decimal Value
AND
00101000
40
OR
11111101
253
NAND
11010111
215
NOR
00000010
2
XOR
11111000
248
NOT
N/A
N/A
Signed Inputs for the Bitwise Operator Block
The following model shows how the Bitwise Operator block works for
signed inputs.
Each Constant block outputs an 8-bit signed integer (int8). To
determine the binary value of each Constant block output, use the
2-54
Bitwise Operator
dec2bin function. The results for all logic operations appear in the
next table.
Operation
Binary Value
Decimal Value
AND
01000000
64
OR
11111011
–5
NAND
10111111
–65
NOR
00000100
4
XOR
11000010
–62
NOT
N/A
N/A
Characteristics Direct Feedthrough
See Also
Yes
Sample Time
Inherited from the driving block
Scalar Expansion
Yes, of inputs
Multidimensionalized
Yes
Zero-Crossing Detection
No
Logical Operator
2-55
Block Support Table
Purpose
View data type support for Simulink blocks
Library
Model-Wide Utilities
Description
The Block Support Table block helps you access a table that lists the
data types that Simulink blocks support. Double-click the block to
view the table.
Data Type
Support
Not applicable
Parameters
and
Dialog
Box
Not applicable
Characteristics Not applicable
Alternatives
2-56
To access the information in the Block Support Table, you can enter
showblockdatatypetable at the MATLAB command prompt.
Bus Assignment
Purpose
Replace specified bus elements
Library
Signal Routing
Description
The Bus Assignment block assigns signals connected to its Assignment
input ports (:=) to specified elements of the bus connected to its Bus
input port, replacing the signals previously assigned to those elements.
The change does not affect the signals themselves, it affects only the
composition of the bus. Signals not replaced are unaffected by the
replacement of other signals. For information about buses, see:
• “Composite Signals”
• “Create and Access a Bus”
Connect the bus to be changed to the first input port. Use the block
parameters dialog box to specify the bus elements to be replaced. The
block displays an assignment input port for each such element. The
signal connected to the assignment port must have the same structure,
data type, and numeric type as the bus element to which it corresponds.
You cannot use the Bus Assignment block to replace a bus that is
nested within another bus. No element selected in the dialog box for
replacement can be a bus, and no signal connected to an Assignment
port can be a bus.
All signals in a nonvirtual bus must have the same sample time, even if
the elements of the associated bus object specify inherited sample times.
Any bus operation that would result in a nonvirtual bus that violates
this requirement generates an error. All buses and signals input to a
Bus Assignment block that modifies a nonvirtual bus must therefore
have the same sample time. You can use a Rate Transition block to
change the sample time of an individual signal, or of all signals in a
bus, to allow the signal or bus to be included in a nonvirtual bus. See
“Virtual and Nonvirtual Buses” for more information.
By default, Simulink implicitly converts a non-bus signal to a bus signal
to support connecting the signal to a Bus Assignment or Bus Selector
block. To prevent Simulink from performing that conversion, in the
2-57
Bus Assignment
Model Configuration Parameters > Diagnostics > Connectivity
pane, set the “Non-bus signals treated as bus signals” diagnostic to
warning or error.
By default, Simulink repairs broken selections in the Bus Assignment
and Bus Selector block parameters dialog boxes that are due to
upstream bus hierarchy changes. Simulink generates a warning to
highlight that it made changes. To prevent Simulink from making these
repairs automatically, in the Model Configuration Parameters >
Diagnostics > Connectivity pane, set the “Repair bus selections”
diagnostic to Error without repair.
The following limitations apply to working with arrays of buses, when
using the Bus Assignment block. For details about defining and using
an array of buses, see “Combine Buses into an Array of Buses”.
• You cannot connect an array of buses signal to a Bus Assignment
block. To work with an array of buses signal, first use a Selector
block to select the index for the bus element that you want to use
with the Bus Assignment block. Then use that selected bus element
with the Bus Assignment block.
• You cannot assign into a sub-bus that is an array of buses.
Data Type
Support
The bus input port of the Bus Assignment block accepts and outputs
real or complex values of any data type that Simulink supports,
including fixed-point and enumerated data types. The assignment
input ports accept the same data types as the bus elements to which
they correspond.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
2-58
The Bus Assignment dialog box appears as follows:
Bus Assignment
Signals in the bus
Displays the names of the signals contained by the bus at the
block’s Bus input port. Click any item in the list to select it. To find
the source of the selected signal, click the adjacent Find button.
Simulink opens the subsystem containing the signal source and
highlights the source’s icon. Use the Select>> button to move the
currently selected signal into the adjacent list of signals to be
assigned values (see Signals that are being assigned below).
To refresh the display (e.g., to reflect modifications to the bus
connected to the block), click the adjacent Refresh button.
2-59
Bus Assignment
Signals that are being assigned
Lists the names of bus elements to be assigned values. This block
displays an assignment input port for each bus element in this
list. The label of the corresponding input port contains the name
of the element. You can order the signals by using the Up, Down,
and Remove buttons. Port connectivity is maintained when the
signal order is changed.
Three question marks (???) before the name of a bus element
indicate that the input bus no longer contains an element of
that name, for example, because the bus has changed since the
last time you refreshed the Bus Assignment block’s input and
bus element assignment lists. You can fix the problem either by
modifying the bus to include a signal of the specified name or by
removing the name from the list of bus elements to be assigned
values.
Enable regular expression
To display this parameter, select the Options button on the
right-hand side of the Filter by name edit box (
).
Enables the use of MATLAB regular expressions for filtering
signal names. For example, entering t$ in the Filter by name
edit box displays all signals whose names end with a lowercase
t (and their immediate parents). For details, see “Regular
Expressions”.
The default is On. If you disable use of MATLAB regular
expressions for filtering signal names, filtering treats the text you
enter in the Filter by name edit box as a literal string.
Show filtered results as a flat list
To display this parameter, select the Options button on the
right-hand side of the Filter by name edit box (
).
Uses a flat list format to display the list of filtered signals, based
on the search text in the Filter by name edit box. The flat list
2-60
Bus Assignment
format uses dot notation to reflect the hierarchy of bus signals.
The following is an example of a flat list format for a filtered set of
nested bus signals.
The default is Off, which displays the filtered list using a tree
format.
Characteristics Multidimensionalized
Virtual
Yes
Yes, if the input bus is virtual
For more information, see “Virtual
Blocks” in the Simulink documentation.
See Also
• “Composite Signals”
• “Create and Access a Bus”
• Bus Creator
2-61
Bus Assignment
• Bus Selector
• Bus to Vector
• Simulink.Bus
• Simulink.Bus.cellToObject
• Simulink.Bus.createObject
• Simulink.BusElement
• Simulink.Bus.objectToCell
• Simulink.Bus.save
2-62
Bus Creator
Purpose
Create signal bus
Library
Signal Routing
Description
The Bus Creator block combines a set of signals into a bus. To bundle
a group of signals with a Bus Creator block, set the block parameter
Number of inputs to the number of signals in the group. The block
displays the number of ports that you specify. Connect to the resulting
input ports those signals that you want to group. For information about
buses, see:
• “Composite Signals”
• “Create and Access a Bus”
The signals in the bus are ordered from the top input port to the bottom
input port. See “How to Rotate a Block” in for a description of the port
order for various block orientations.
You can connect any type of signal to the inputs, including other bus
signals. To ungroup the signals, connect the output port of the block to
a Bus Selector block port.
Note Simulink hides the name of a Bus Creator block when you copy it
from the Simulink library to a model.
You can use an array of buses as an input signal to a Bus Creator block.
For details about defining and using an array of buses, see “Combine
Buses into an Array of Buses”.
Naming Signals
The Bus Creator block assigns a name to each signal on the bus that
it creates. This allows you to refer to signals by name when you are
searching for their sources (see “Browsing Bus Signals” on page 2-66) or
selecting signals for connection to other blocks.
2-63
Bus Creator
The block offers two bus signal naming options. You can specify that:
• Each signal on the bus inherits the name of the signal connected
to the bus (the default).
Inputs to a Bus Creator block must have unique names. If there are
duplicate names, the Bus Creator block appends (signal#) to all
input signal names, where # is the input port index.
• Each input signal must have a specific name.
To specify that bus signals inherit their names from input ports, select
Inherit bus signal names from input ports from the list box on
the Block Parameters dialog box. The names of the inherited bus
signals appear in the Signals in the bus list box. For example, suppose
that you have the following model:
2-64
Bus Creator
In the dialog box for LIMITBUSCreator, the signals
upper_saturation_limit and lower_saturation_limit
appear in the Signals in the bus list box:
2-65
Bus Creator
The Bus Creator block generates names for bus signals whose
corresponding inputs do not have names. The names are of the form
signaln, where n is the number of the port to which the input signal is
connected.
You can change the name of any signal by editing its name on the
block diagram or in the Signal Properties dialog box. If you change the
signal name using either approach while the Bus Creator block dialog
box is open, you need to update the name in the dialog box. To do so,
close and reopen the dialog box or click the Refresh button next to the
Signals in the bus list.
To specify that the bus inputs must have specific names, select Require
input signal names to match signals below from the list box
in the block parameter dialog box. The block parameter dialog box
displays the names of the signals currently connected to its inputs, or a
generated name (for example, signal2) for an anonymous input. Then
you can use the parameter dialog box to change the required names
of the block inputs.
To change the required signal name, select the signal in the Signals in
the bus list. The name of the selected signal appears in the Rename
selected signal field. Edit the name in the field and click Apply or OK.
Browsing Bus Signals
The Signals in the bus list on a Bus Creator Block Parameters dialog
box displays a list of the signals entering the block. A plus sign (+)
next to a signal indicates that the signal is itself a bus. To display the
contents of the bus, click the plus sign. If the expanded input includes
bus signals, plus signs appear next to the names of those bus signals.
You can expand them as well. In this way, you can view all signals
entering the block, including those entering via buses.
To find the source of any signal entering the block, select the signal
in the Signals in the bus list and click the adjacent Find button.
Simulink opens the subsystem containing the signal source, if
necessary, and highlights the source’s icon.
2-66
Bus Creator
Data Type
Support
The Bus Creator block accepts and outputs real or complex values
of any data type supported by Simulink, including fixed-point and
enumerated data types, as well as bus objects.
For a discussion on the data types supported by Simulink, refer to “Data
Types Supported by Simulink”.
2-67
Bus Creator
Parameters
and
Dialog
Box
2-68
• “Signal naming options” on page 2-70
• “Number of inputs” on page 2-71
Bus Creator
• “Signals in bus” on page 2-72
• “Enable regular expression” on page 2-86
• “Show filtered results as a flat list” on page 2-87
• “Rename selected signal” on page 2-76
• “Data type” on page 2-77
• “Show data type assistant” on page 2-1665
• “Mode” on page 2-79
• “Output as nonvirtual bus” on page 2-80
2-69
Bus Creator
Signal naming options
Assign input signal names to the corresponding bus signals.
Settings
Default: Inherit bus signal names from input ports
Inherit bus signal names from input ports
Assign input signal names to the corresponding bus signals.
Require input signal names to match signals below
Inputs must have the names listed in the Signals in bus list.
Dependencies
Selecting Require input signal names to match signals below
enables Rename selected signal.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-70
Bus Creator
Number of inputs
Specify the number of input ports on this block.
Settings
Default: 2
To bundle a group of signals, enter the number of signals in the group.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-71
Bus Creator
Signals in bus
Show the signals in the output bus.
Settings
When you modify the Number of inputs parameter, click Refresh to
update the list of signals.
Tips
• A plus sign (+) next to a signal name indicates that the signal is itself
a bus. Click the plus sign to display the subsidiary bus signals.
• Click the Refresh button to update the list after editing the name
of an input signal.
• Click the Find button to highlight the source of the currently selected
signal.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-72
Bus Creator
Enable regular expression
Enable the use of MATLAB regular expressions for filtering signal
names. For example, entering t$ in the Filter by name edit box
displays all signals whose names end with a lowercase t (and their
immediate parents). For details, see “Regular Expressions”.
Settings
Default: On
On
Allow use of MATLAB regular expressions for filtering signal
names.
Off
Disable use of MATLAB regular expressions for filtering signal
names. Filtering treats the text you enter in the Filter by name
edit box as a literal string.
Dependencies
Selecting the Options button on the right-hand side of the Filter by
name edit box (
) enables this parameter.
2-73
Bus Creator
Show filtered results as a flat list
Uses a flat list format to display the list of filtered signals, based on the
search text in the Filter by name edit box. The flat list format uses
dot notation to reflect the hierarchy of bus signals. The following is an
example of a flat list format for a filtered set of nested bus signals.
Settings
Default: Off
On
Display the filtered list of signals using a flat list format,
indicating bus hierarchies with dot notation instead of using a
tree format.
Off
Display filtered bus hierarchies using a tree format.
2-74
Bus Creator
Dependencies
Selecting the Options button on the right-hand side of the Filter by
name edit box (
) enables this parameter.
2-75
Bus Creator
Rename selected signal
List the name of the signal currently selected in the Signals in the
bus list when you select the Require input signal names to match
signals below option.
Settings
Default: ''
Edit this field to change the name of the currently selected signal. See
“Signal Names” for guidelines for signal names.
Dependencies
Selecting Require input signal names to match signals below for
Parameters and signal1 or signal2 for Signals in the bus enables
this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-76
Bus Creator
Data type
Specify the output data type of the external input.
Settings
Default: Inherit:
Inherit:
auto
auto
A rule that inherits a data type
Bus:
<object name>
Data type is a bus object.
<data type expression>
The name of a data type object, for example
Simulink.NumericType
Do not specify a bus object as the expression.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-77
Bus Creator
Show data type assistant
Display the Data Type Assistant.
Settings
The Data Type Assistant helps you set the Output data type
parameter.
For more information, see “Specify Block Output Data Types”.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-78
Bus Creator
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rule for data types. Selecting Inherit enables a
second menu/text box to the right.
Bus
Bus object. Selecting Bus enables a Bus object parameter to the
right, where you enter the name of a bus object that you want to
use to define the structure of the bus. If you need to create or
change a bus object, click Edit to the right of the Bus object
field to open the Simulink Bus Editor. For details about the Bus
Editor, see “Manage Bus Objects with the Bus Editor”.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
Do not specify a bus object as the expression.
Tips
At the beginning of a simulation or when you update the model
diagram, Simulink checks whether the signals connected to this Bus
Creator block have the specified structure. If not, Simulink displays an
error message.
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-79
Bus Creator
Output as nonvirtual bus
Output a nonvirtual bus.
Settings
Default: Off
On
Output a nonvirtual bus.
Off
Output a virtual bus.
Tips
• Select this option if you want code generated from this model to use
a C structure to define the structure of the bus signal output by
this block.
• All signals in a nonvirtual bus must have the same sample time, even
if the elements of the associated bus object specify inherited sample
times. Any bus operation that would result in a nonvirtual bus that
violates this requirement generates an error. Therefore, if you select
this option all signals entering the Bus Creator block must have the
same sample time. You can use a Rate Transition block to change the
sample time of an individual signal, or of all signals in a bus, to allow
the signal or bus to be included in a nonvirtual bus.
Dependencies
The following Data type values enable this parameter:
• Bus:
<object name>
• <data type expression> that specifies a bus object
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-80
Bus Creator
Examples
For an example of how the Bus Creator block works, see the
sldemo_househeat model.
Characteristics Multidimensionalized
Virtual
Yes
Yes, if the output bus is virtual
For more information, see “Virtual
Blocks” in the Simulink documentation.
See Also
• “Composite Signals”
• “Create and Access a Bus”
• Bus Assignment
• Bus Selector
• Bus to Vector
• Simulink.Bus
• Simulink.Bus.cellToObject
• Simulink.Bus.createObject
• Simulink.BusElement
• Simulink.Bus.objectToCell
• Simulink.Bus.save
2-81
Bus Selector
Purpose
Select signals from incoming bus
Library
Signal Routing
Description
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. For information about buses, see:
• “Composite Signals”
• “Create and Access a Bus”
When the block outputs separate elements, it outputs each element
from a separate port from top to bottom of the block. See “How to Rotate
a Block” for a description of the port order for various block orientations.
Note Simulink software hides the name of a Bus Selector block when
you copy it from the Simulink library to a model.
Caution
MathWorks recommends not using Bus Selector blocks in library blocks,
because such use complicates changing the library blocks and increases
the likelihood of errors. See “Buses and Libraries” for more information.
The following limitations apply to working with arrays of buses, when
using the Bus Selector block. For details about defining and using an
array of buses, see “Combine Buses into an Array of Buses”.
• You cannot connect an array of buses signal to a Bus Selector block.
To work with an array of buses signal, first use a Selector block to
select the index for the bus element that you want to use with the
2-82
Bus Selector
Bus Selector block. Then use that selected bus element with the
Bus Selector block.
• You cannot assign into a sub-bus that is an array of buses.
Data Type
Support
A Bus Selector block accepts and outputs real or complex values of any
data type supported by Simulink software, including fixed-point and
enumerated data types.
For a discussion on the data types supported by Simulink software,
see “Data Types Supported by Simulink” in the “Working with Data”
chapter of the Simulink documentation.
Parameters
and
Dialog
Box
The Bus Selector dialog box appears as follows:
2-83
Bus Selector
2-84
Bus Selector
Signals in the bus
Shows the signals in the input bus.
Settings
To refresh the display to reflect modifications to the bus connected to
the block, click Refresh.
Tips
• Use Select>> to select signals to output.
• To find the source of any signal entering the block, select the signal in
the list and click Find. The Simulink software opens the subsystem
containing the signal source, and highlights the source’s icon.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-85
Bus Selector
Enable regular expression
Enable the use of MATLAB regular expressions for filtering signal
names. For example, entering t$ in the Filter by name edit box
displays all signals whose names end with a lowercase t (and their
immediate parents). For details, see “Regular Expressions”.
Settings
Default: On
On
Allow use of MATLAB regular expressions for filtering signal
names.
Off
Disable use of MATLAB regular expressions for filtering signal
names. Filtering treats the text you enter in the Filter by name
edit box as a literal string.
Dependencies
Selecting the Options button on the right-hand side of the Filter by
name edit box (
2-86
) enables this parameter.
Bus Selector
Show filtered results as a flat list
Uses a flat list format to display the list of filtered signals, based on the
search text in the Filter by name edit box. The flat list format uses
dot notation to reflect the hierarchy of bus signals. The following is an
example of a flat list format for a filtered set of nested bus signals.
Settings
Default: Off
On
Display the filtered list of signals using a flat list format,
indicating bus hierarchies with dot notation instead of using a
tree format.
Off
Display filtered bus hierarchies using a tree format.
2-87
Bus Selector
Dependencies
Selecting the Options button on the right-hand side of the Filter by
name edit box (
2-88
) enables this parameter.
Bus Selector
Selected signals
Shows the signals to be output.
Settings
Default: signal1,signal2
You can change the list by using the Up, Down, and Remove buttons.
Tips
• Port connectivity is maintained when the signal order is changed.
• If an output signal listed in the Selected signals list box is not an
input to the Bus Selector block, the signal name is preceded by three
question marks (???).
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-89
Bus Selector
Output as bus
Output the selected elements as a bus.
Settings
Default: Off
On
Output the selected elements as a bus.
Off
Output the selected elements as standalone signals, each from an
output port that is labeled with the corresponding element’s name.
Tips
The output bus is virtual. To produce nonvirtual bus output, insert a
Signal Conversion block after the Bus Selector block. Set the Signal
Conversion block Output parameter to Nonvirtual bus and Data
type parameter to use a Simulink.Bus bus object. For an example, see
the Signal Conversion documentation.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Examples
For an example of how the Bus Selector block works, see the
sldemo_fuelsys model. The Bus Selector block appears in the following
subsystems:
• fuel_rate_control/airflow_calc
• fuel_rate_control/validate_sample_time
Characteristics Multidimensionalized
Virtual
Yes
Yes, if the input bus is virtual
For more information, see “Virtual
Blocks” in the Simulink documentation.
2-90
Bus Selector
See Also
• “Composite Signals”
• “Create and Access a Bus”
• Bus Assignment
• Bus Creator
• Bus to Vector
• Signal Conversion
• Simulink.Bus
• Simulink.Bus.cellToObject
• Simulink.Bus.createObject
• Simulink.BusElement
• Simulink.Bus.objectToCell
• Simulink.Bus.save
2-91
Bus to Vector
Purpose
Convert virtual bus to vector
Library
Signal Attributes
Description
The Bus to Vector block converts a virtual bus signal to a vector signal.
The input bus signal must consist of scalar, 1-D, 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 1-D array.
Use the Bus to Vector block only to replace an implicit bus-to-vector
conversion with an equivalent explicit conversion. See “Bus signal
treated as vector” and “Correcting Buses Used as Muxes” for more
information.
Note Simulink hides the name of a Bus to Vector block when you copy
it from the Simulink library to a model.
Data Type
Support
The Bus to Vector block accepts and outputs real or complex values
of any data type that Simulink supports, including fixed-point and
enumerated data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-92
Bus to Vector
Parameters
and
Dialog
Box
This block has no user-accessible parameters.
Characteristics Multidimensionalized
See Also
Yes
• “Composite Signals”
• “Create and Access a Bus”
• Avoiding Mux/Bus Mixtures
• Bus Assignment
• Bus Creator
• Bus Selector
• Simulink.BlockDiagram.addBusToVector
• Simulink.Bus
• Simulink.Bus.cellToObject
• Simulink.Bus.createObject
2-93
Bus to Vector
• Simulink.BusElement
• Simulink.Bus.objectToCell
• Simulink.Bus.save
2-94
Check Discrete Gradient
Purpose
Check that absolute value of difference between successive samples of
discrete signal is less than upper bound
Library
Model Verification
Description
The Check Discrete Gradient block checks each signal element at its
input to determine whether the absolute value of the difference between
successive samples of the element is less than an upper bound. Use the
block parameter dialog box to specify the value of the upper bound (1
by default). If the verification condition is true, the block does nothing.
Otherwise, the block halts the simulation, by default, and displays an
error message in the Simulation Diagnostics Viewer.
The Model Verification block enabling setting under Debugging
on the Data Validity diagnostics pane of the Configuration Parameters
dialog box lets you enable or disable all model verification blocks,
including Check Discrete Gradient blocks, in a model.
The Check Discrete Gradient block and its companion blocks in
the Model Verification library are intended to facilitate creation of
self-validating models. For example, you can use model verification
blocks to test that signals do not exceed specified limits during
simulation. When you are satisfied that a model is correct, you can
turn error checking off by disabling the verification blocks. You do not
have to physically remove them from the model. If you need to modify
a model, you can temporarily turn the verification blocks back on to
ensure that your changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
Data Type
Support
The Check Discrete Gradient block accepts single, double, int8,
int16, and int32 input signals of any dimensions. This block also
supports fixed-point data types.
2-95
Check Discrete Gradient
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
Maximum gradient
Specify the upper bound on the gradient of the discrete input
signal.
Enable assertion
Clearing this check box disables the Check Discrete Gradient
block, that is, causes the model to behave as if the block did
2-96
Check Discrete Gradient
not exist. The Model Verification block enabling setting
under Debugging on the Data Validity diagnostics pane of
the Configuration Parameters dialog box allows you to enable or
disable all model verification blocks in a model, including Check
Discrete Gradient blocks, regardless of the setting of this option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Discrete Gradient block
to halt the simulation when the block’s output is zero and display
an error message in the Simulink Simulation Diagnostics Viewer.
Otherwise, the block displays a warning message in the MATLAB
Command Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Discrete Gradient block
to output a Boolean signal that is true (1) at each time step if
the assertion succeeds and false (0) if the assertion fails. The
data type of the output signal is Boolean if you have selected the
Implement logic signals as Boolean data check box on the
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Select icon type
Specify the type of icon used to display this block in a block
diagram: either graphic or text. The graphic option displays
a graphical representation of the assertion condition on the
icon. The text option displays a mathematical expression that
represents the assertion condition. If the icon is too small to
display the expression, the text icon displays an exclamation
point. To see the expression, enlarge the block.
2-97
Check Discrete Gradient
Characteristics Direct Feedthrough
2-98
No
Sample Time
Inherited from the driving block
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Check Dynamic Gap
Purpose
Check that gap of possibly varying width occurs in range of signal’s
amplitudes
Library
Model Verification
Description
The Check Dynamic Gap block checks that a gap of possibly varying
width occurs in the range of a signal’s amplitudes. The test signal
is the signal connected to the input labeled sig. The inputs labeled
min and max specify the lower and upper bounds of the dynamic gap,
respectively. If the verification condition is true, the block does nothing.
If not, the block halts the simulation, by default, and displays an error
message.
The Check Dynamic Gap block and its companion blocks in the Model
Verification library are intended to facilitate creation of self-validating
models. For example, you can use model verification blocks to test
that signals do not exceed specified limits during simulation. When
you are satisfied that a model is correct, you can turn error checking
off by disabling the verification blocks. You do not have to physically
remove them from the model. If you need to modify a model, you can
temporarily turn the verification blocks back on to ensure that your
changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
2-99
Check Dynamic Gap
Data Type
Support
The Check Dynamic Gap block accepts input signals of any dimensions
and of any numeric data type that Simulink supports. All three input
signals must have the same dimension and data type. If the inputs are
nonscalar, the block checks each element of the input test signal to the
corresponding elements of the reference signals.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
2-100
Enable assertion
Clearing this check box disables the Check Dynamic Gap block,
that is, causes the model to behave as if the block did not
Check Dynamic Gap
exist. The Model Verification block enabling setting under
Debugging on the Data Validity diagnostics pane of the
Configuration Parameters dialog box allows you to enable or
disable all model verification blocks in a model, including Check
Dynamic Gap blocks, regardless of the setting of this option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Dynamic Gap block to
halt the simulation when the block’s output is zero and display an
error message in the Simulation Diagnostics Viewer. Otherwise,
the block displays a warning message in the MATLAB Command
Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Dynamic Gap block
to output a Boolean signal that is true (1) at each time step if
the assertion succeeds and false (0) if the assertion fails. The
data type of the output signal is Boolean if you have selected the
Implement logic signals as Boolean data check box on the
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Select icon type
Specify the type of icon used to display this block in a block
diagram: either graphic or text. The graphic option displays
a graphical representation of the assertion condition on the
icon. The text option displays a mathematical expression that
represents the assertion condition. If the icon is too small to
display the expression, the text icon displays an exclamation
point. To see the expression, enlarge the block.
2-101
Check Dynamic Gap
Characteristics Direct Feedthrough
2-102
No
Sample Time
Inherited from driving block
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Check Dynamic Lower Bound
Purpose
Check that one signal is always less than another signal
Library
Model Verification
Description
The Check Dynamic Lower Bound block checks that the amplitude of a
reference signal is less than the amplitude of a test signal at the current
time step. The test signal is the signal connected to the input labeled sig.
If the verification condition is true, the block does nothing. If not, the
block halts the simulation, by default, and displays an error message.
The Check Dynamic Lower Bound block and its companion blocks in
the Model Verification library are intended to facilitate creation of
self-validating models. For example, you can use model verification
blocks to test that signals do not exceed specified limits during
simulation. When you are satisfied that a model is correct, you can
turn error checking off by disabling the verification blocks. You do not
have to physically remove them from the model. If you need to modify
a model, you can temporarily turn the verification blocks back on to
ensure that your changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
Data Type
Support
The Check Dynamic Lower Bound block accepts input signals of any
numeric data type that Simulink supports. The test and the reference
signals must have the same dimensions and data type. If the inputs are
2-103
Check Dynamic Lower Bound
nonscalar, the block checks each element of the input test signal to the
corresponding elements of the reference signal.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
2-104
Enable assertion
Clearing this check box disables the Check Dynamic Lower
Bound block, that is, causes the model to behave as if the block
did not exist. The Model Verification block enabling setting
under Debugging on the Data Validity diagnostics pane of
the Configuration Parameters dialog box allows you to enable or
disable all model verification blocks, including Check Dynamic
Check Dynamic Lower Bound
Lower Bound blocks, in a model regardless of the setting of this
option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Dynamic Lower Bound
block to halt the simulation when the block’s output is zero and
display an error message in the Simulation Diagnostics Viewer.
Otherwise, the block displays a warning message in the MATLAB
Command Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Dynamic Lower Bound
block to output a Boolean signal that is true (1) at each time step
if the assertion succeeds and false (0) if the assertion fails. The
data type of the output signal is Boolean if you have selected the
Implement logic signals as Boolean data check box on the
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Select icon type
Specify the type of icon used to display this block in a block
diagram: either graphic or text. The graphic option displays
a graphical representation of the assertion condition on the
icon. The text option displays a mathematical expression that
represents the assertion condition. If the icon is too small to
display the expression, the text icon displays an exclamation
point. To see the expression, enlarge the block.
Characteristics Direct Feedthrough
Sample Time
No
Inherited from driving block
2-105
Check Dynamic Lower Bound
2-106
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Check Dynamic Range
Purpose
Check that signal falls inside range of amplitudes that varies from time
step to time step
Library
Model Verification
Description
The Check Dynamic Range block checks that a test signal falls inside a
range of amplitudes at each time step. The width of the range can vary
from time step to time step. The input labeled sig is the test signal. The
inputs labeled min and max are the lower and upper bounds of the valid
range at the current time step. If the verification condition is true, the
block does nothing. If not, the block halts the simulation, by default,
and displays an error message.
The Check Dynamic Range block and its companion blocks in the Model
Verification library are intended to facilitate creation of self-validating
models. For example, you can use model verification blocks to test
that signals do not exceed specified limits during simulation. When
you are satisfied that a model is correct, you can turn error checking
off by disabling the verification blocks. You do not have to physically
remove them from the model. If you need to modify a model, you can
temporarily turn the verification blocks back on to ensure that your
changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
2-107
Check Dynamic Range
Data Type
Support
The Check Dynamic Range block accepts input signals of any
dimensions and of any numeric data type that Simulink supports. All
three input signals must have the same dimension and data type. If the
inputs are nonscalar, the block checks each element of the input test
signal to the corresponding elements of the reference signals.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
2-108
Enable assertion
Clearing this check box disables the Check Dynamic Range
block, that is, causes the model to behave as if the block did
not exist. The Model Verification block enabling setting
Check Dynamic Range
under Debugging on the Data Validity diagnostics pane of
the Configuration Parameters dialog box allows you to enable or
disable all model verification blocks in a model, including Check
Dynamic Range blocks, regardless of the setting of this option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Dynamic Range block to
halt the simulation when the block’s output is zero and display an
error message in the Simulation Diagnostics Viewer. Otherwise,
the block displays a warning message in the MATLAB Command
Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Dynamic Range block
to output a Boolean signal that is true (1) at each time step if
the assertion succeeds and false (0) if the assertion fails. The
data type of the output signal is Boolean if you selected the
Implement logic signals as Boolean data check box on the
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Select icon type
Specify the type of icon used to display this block in a block
diagram: either graphic or text. The graphic option displays
a graphical representation of the assertion condition on the
icon. The text option displays a mathematical expression that
represents the assertion condition. If the icon is too small to
display the expression, the text icon displays an exclamation
point. To see the expression, enlarge the block.
2-109
Check Dynamic Range
Characteristics Direct Feedthrough
2-110
No
Sample Time
Inherited from driving block
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Check Dynamic Upper Bound
Purpose
Check that one signal is always greater than another signal
Library
Model Verification
Description
The Check Dynamic Upper Bound block checks that the amplitude of
a reference signal is greater than the amplitude of a test signal at the
current time step. The test signal is the signal connected to the input
labeled sig. If the verification condition is true, the block does nothing.
If not, the block halts the simulation, by default, and displays an error
message.
The Check Dynamic Upper Bound block and its companion blocks in
the Model Verification library are intended to facilitate creation of
self-validating models. For example, you can use model verification
blocks to test that signals do not exceed specified limits during
simulation. When you are satisfied that a model is correct, you can
turn error-checking off by disabling the verification blocks. You do not
have to physically remove them from the model. If you need to modify
a model, you can temporarily turn the verification blocks back on to
ensure that your changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
Data Type
Support
The Check Dynamic Upper Bound block accepts input signals of any
dimensions and of any numeric data type that Simulink supports. The
test and the reference signals must have the same dimensions and data
2-111
Check Dynamic Upper Bound
type. If the inputs are nonscalar, the block compares each element of the
input test signal to the corresponding elements of the reference signal.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
2-112
Enable assertion
Clearing this check box disables the Check Dynamic Upper
Bound block, that is, causes the model to behave as if the block
did not exist. The Model Verification block enabling setting
under Debugging on the Data Validity diagnostics pane of
the Configuration Parameters dialog box allows you to enable or
disable all model verification blocks, including Check Dynamic
Check Dynamic Upper Bound
Upper Bound blocks, in a model regardless of the setting of this
option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Dynamic Upper Bound
block to halt the simulation when the block’s output is zero and
display an error message in the Simulation Diagnostics Viewer.
Otherwise, the block displays a warning message in the MATLAB
Command Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Dynamic Upper Bound
block to output a Boolean signal that is true (1) at each time step
if the assertion succeeds and false (0) if the assertion fails. The
data type of the output signal is Boolean if you have selected the
Implement logic signals as Boolean data check box on the
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Select icon type
Specify the type of icon used to display this block in a block
diagram: either graphic or text. The graphic option displays
a graphical representation of the assertion condition on the
icon. The text option displays a mathematical expression that
represents the assertion condition. If the icon is too small to
display the expression, the text icon displays an exclamation
point. To see the expression, enlarge the block.
Characteristics Direct Feedthrough
Sample Time
No
Inherited from driving block
2-113
Check Dynamic Upper Bound
2-114
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Check Input Resolution
Purpose
Check that input signal has specified resolution
Library
Model Verification
Description
The Check Input Resolution block checks whether the input signal has
a specified scalar or vector resolution (see Resolution). If the resolution
is a scalar, the input signal must be a multiple of the resolution within
a 10e-3 tolerance. If the resolution is a vector, the input signal must
equal an element of the resolution vector. If the verification condition is
true, the block does nothing. If not, the block halts the simulation, by
default, and displays an error message.
The Check Input Resolution block and its companion blocks in the Model
Verification library are intended to facilitate creation of self-validating
models. For example, you can use model verification blocks to test
that signals do not exceed specified limits during simulation. When
you are satisfied that a model is correct, you can turn error checking
off by disabling the verification blocks. You do not have to physically
remove them from the model. If you need to modify a model, you can
temporarily turn the verification blocks back on to ensure that your
changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
Data Type
Support
The Check Input Resolution block accepts input signals of data type
double and of any dimension. If the input signal is nonscalar, the block
checks the resolution of each element of the input test signal.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-115
Check Input Resolution
Parameters
and
Dialog
Box
2-116
Resolution
Specify the resolution that the input signal must have.
Enable assertion
Clearing this check box disables the Check Input Resolution
block, that is, causes the model to behave as if the block did
not exist. The Model Verification block enabling setting
under Debugging on the Data Validity diagnostics pane of
the Configuration Parameters dialog box allows you to enable or
Check Input Resolution
disable all model verification blocks in a model, including Check
Input Resolution blocks, regardless of the setting of this option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Input Resolution
block to halt the simulation when the block’s output is zero and
display an error message in the Simulation Diagnostics Viewer.
Otherwise, the block displays a warning message in the MATLAB
Command Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Input Resolution block
to output a Boolean signal that is true (1) at each time step if
the assertion succeeds and false (0) if the assertion fails. The
data type of the output signal is Boolean if you have selected the
Implement logic signals as Boolean data check box on the
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Characteristics Direct Feedthrough
No
Sample Time
Inherited from driving block
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
2-117
Check Static Gap
Purpose
Check that gap exists in signal’s range of amplitudes
Library
Model Verification
Description
The Check Static Gap block checks that each element of the input signal
is less than (or optionally equal to) a static lower bound or greater than
(or optionally equal to) a static upper bound at the current time step.
If the verification condition is true, the block does nothing. If not, the
block halts the simulation, by default, and displays an error message.
The Check Static Gap block and its companion blocks in the Model
Verification library are intended to facilitate creation of self-validating
models. For example, you can use model verification blocks to test
that signals do not exceed specified limits during simulation. When
you are satisfied that a model is correct, you can turn error checking
off by disabling the verification blocks. You do not have to physically
remove them from the model. If you need to modify a model, you can
temporarily turn the verification blocks back on to ensure that your
changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
Data Type
Support
The Check Static Gap block accepts input signals of any dimensions and
of any numeric data type that Simulink supports.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-118
Check Static Gap
Parameters
and
Dialog
Box
Upper bound
Specify the upper bound of the gap in the input signal’s range
of amplitudes.
2-119
Check Static Gap
Inclusive upper bound
Selecting this check box specifies that the gap includes the upper
bound.
Lower bound
Specify the lower bound of the gap in the input signal’s range
of amplitudes.
Inclusive lower bound
Selecting this check box specifies that the gap includes the lower
bound.
Enable assertion
Clearing this check box disables the Check Static Gap block, that
is, causes the model to behave as if the block did not exist. The
Model Verification block enabling setting under Debugging
on the Data Validity diagnostics pane of the Configuration
Parameters dialog box allows you to enable or disable all model
verification blocks in a model, including Check Static Gap blocks,
regardless of the setting of this option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Static Gap block to halt
the simulation when the block’s output is zero and display an
error message in the Simulation Diagnostics Viewer. Otherwise,
the block displays a warning message in the MATLAB Command
Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Static Gap block to
output a Boolean signal that is true (1) at each time step if the
assertion succeeds and false (0) if the assertion fails. The data
type of the output signal is Boolean if you have selected the
Implement logic signals as Boolean data check box on the
2-120
Check Static Gap
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Select icon type
Specify the type of icon used to display this block in a block
diagram: either graphic or text. The graphic option displays
a graphical representation of the assertion condition on the
icon. The text option displays a mathematical expression that
represents the assertion condition. If the icon is too small to
display the expression, the text icon displays an exclamation
point. To see the expression, enlarge the block.
Characteristics Direct Feedthrough
No
Sample Time
Inherited from the driving block
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
2-121
Check Static Lower Bound
Purpose
Check that signal is greater than (or optionally equal to) static lower
bound
Library
Model Verification
Description
The Check Static Lower Bound block checks that each element of the
input signal is greater than (or optionally equal to) a specified lower
bound at the current time step. Use the block parameter dialog box to
specify the value of the lower bound and whether the lower bound is
inclusive. If the verification condition is true, the block does nothing. If
not, the block halts the simulation, by default, and displays an error
message.
The Check Static Lower Bound block and its companion blocks in
the Model Verification library are intended to facilitate creation of
self-validating models. For example, you can use model verification
blocks to test that signals do not exceed specified limits during
simulation. When you are satisfied that a model is correct, you can
turn error checking off by disabling the verification blocks. You do not
have to physically remove them from the model. If you need to modify
a model, you can temporarily turn the verification blocks back on to
ensure that your changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
Data Type
Support
The Check Static Lower Bound block accepts input signals of any
dimensions and of any numeric data type that Simulink supports.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-122
Check Static Lower Bound
Parameters
and
Dialog
Box
Lower bound
Specify the lower bound on the range of amplitudes that the input
signal can have.
Inclusive boundary
Selecting this check box makes the range of valid input amplitudes
include the lower bound.
2-123
Check Static Lower Bound
Enable assertion
Clearing this check box disables the Check Static Lower Bound
block, that is, causes the model to behave as if the block did
not exist. The Model Verification block enabling setting
under Debugging on the Data Validity diagnostics pane of
the Configuration Parameters dialog box allows you to enable or
disable all model verification blocks in a model, including Check
Static Lower Bound blocks, regardless of the setting of this option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Static Lower Bound
block to halt the simulation when the block’s output is zero and
display an error message in the Simulation Diagnostics Viewer.
Otherwise, the block displays a warning message in the MATLAB
Command Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Static Lower Bound
block to output a Boolean signal that is true (1) at each time step
if the assertion succeeds and false (0) if the assertion fails. The
data type of the output signal is Boolean if you have selected the
Implement logic signals as Boolean data check box on the
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Select icon type
Specify the type of icon used to display this block in a block
diagram: either graphic or text. The graphic option displays
a graphical representation of the assertion condition on the
icon. The text option displays a mathematical expression that
represents the assertion condition. If the icon is too small to
display the expression, the text icon displays an exclamation
point. To see the expression, enlarge the block.
2-124
Check Static Lower Bound
Characteristics Direct Feedthrough
No
Sample Time
Inherited from driving block
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
2-125
Check Static Range
Purpose
Check that signal falls inside fixed range of amplitudes
Library
Model Verification
Description
The Check Static Range block checks that each element of the input
signal falls inside the same range of amplitudes at each time step. Use
the block parameter dialog box to specify the upper and lower bounds of
the valid amplitude range and whether the range includes the bounds.
If the verification condition is true, the block does nothing. If not, the
block halts the simulation, by default, and displays an error message.
The Check Static Range block and its companion blocks in the Model
Verification library are intended to facilitate creation of self-validating
models. For example, you can use model verification blocks to test
that signals do not exceed specified limits during simulation. When
you are satisfied that a model is correct, you can turn error checking
off by disabling the verification blocks. You do not have to physically
remove them from the model. If you need to modify a model, you can
temporarily turn the verification blocks back on to ensure that your
changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
Data Type
Support
The Check Static Range block accepts input signals of any dimensions
and of any numeric data type that Simulink supports.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-126
Check Static Range
Parameters
and
Dialog
Box
Upper bound
Specify the upper bound of the range of valid input signal
amplitudes.
2-127
Check Static Range
Inclusive upper bound
Selecting this check box specifies that the valid signal range
includes the upper bound.
Lower bound
Specify the lower bound of the range of valid input signal
amplitudes.
Inclusive lower bound
Selecting this check box specifies that the valid signal range
includes the lower bound.
Enable assertion
Clearing this check box disables the Check Static Range block,
that is, causes the model to behave as if the block did not
exist. The Model Verification block enabling setting under
Debugging on the Data Validity diagnostics pane of the
Configuration Parameters dialog box allows you to enable or
disable all model verification blocks in a model, including Check
Static Range blocks, regardless of the setting of this option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Static Range block to
halt the simulation when the block’s output is zero and display an
error message in the Simulation Diagnostics Viewer. Otherwise,
the block displays a warning message in the MATLAB Command
Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Static Range block
to output a Boolean signal that is true (1) at each time step if
the assertion succeeds and false (0) if the assertion fails. The
data type of the output signal is Boolean if you have selected the
Implement logic signals as Boolean data check box on the
2-128
Check Static Range
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Select icon type
Specify the type of icon used to display this block in a block
diagram: either graphic or text. The graphic option displays
a graphical representation of the assertion condition on the
icon. The text option displays a mathematical expression that
represents the assertion condition. If the icon is too small to
display the expression, the text icon displays an exclamation
point. To see the expression, enlarge the block.
Examples
The sldemo_fuelsys model shows how you can use the Check Static
Range block to verify that the sample time is consistent throughout
the model.
The Check Static Range block appears in the
sldemo_fuelsys/fuel_rate_control/validate_sample_time
subsystem.
Characteristics Direct Feedthrough
No
Sample Time
Inherited from the driving block
Scalar Expansion
No
Dimensionalized
Yes
2-129
Check Static Range
2-130
Multidimensionalized
Yes
Zero-Crossing Detection
No
Check Static Upper Bound
Purpose
Check that signal is less than (or optionally equal to) static upper bound
Library
Model Verification
Description
The Check Static Upper Bound block checks that each element of the
input signal is less than (or optionally equal to) a specified upper bound
at the current time step. Use the block parameter dialog box to specify
the value of the upper bound and whether the bound is inclusive. If the
verification condition is true, the block does nothing. If not, the block
halts the simulation, by default, and displays an error message.
The Check Static Upper Bound block and its companion blocks in
the Model Verification library are intended to facilitate creation of
self-validating models. For example, you can use model verification
blocks to test that signals do not exceed specified limits during
simulation. When you are satisfied that a model is correct, you can
turn error checking off by disabling the verification blocks. You do not
have to physically remove them from the model. If you need to modify
a model, you can temporarily turn the verification blocks back on to
ensure that your changes do not break the model.
Note For information about how Simulink Coder generated code
handles Model Verification blocks, see “Debug”.
Data Type
Support
The Check Static Upper Bound block accepts input signals of any
dimensions and of any numeric data type that Simulink supports.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-131
Check Static Upper Bound
Parameters
and
Dialog
Box
Upper bound
Specify the upper bound on the range of amplitudes that the input
signal can have.
Inclusive boundary
Selecting this check box makes the range of valid input amplitudes
include the upper bound.
2-132
Check Static Upper Bound
Enable assertion
Clearing this check box disables the Check Static Upper Bound
block, that is, causes the model to behave as if the block did
not exist. The Model Verification block enabling setting
under Debugging on the Data Validity diagnostics pane of
the Configuration Parameters dialog box allows you to enable or
disable all model verification blocks in a model, including Check
Static Upper Bound blocks, regardless of the setting of this option.
Simulation callback when assertion fails
Specify a MATLAB expression to evaluate when the assertion
fails. Because the expression is evaluated in the MATLAB
workspace, define all variables used in the expression in that
workspace.
Stop simulation when assertion fails
Selecting this check box causes the Check Static Upper Bound
block to halt the simulation when the block’s output is zero and
display an error message in the Simulation Diagnostics Viewer.
Otherwise, the block displays a warning message in the MATLAB
Command Window and continues the simulation.
Output assertion signal
Selecting this check box causes the Check Static Upper Bound
block to output a Boolean signal that is true (1) at each time step
if the assertion succeeds and false (0) if the assertion fails. The
data type of the output signal is Boolean if you have selected the
Implement logic signals as Boolean data check box on the
Optimization pane of the Configuration Parameters dialog box.
Otherwise the data type of the output signal is double.
Select icon type
Specify the type of icon used to display this block in a block
diagram: either graphic or text. The graphic option displays
a graphical representation of the assertion condition on the
icon. The text option displays a mathematical expression that
represents the assertion condition. If the icon is too small to
display the expression, the text icon displays an exclamation
point. To see the expression, enlarge the block.
2-133
Check Static Upper Bound
Characteristics Direct Feedthrough
2-134
No
Sample Time
Inherited from driving block
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Chirp Signal
Purpose
Generate sine wave with increasing frequency
Library
Sources
Description
The Chirp Signal block generates a sine wave whose frequency increases
at a linear rate with time. You can use this block for spectral analysis of
nonlinear systems. The block generates a scalar or vector output.
The parameters, Initial frequency, Target time, and Frequency at
target time, determine the block’s output. You can specify any or all
of these variables as scalars or arrays. All the parameters specified
as arrays must have the same dimensions. The block expands scalar
parameters to have the same dimensions as the array parameters. The
block output has the same dimensions as the parameters unless you
select the Interpret vector parameters as 1-D check box. If you
select this check box and the parameters are row or column vectors, the
block outputs a vector (1-D array) signal.
The following limitations apply to the Chirp Signal block:
• The start time of the simulation must be 0. To confirm this value,
go to the Solver pane in the Configuration Parameters dialog box
and view the Start time field.
• Suppose that you use a Chirp Signal block in an enabled subsystem.
Whenever the subsystem is enabled, the block output matches
what would appear if the subsystem were enabled throughout the
simulation.
Data Type
Support
The Chirp Signal block outputs a real-valued signal of type double.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-135
Chirp Signal
Parameters
and
Dialog
Box
Initial frequency
The initial frequency of the signal, specified as a scalar or matrix
value. The default is 0.1 Hz.
Target time
The time at which the frequency reaches the Frequency at
target time parameter value, a scalar or matrix value. The
frequency continues to change at the same rate after this time.
The default is 100 seconds.
2-136
Chirp Signal
Frequency at target time
The frequency of the signal at the target time, a scalar or matrix
value. The default is 1 Hz.
Interpret vector parameters as 1-D
If selected, column or row matrix values for the Initial
frequency, Target time, and Frequency at target time
parameters result in a vector output whose elements are the
elements of the row or column. For more information, see
“Determining the Output Dimensions of Source Blocks” in the
Simulink documentation.
Characteristics Sample Time
Continuous
Scalar Expansion
Yes, of parameters
Dimensionalized
Yes
Zero-Crossing Detection
No
2-137
Clock
Purpose
Display and provide simulation time
Library
Sources
Description
The Clock block outputs the current simulation time at each simulation
step. This block is useful for other blocks that need the simulation time.
When you need the current time within a discrete system, use the
Digital Clock block.
Data Type
Support
Parameters
and
Dialog
Box
2-138
The Clock block outputs a real-valued signal of type double.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Display time
Select this check box to display the current simulation time inside
the Clock block icon.
Clock
Decimation
Specify a positive integer for the interval at which Simulink
updates the Clock icon when you select Display time.
Suppose that the decimation is 1000. For a fixed integration step
of 1 millisecond, the Clock icon updates at 1 second, 2 seconds,
and so on.
Examples
The following Simulink examples show how to use the Clock block:
• sldemo_tonegen_fixpt
• penddemo
Characteristics Sample Time
See Also
Continuous
Scalar Expansion
N/A
Dimensionalized
No
Zero-Crossing Detection
No
Digital Clock
2-139
Combinatorial Logic
Purpose
Implement truth table
Library
Logic and Bit Operations
Description
The Combinatorial Logic block implements a standard truth table for
modeling programmable logic arrays (PLAs), logic circuits, decision
tables, and other Boolean expressions. You can use this block in
conjunction with Memory blocks to implement finite-state machines
or flip-flops.
You specify a matrix that defines all possible block outputs as the
Truth table parameter. Each row of the matrix contains the output for
a different combination of input elements. You must specify outputs for
every combination of inputs. The number of columns is the number of
block outputs.
The relationship between the number of inputs and the number of
rows is:
number of rows = 2 ^ (number of inputs)
Simulink returns a row of the matrix by computing the row’s index from
the input vector elements. Simulink computes the index by building a
binary number where input vector elements having zero values are 0
and elements having nonzero values are 1, then adding 1 to the result.
For an input vector, u, of m elements:
row index = 1 + u(m)*20 + u(m-1)*21 + ...
+ u(1)*2m-1
Two-Input AND Logic
This example builds a two-input AND function, which returns 1 when
both input elements are 1, and 0 otherwise. To implement this function,
specify the Truth table parameter value as [0; 0; 0; 1]. The
portion of the model that provides the inputs to and the output from the
Combinatorial Logic block might look like this:
2-140
Combinatorial Logic
The following table indicates the combination of inputs that generate
each output. The input signal labeled “Input 1” corresponds to the
column in the table labeled Input 1. Similarly, the input signal “Input
2” corresponds to the column with the same name. The combination of
these values determines the row of the Output column of the table that
is passed as block output.
For example, if the input vector is [1 0], the input references the third
row:
(2^1*1 + 1)
The output value is 0.
Row
Input 1
Input 2
Output
1
0
0
0
2
0
1
0
3
1
0
0
4
1
1
1
Circuit Logic
This sample circuit has three inputs: the two bits (a and b) to be
summed and a carry-in bit (c). It has two outputs: the carry-out bit (c’)
and the sum bit (s).
2-141
Combinatorial Logic
The truth table and corresponding outputs for each combination of
input values for this circuit appear in the following table.
Inputs
Outputs
a
b
c
c’
s
0
0
0
0
0
0
0
1
0
1
0
1
0
0
1
0
1
1
1
0
1
0
0
0
1
1
0
1
1
0
1
1
0
1
0
1
1
1
1
1
To implement this adder with the Combinatorial Logic block, you enter
the 8-by-2 matrix formed by columns c’ and s as the Truth table
parameter.
You can also implement sequential circuits (that is, circuits with states)
with the Combinatorial Logic block by including an additional input
for the state of the block and feeding the output of the block back into
this state input.
2-142
Combinatorial Logic
Data Type
Support
The type of signals accepted by a Combinatorial Logic block depends on
whether you selected the Boolean logic signals option (see “Implement
logic signals as Boolean data (vs. double)”). If this option is enabled, the
block accepts real signals of type Boolean or double. The Truth table
parameter can have Boolean values (0 or 1) of any data type, including
fixed-point data types. If the table contains non-Boolean values, the
data type of the table must be double.
The type of the output is the same as that of the input except that
the block outputs double if the input is Boolean and the truth table
contains non-Boolean values.
If Boolean compatibility mode is disabled, the Combinatorial Logic
block accepts only signals of type Boolean. The block outputs double if
the truth table contains non-Boolean values of type double. Otherwise,
the output is Boolean.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-143
Combinatorial Logic
Parameters
and
Dialog
Box
Truth table
Specify the matrix of outputs. Each column corresponds to an
element of the output vector and each row corresponds to a row
of the truth table.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink documentation.
2-144
Combinatorial Logic
Examples
Usage with the Memory Block to Implement a Finite-State
Machine
The sldemo_clutch model shows how you can use the Combinatorial
Logic block with the Memory block to implement a finite-state machine.
The finite-state machine appears in the Friction Mode Logic/Lockup
FSM subsystem.
2-145
Combinatorial Logic
Usage with a Stateflow® Chart to Implement a Finite-State
Machine
The powerwindow model shows how you can use two Combinatorial
Logic blocks as inputs to a Stateflow chart to implement a finite-state
machine.
Characteristics Direct Feedthrough
2-146
Yes
Sample Time
Inherited from the driving block
Scalar Expansion
No
Dimensionalized
Yes, the output width is the number of
columns of the Truth table parameter
Zero-Crossing Detection
No
Compare To Constant
Purpose
Determine how signal compares to specified constant
Library
Logic and Bit Operations
Description
The Compare To Constant block compares an input signal to a constant.
Specify the constant in the Constant value parameter. Specify how the
input is compared to the constant value with the Operator parameter.
The Operator parameter can have the following values:
• == — Determine whether the input is equal to the specified constant.
• ~= — Determine whether the input is not equal to the specified
constant.
• < — Determine whether the input is less than the specified constant.
• <= — Determine whether the input is less than or equal to the
specified constant.
• > — Determine whether the input is greater than the specified
constant.
• >= — Determine whether the input is greater than or equal to the
specified constant.
The output is 0 if the comparison is false, and 1 if it is true.
Data Type
Support
The Compare To Constant block accepts inputs of any data type that
Simulink supports, including fixed-point and enumerated data types.
The block first converts its Constant value parameter to the input
data type, and then performs the specified operation. The block output
is uint8 or boolean as specified by the Output data type parameter.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-147
Compare To Constant
Parameters
and
Dialog
Box
Operator
Specify how the input is compared to the constant value, as
discussed in Description.
Constant value
Specify the constant value to which the input is compared.
Output data type
Specify the data type of the output, boolean or uint8.
Enable zero-crossing detection
Select to enable zero-crossing detection. For more information,
see “Zero-Crossing Detection” in the Simulink documentation.
2-148
Compare To Constant
Characteristics Direct Feedthrough
See Also
Yes
Scalar Expansion
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
Yes, if enabled.
Compare To Zero
2-149
Compare To Zero
Purpose
Determine how signal compares to zero
Library
Logic and Bit Operations
Description
The Compare To Zero block compares an input signal to zero. Specify
how the input is compared to zero with the Operator parameter. The
Operator parameter can have the following values:
• == — Determine whether the input is equal to zero.
• ~= — Determine whether the input is not equal to zero.
• < — Determine whether the input is less than zero.
• <= — Determine whether the input is less than or equal to zero.
• > — Determine whether the input is greater than zero.
• >= — Determine whether the input is greater than or equal to zero.
The output is 0 if the comparison is false, and 1 if it is true.
Data Type
Support
The Compare To Zero block accepts inputs of the following data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
The block output is uint8 or boolean, depending on your selection for
the Output data type parameter. For more information, see “Data
Types Supported by Simulink” in the Simulink documentation.
2-150
Compare To Zero
Tip If the input data type cannot represent zero, parameter overflow
occurs. To detect this overflow, go to the Diagnostics > Data Validity
pane of the Configuration Parameters dialog box and set Parameters >
Detect overflow to warning or error.
In this case, the block compares the input signal to the ground value
of the input data type. For example, if you have an input signal of
type fixdt(0,8,2^0,10), the input data type can represent unsigned
8-bit integers from 10 to 265 due to a bias of 10. The ground value is
10, instead of 0.
Parameters
and
Dialog
Box
Operator
Specify how the input is compared to zero, as discussed in
Description.
Output data type
Specify the data type of the output, boolean or uint8.
2-151
Compare To Zero
Enable zero-crossing detection
Select to enable zero-crossing detection. For more information,
see “Zero-Crossing Detection” in the Simulink documentation.
Characteristics Direct Feedthrough
See Also
2-152
Yes
Scalar Expansion
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
Yes, if enabled.
Compare To Constant
Complex to Magnitude-Angle
Purpose
Compute magnitude and/or phase angle of complex signal
Library
Math Operations
Description
The Complex to Magnitude-Angle block accepts a complex-valued signal
of type double or single. It outputs the magnitude and/or phase angle
of the input signal, depending on the setting of the Output parameter.
The outputs are real values of the same data type as the block input.
The input can be an array of complex signals, in which case the output
signals are also arrays. The magnitude signal array contains the
magnitudes of the corresponding complex input elements. The angle
output similarly contains the angles of the input elements.
Data Type
Support
See the preceding description.
2-153
Complex to Magnitude-Angle
Parameters
and
Dialog
Box
Output
Determines the output of this block. Choose from the following
values: Magnitude and angle (outputs the input signal’s
magnitude and phase angle in radians), Magnitude (outputs the
input’s magnitude), Angle (outputs the input’s phase angle in
radians).
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. For more information, see “Specify
Sample Time” in the Simulink documentation.
Characteristics Direct Feedthrough
2-154
Yes
Sample Time
Specified by the Sample time parameter
Scalar Expansion
No
Dimensionalized
Yes
Complex to Magnitude-Angle
Multidimensionalized
Yes
Zero-Crossing Detection
No
2-155
Complex to Real-Imag
Purpose
Output real and imaginary parts of complex input signal
Library
Math Operations
Description
The Complex to Real-Imag block accepts a complex-valued signal of any
data type that Simulink supports, including fixed-point data types. It
outputs the real and/or imaginary part of the input signal, depending on
the setting of the Output parameter. The real outputs are of the same
data type as the complex input. The input can be an array (vector or
matrix) of complex signals, in which case the output signals are arrays
of the same dimensions. The real array contains the real parts of the
corresponding complex input elements. The imaginary output similarly
contains the imaginary parts of the input elements.
Data Type
Support
See the preceding description. For more information, see “Data Types
Supported by Simulink” in the Simulink documentation.
2-156
Complex to Real-Imag
Parameters
and
Dialog
Box
Output
Determines the output of this block. Choose from the following
values: Real and imag (outputs the input signal’s real and
imaginary parts), Real (outputs the input’s real part), Imag
(outputs the input’s imaginary part).
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. For more information, see “Specify
Sample Time” in the Simulink documentation.
Characteristics Direct Feedthrough
Yes
Sample Time
Specified by the Sample time parameter
Scalar Expansion
No
Dimensionalized
Yes
2-157
Complex to Real-Imag
2-158
Multidimensionalized
Yes
Zero-Crossing Detection
No
Configurable Subsystem
Purpose
Represent any block selected from user-specified library of blocks
Library
Ports & Subsystems
Description
The Configurable Subsystem block represents one of a set of blocks
contained in a specified library of blocks. The block’s context menu lets
you choose which block the configurable subsystem represents.
Configurable Subsystem blocks simplify creation of models that
represent families of designs. For example, suppose that you want to
model an automobile that offers a choice of engines. To model such a
design, you would first create a library of models of the engine types
available with the car. You would then use a Configurable Subsystem
block in your car model to represent the choice of engines. To model a
particular variant of the basic car design, a user need only choose the
engine type, using the configurable engine block’s dialog.
To create a configurable subsystem in a model, you must first create a
library containing a master configurable subsystem and the blocks that
it represents. You can then create configurable instances of the master
subsystem by dragging copies of the master subsystem from the library
and dropping them into models.
You can add any type of block to a master configurable subsystem
library. Simulink derives the port names for the configurable subsystem
by making a unique list from the port names of all the choices. However,
Simulink uses default port names for non-subsystem block choices.
Note that you cannot break library links in a configurable subsystem
because Simulink uses those links to reconfigure the subsystem when
you choose a new configuration. Breaking links would be useful only if
2-159
Configurable Subsystem
you do not intend to reconfigure the subsystem. In this case, you can
replace the configurable subsystem with a nonconfigurable subsystem
that implements the permanent configuration.
Creating a Master Configurable Subsystem
To create a master configurable subsystem:
1 Create a library of blocks representing the various configurations
of the configurable subsystem.
2 Save the library.
3 Create an instance of the Configurable Subsystem block in the
library.
To do this, drag a copy of the Configurable Subsystem block from the
Simulink Ports & Subsystems library into the library you created in
the previous step.
4 Display the Configurable Subsystem block dialog by double-clicking
it. The dialog displays a list of the other blocks in the library.
5 Under List of block choices in the dialog box, select the blocks that
represent the various configurations of the configurable subsystems
you are creating.
6 Click the OK button to apply the changes and close the dialog box.
7 Select Block Choice from the Configurable Subsystem block’s
context menu.
The context menu displays a submenu listing the blocks that the
subsystem can represent.
8 Select the block that you want the subsystem to represent by default.
9 Save the library.
2-160
Configurable Subsystem
Note If you add or remove blocks from a library, you must recreate
any Configurable Subsystem blocks that use the library.
If you modify a library block that is the default block choice for a
configurable subsystem, the change does not immediately propagate
to the configurable subsystem. To propagate this change, do one of
the following:
• Change the default block choice to another block in the subsystem,
then change the default block choice back to the original block.
• Recreate the configurable subsystem block, including the selection of
the updated block as the default block choice.
Creating an Instance of a Configurable Subsystem
To create an instance of a configurable subsystem in a model:
1 Open the library containing the master configurable subsystem.
2 Drag a copy of the master into the model.
3 Select Block Choice from the copy’s context menu.
4 Select the block that you want the configurable subsystem to
represent.
The instance of the configurable system displays the icon and parameter
dialog box of the block that it represents.
Setting Instance Block Parameters
As with other blocks, you can use the parameter dialog box of a
configurable subsystem instance to set the instance’s parameters
interactively and the set_param command to set the parameters from
the MATLAB command line or in a MATLAB file. If you use set_param,
you must specify the full path name of the configurable subsystem’s
current block choice as the first argument of set_param, for example:
2-161
Configurable Subsystem
curr_choice = get_param('mymod/myconfigsys', 'BlockChoice');
curr_choice = ['mymod/myconfigsys/' curr_choice];
set_param(curr_choice, 'MaskValues', ...);
Mapping I/O Ports
A configurable subsystem displays a set of input and output ports
corresponding to input and output ports in the selected library.
Simulink uses the following rules to map library ports to Configurable
Subsystem block ports:
• Map each uniquely named input/output port in the library to a
separate input/output port of the same name on the Configurable
Subsystem block.
• Map all identically named input/output ports in the library to the
same input/output ports on the Configurable Subsystem block.
• Terminate any input/output port not used by the currently selected
library block with a Terminator/Ground block.
This mapping allows a user to change the library block represented by a
Configurable Subsystem block without having to rewire connections to
the Configurable Subsystem block.
For example, suppose that a library contains two blocks A and B and
that block A has input ports labeled a, b, and c and an output port
labeled d and that block B has input ports labeled a and b and an
output port labeled e. A Configurable Subsystem block based on this
library would have three input ports labeled a, b, and c, respectively,
and two output ports labeled d and e, respectively, as illustrated in
the following figure.
2-162
Configurable Subsystem
In this example, port a on the Configurable Subsystem block connects to
port a of the selected library block no matter which block is selected. On
the other hand, port c on the Configurable Subsystem block functions
only if library block A is selected. Otherwise, it simply terminates.
Note A Configurable Subsystem block does not provide ports that
correspond to non-I/O ports, such as the trigger and enable ports on
triggered and enabled subsystems. Thus, you cannot use a Configurable
Subsystem block directly to represent blocks that have such ports. You
can do so indirectly, however, by wrapping such blocks in subsystem
blocks that have input or output ports connected to the non-I/O ports.
Convert to Variable Subsystem
Right-click a configurable subsystem and select Subsystems and
Model Reference > Convert Subsystem To > Variant Subsystem.
Simulink copies the block choices of the configurable subsystem to a
new variant subsystem and adds the appropriate number of inports
and outports to the variant subsystem. The current block choice of the
configurable subsystem is made the active variant selection.
See Variant Subsystem for more information on variant choices.
Data Type
Support
The Configurable Subsystem block accepts and outputs signals of the
same types that are accepted or output by the block that it currently
represents. The data types can be any that Simulink supports,
including fixed-point data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-163
Configurable Subsystem
Parameters
and
Dialog
Box
List of block choices
Select the blocks you want to include as members of the
configurable subsystem. You can include user-defined subsystems
as blocks.
Port names
Lists of input and output ports of member blocks. In the case of
multiports, you can rearrange selected port positions by clicking
the Up and Down buttons.
Characteristics A Configurable Subsystem block has the characteristics of the block
that it currently represents. Double-clicking the block opens the dialog
box for the block that it currently represents.
2-164
Constant
Purpose
Generate constant value
Library
Sources
Description
The Constant block generates a real or complex constant value.
The block generates scalar, vector, or matrix output, depending on:
• The dimensionality of the Constant value parameter
• The setting of the Interpret vector parameters as 1-D parameter
Also, the block can generate either a sample-based or frame-based
signal, depending on the setting of the Sampling mode.
The output of the block has the same dimensions and elements as the
Constant value parameter. If you specify for this parameter a vector
that you want the block to interpret as a vector, select the Interpret
vector parameters as 1-D parameter. Otherwise, if you specify a
vector for the Constant value parameter, the block treats that vector
as a matrix.
Data Type
Support
By default, the Constant block outputs a signal whose data type and
complexity are the same as those of the Constant value parameter.
However, you can specify the output to be any data type that Simulink
supports, including fixed-point and enumerated data types. The
Enumerated Constant block can be more convenient than the Constant
block for outputting a constant enumerated value. You can also use a
bus object as the output data type, which can help to simplify a model
(see “Bus Support” on page 2-187 for details).
2-165
Constant
Note If you specify a bus object as the data type for this block,
do not set the minimum and maximum values for bus data on the
block. Simulink ignores these settings. Instead, set the minimum and
maximum values for bus elements of the bus object specified as the data
type. The values should be finite real double scalar.
For information on the Minimum and Maximum properties of a bus
element, see Simulink.BusElement.
For more information about data type support, see “Data Types
Supported by Simulink” in the Simulink documentation.
2-166
Constant
Parameters
and
Dialog
Box
The Main pane of the Constant block dialog box appears as follows:
The Signal Attributes pane of the Constant block dialog appears as
follows:
2-167
Constant
2-168
Constant
Constant value
Specify the constant value output of the block.
Settings
Default: 1
Minimum: value from the Output minimum parameter
Maximum: value from the Output maximum parameter
• You can enter any expression that MATLAB evaluates as a matrix,
including the Boolean keywords true and false.
• If you set the Output data type to be a bus object, you can specify
either:
-
A full MATLAB structure corresponding to the bus object
0 to indicate a structure corresponding to the ground value of the
bus object
For details, see “Bus Support” on page 2-187.
• For non-bus data types, Simulink converts this parameter from its
value data type to the specified output data type offline, using round
toward nearest and saturation.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-169
Constant
Interpret vector parameters as 1-D
Select this check box to output a vector of length N if the Constant
value parameter evaluates to an N-element row or column vector.
Settings
Default: On
On
Outputs a vector of length N if the Constant value parameter
evaluates to an N-element row or column vector. For example, the
block outputs a matrix of dimension 1-by-N or N-by-1.
Off
Does not output a vector of length N if the Constant value
parameter evaluates to an N-element row or column vector.
If you clear this check box, you can interact with the Sampling
mode parameter.
Dependencies
This parameter enables Sampling mode.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-170
Constant
Sampling mode
Specify whether the output signal is Sample based or Frame based.
Settings
Default: Sample based
Sample based
The output signal is sample-based.
Frame based
The output signal is frame-based.
Tip
If you specify the Data type to be a bus object, do not specify a
frame-based sampling mode.
Dependencies
• Frame-based processing requires a DSP System Toolbox license.
For more information, see “Sample- and Frame-Based Concepts” in
the DSP System Toolbox documentation.
• Clearing Interpret vector parameters as 1-D enables this
parameter.
• Selecting Sample based enables the following parameter:
-
Sample time
• Selecting Frame based enables the following parameter:
-
Frame period
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-171
Constant
Sample time
Specify the interval between times that the Constant block output can
change during simulation (for example, due to tuning the Constant
value parameter).
Settings
Default: inf
This setting indicates that the block output can never change. This
setting speeds simulation and generated code by avoiding the need to
recompute the block output.
See “Specify Sample Time” in the online documentation for more
information.
Dependency
Sampling mode enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-172
Constant
Output minimum
Specify the minimum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the minimum value for bus data on the block. Simulink ignores
this setting. Instead, set the minimum values for bus elements of the
bus object specified as the data type. For information on the Minimum
property of a bus element, see Simulink.BusElement.
Simulink uses the minimum to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-173
Constant
Output maximum
Specify the maximum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the maximum value for bus data on the block. Simulink ignores this
setting. Instead, set the maximum values for bus elements of the bus
object specified as the data type. For information on the Maximum
property of a bus element, see Simulink.BusElement.
Simulink uses the maximum value to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-174
Constant
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-175
Constant
Output data type
Specify the output data type.
Settings
Default: Inherit:
Inherit:
Inherit from 'Constant value'
Inherit from 'Constant value'
Use data type of Constant value.
Inherit:
Inherit via back propagation
Use data type of the driving block.
double
Output data type is double.
single
Output data type is single.
int8
Output data type is int8.
uint8
Output data type is uint8.
int16
Output data type is int16.
uint16
Output data type is uint16.
int32
Output data type is int32.
uint32
Output data type is uint32.
boolean
Output data type is boolean.
fixdt(1,16)
Output data type is fixed point fixdt(1,16).
2-176
Constant
fixdt(1,16,0)
Output data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0))
Output data type is fixed point fixdt(1,16,2^0,0).
Enum:
<class name>
Use an enumerated data type, for example, Enum:
Bus:
BasicColors.
<object name>
Data type is a bus object.
<data type expression>
Data type is data type object, for example Simulink.NumericType.
Do not specify a bus object as the expression.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Block Output Data Types” for more information.
2-177
Constant
Show data type assistant
Display the Data Type Assistant.
Settings
The Data Type Assistant helps you set the Output data type
parameter.
For more information, see “Specify Block Output Data Types”.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-178
Constant
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second menu/text box to the right. Select one of the following
choices:
• Inherit from 'Constant value' (default)
• Inherit via back propagation
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
• boolean
Fixed point
Fixed-point data types.
Enumerated
Enumerated data types. Selecting Enumerated enables a second
menu/text box to the right, where you can enter the class name.
2-179
Constant
Bus
Bus object. Selecting Bus enables a Bus object parameter to the
right, where you enter the name of a bus object that you want to
use to define the structure of the bus. If you need to create or
change a bus object, click Edit to the right of the Bus object
field to open the Simulink Bus Editor. For details about the Bus
Editor, see “Manage Bus Objects with the Bus Editor”.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
Do not specify a bus object as the expression.
2-180
Constant
Frame period
Specify the interval between frames that the Constant block output can
change during simulation (for example, due to tuning the Constant
value parameter).
Settings
Default: inf
Dependency
Sampling mode enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-181
Constant
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-182
Constant
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-183
Constant
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-184
Constant
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-185
Constant
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-186
Constant
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
Bus
Support
Using Bus Objects as the Output Data Type
The Constant block supports nonvirtual buses as the output data type.
If you use a bus object as the data type, set Constant value to 0 or a
MATLAB structure that matches the bus object.
Using Structures for the Constant Value
The structure you specify must contain a value for every element of the
bus represented by the bus object.
You can use the Simulink.Bus.createMATLABStruct to create a full
structure that corresponds to a bus.
You can use Simulink.Bus.createObject to create a bus object from a
MATLAB structure.
2-187
Constant
Sampling Mode
Do not specify a frame-based sampling mode if you specify the Data
type to be a bus object.
Example of Using a Bus Object for a Constant Block
The following example illustrates how using a bus object as an output
data type for a Constant block can help to simplify a model.
1 Open the busic_example model and update it.
This model uses six Constant blocks. For details about the model, see
“Examples of Partial Structures”.
2 Open the constantbus_example model and update it. This model
uses one Constant block that replaces the six Constant blocks in
the busic_example model.
2-188
Constant
3 Simulate the constantbus_example model. To verify that
the output from the Constant block reflects the values from
constant_value_struct, perform the next two steps.
4 At the MATLAB command line, examine the constant_value_struct
structure that the Constant block uses for its Constant value
parameter.
constant_value_struct
constant_value_struct =
A: [1x1 struct]
B: 5
C: [1x1 struct]
5 Examine the logged data in the logsout variable, focusing on the B
element of the A1 bus signal. The constant_value_struct structure
sets the B element to 5.
logsout.A1.B.Data
Setting Configuration Parameters to Support Using a Bus
Object Data Type
To enable the use of a bus object as an output data type, before you start
a simulation, set the following diagnostics as indicated:
2-189
Constant
• In the Diagnostics > Connectivity pane of the Configuration
Parameters dialog box, set “Mux blocks used to create bus signals” to
error.
• In the Diagnostics > Data Validity pane of the Configuration
Parameters dialog box, set “Underspecified initialization detection”
to simplified.
The documentation for these diagnostics explains how to convert your
model to handle error messages the diagnostics generate.
Arrays of Buses Not Supported
You cannot use an array of buses with a Constant block.
Examples
The following Simulink examples show how to use the Constant block:
• sldemo_auto_climatecontrol
• sldemo_boiler
• sldemo_bounce
Characteristics Direct Feedthrough
See Also
2-190
N/A
Sample Time
Specified in the Sample time parameter
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Enumerated Constant
Coulomb and Viscous Friction
Purpose
Model discontinuity at zero, with linear gain elsewhere
Library
Discontinuities
Description
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.
The block output matches the MATLAB result for:
y = sign(x) .* (Gain .* abs(x) + Offset)
where y is the output, x is the input, Gain is the signal gain for nonzero
input values, and Offset is the Coulomb friction.
The block accepts one input and generates one output. The input can be
a scalar, vector, or matrix with real and complex elements.
• For a scalar input, Gain and Offset can have dimensions that differ
from the input. The output is a scalar, vector, or matrix depending
on the dimensions of Gain and Offset.
• For a vector or matrix input, Gain and Offset must be scalar or have
the same dimensions as the input. The output is a vector or matrix of
the same dimensions as the input.
Data Type
Support
The Coulomb and Viscous Friction block supports real inputs of the
following data types:
• Floating point
• Built-in integer
• Fixed point
The block supports complex inputs only for floating-point data types,
double and single. The output uses the same data type as the input.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-191
Coulomb and Viscous Friction
Parameters
and
Dialog
Box
2-192
Coulomb friction value
Specify the offset that applies to all input values.
Coefficient of viscous friction
Specify the signal gain for nonzero input values.
Coulomb and Viscous Friction
Examples
Scalar Input
Suppose that you have the following model:
In this model, block input x and Gain are scalar values, but Offset is
a vector. Therefore, the block uses element-wise scalar expansion to
compute the output.
Vector Input
Suppose that you have the following model:
In this model, vector dimensions for block input x and Offset are the
same.
2-193
Coulomb and Viscous Friction
Matrix Input
Suppose that you have the following model:
In this model, matrix dimensions for block input x and Offset are the
same.
Characteristics Direct Feedthrough
2-194
Yes
Sample Time
Inherited from the driving block
Scalar Expansion
Yes
Dimensionalized
Yes
Multidimensionalized
No
Zero-Crossing Detection
No
Counter Free-Running
Purpose
Count up and overflow back to zero after reaching maximum value
for specified number of bits
Library
Sources
Description
The Counter Free-Running block counts up until reaching the maximum
value, 2Nbits – 1, where Nbits is the number of bits. Then the counter
overflows to zero and begins counting up again.
After overflow, the counter always initializes to zero. However, if you
select the global doubles override, the Counter Free-Running block
does not wrap back to zero.
Data Type
Support
The Counter Free-Running block outputs an unsigned integer.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-195
Counter Free-Running
Parameters
and
Dialog
Box
2-196
Number of Bits
Specify the number of bits.
When you
use...
Such as...
The block counts
up to...
Which
is...
A positive
integer
8
28 – 1
255
An unsigned
integer
expression
uint8(8)
uint8(2uint8(8) – 1)
254
Counter Free-Running
Sample time
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink documentation.
Examples
Bit Specification Using a Positive Integer
Suppose that you have the following model:
The block parameters are:
Parameter
Setting
Number of Bits
8
Sample time
-1
The solver options for the model are:
Parameter
Setting
Stop time
255
Type
Fixed-step
Solver
discrete (no continuous
states)
Fixed-step size
1
At t = 255, the counter reaches the maximum value:
28 – 1
2-197
Counter Free-Running
If you change the stop time of the simulation to 256, the counter wraps
to zero.
Bit Specification Using an Unsigned Integer Expression
Suppose that you have the following model:
The block parameters are:
Parameter
Setting
Number of Bits
uint8(8)
Sample time
-1
The solver options for the model are:
Parameter
Setting
Stop time
254
Type
Fixed-step
Solver
discrete (no continuous
states)
Fixed-step size
1
At t = 254, the counter reaches the maximum value:
uint8(2uint8(8) – 1)
If you change the stop time of the simulation to 255, the counter wraps
to zero.
2-198
Counter Free-Running
Characteristics Sample Time
See Also
Specified in the Sample time parameter
Scalar Expansion
No
Zero-Crossing Detection
No
Counter Limited
2-199
Counter Limited
Purpose
Count up and wrap back to zero after outputting specified upper limit
Library
Sources
Description
The Counter Limited block counts up until the specified upper limit is
reached. Then the counter wraps back to zero, and restarts counting
up. The counter always initializes to zero.
You can specify the upper limit with the Upper limit parameter.
You can specify the sample time with the Sample time parameter. A
Sample time of -1 means that the sample time is inherited.
The output is an unsigned integer of 8, 16, or 32 bits, with the smallest
number of bits needed to represent the upper limit.
Data Type
Support
2-200
The Counter Limited block outputs an unsigned integer.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Counter Limited
Parameters
and
Dialog
Box
Examples
Upper limit
Specify the upper limit.
Sample time
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink documentation.
The following Simulink examples show how to use the Counter Limited
block:
• sldemo_tonegen_fixpt
2-201
Counter Limited
Characteristics Sample Time
Scalar Expansion
See Also
2-202
Counter Free-Running
Specified in the Sample time parameter
No
Data Store Memory
Purpose
Define data store
Library
Signal Routing
Description
The Data Store Memory block defines and initializes a named shared
data store, which is a memory region usable by Data Store Read and
Data Store Write blocks that specify the same data store name.
The location of the Data Store Memory block that defines a data store
determines which Data Store Read and Data Store Write blocks can
access the data store:
• If the Data Store Memory block is in the top-level system, Data Store
Read and Data Store Write blocks anywhere in the model can access
the data store.
• If the Data Store Memory block is in a subsystem, Data Store Read
and Data Store Write blocks in the same subsystem or in any
subsystem below it in the model hierarchy can access the data store.
Data Store Read or Data Store Write blocks cannot access a Data Store
Memory block that is either in a model that contains a Model block
or in a referenced model.
Do not include a Data Store Memory block in a subsystem that a For
Each Subsystem block represents.
Use the Initial value parameter to initialize the data store. Specify
a scalar value or an array of values in the Initial value parameter.
The dimensions of the array determine the dimensionality of the data
store. Any data written to the data store must have the dimensions
designated by the Initial value parameter. Otherwise, an error occurs.
Obtaining correct results from data stores requires ensuring that data
store reads and writes occur in the expected order. For details, see:
• “Order Data Store Access”
• “Data Store Diagnostics”
2-203
Data Store Memory
• “Log Data Stores”
You can use Simulink.Signal objects in addition to, or instead of, Data
Store Memory blocks to define data stores. A data store defined in the
base workspace with a signal object is a global data store. Global data
stores are accessible to every model, including all referenced models.
See “Data Stores” for more information.
Data Type
Support
The Data Store Memory block stores real or complex signals of any
data type that Simulink supports, including fixed-point, bus object,
and enumerated data types.
Note If you specify a bus object as the data type for this block,
do not set the minimum and maximum values for bus data on the
block. Simulink ignores these settings. Instead, set the minimum and
maximum values for bus elements of the bus object specified as the data
type. The values should be finite real double scalar.
For information on the Minimum and Maximum properties of a bus
element, see Simulink.BusElement.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
You can use arrays of buses with a Data Store Memory block. For
details about defining and using an array of buses, see “Combine Buses
into an Array of Buses”.
2-204
Data Store Memory
Parameters
and
Dialog
Box
The Main pane of the Data Store Memory block dialog box appears
as follows:
2-205
Data Store Memory
Data store name
Specify a name for the data store you are defining with this block.
Data Store Read and Data Store Write blocks with the same name
can read from, and write to, the data store initialized by this
block. The name can represent a Data Store Memory block or a
sign object defined to be a data store.
Corresponding Data Store Read/Write blocks
List all the Data Store Read and Data Store Write blocks that
have the same data store name as the current block, and that are
in the current system or in any subsystem below it in the model
hierarchy. Double-click a block in this list to highlight the block
and bring it to the foreground.
The Signal Attributes pane of the Data Store Memory block dialog box
appears as follows:
2-206
Data Store Memory
2-207
Data Store Memory
Initial value
Specify the initial value or values of the data store. The
dimensions of this value determine the dimensions of data that
may be written to the data store. The Minimum parameter
specifies the minimum value for this parameter, and the
Maximum parameter specifies the maximum value.
Initial value dimensions must match the dimensions that you
specify in the Signal Attributes > Dimensions parameter,
unless the initial value is a MATLAB structure.
Minimum
Specify the minimum value that the block should output. The
default value is [] (unspecified). This number must be a finite
real double scalar value.
Note If you specify a bus object as the data type for this
block, do not set the minimum value for bus data on the block.
Simulink ignores this setting. Instead, set the minimum values
for bus elements of the bus object specified as the data type. For
information on the Minimum property of a bus element, see
Simulink.BusElement.
Simulink uses the minimum value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Maximum
Specify the maximum value that the block should output. The
default value is [] (unspecified). This number must be a finite
real double scalar value.
2-208
Data Store Memory
Note If you specify a bus object as the data type for this
block, do not set the maximum value for bus data on the block.
Simulink ignores this setting. Instead, set the maximum values
for bus elements of the bus object specified as the data type. For
information on the Maximum property of a bus element, see
Simulink.BusElement.
Simulink uses the maximum value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Data type
Specify the output data type. You can set it to:
• A rule that inherits a data type (for example, Inherit:
auto)
• The name of a built-in data type (for example, single)
• The name of a data type object (for example, a
Simulink.NumericType object)
• An expression that evaluates to a data type (for example,
fixdt(1,16,0)). Do not specify a bus object as the data type
in an expression; use Bus: <object name> to specify a bus
data type.
• Bus: <object name>; enter the name of a bus object that you
want to use to define the structure of the bus. The bus must be
a nonvirtual bus. If you need to create or change a bus object,
click the Show data type assistant button and then click the
Edit button to the right of the Bus object field to open the
Simulink Bus Editor. For details about the Bus Editor, see
“Manage Bus Objects with the Bus Editor”
2-209
Data Store Memory
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the Data
type parameter.
See “Specify Block Output Data Types”.
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Signal type
Specify the numeric type, real or complex, of the values in the
data store.
Dimensions (-1 to infer from Initial value)
Specify dimensions that match the dimensions of the Initial
value dimensions, unless you specify a MATLAB structure for the
initial value. For example, if you use a MATLAB structure for the
initial value, then you need to specify dimensions to initialize an
array of buses with this MATLAB structure.
Interpret vector parameters as 1-D
If you enable this option and specify the Initial value parameter
as a column or row matrix, Simulink initializes the data store
to a 1-D array whose elements are equal to the elements of the
row or column vector. See “Determining the Output Dimensions
of Source Blocks”.
Data store must resolve to Simulink signal object
Specify that Simulink software, when compiling the model,
searches the model and base workspace for a Simulink.Signal
object having the same name, as described in “Symbol Resolution”.
If Simulink does not find such an object, the compilation stops,
with an error. Otherwise, Simulink compares the attributes of
the signal object to the corresponding attributes of the Data
Store Memory block. If the block and the object attributes are
2-210
Data Store Memory
inconsistent, Simulink halts model compilation and displays an
error.
Package
Select a package that defines the custom storage class you want
to apply. If you have defined any packages of your own, click
Refresh. This action adds all user-defined packages on your
search path to the package list.
Storage class
Select a custom storage class for the signal object. When no
Package is selected, setting this parameter to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables Storage
type qualifier.
Storage type qualifier
Specify the Simulink Coder storage type qualifier.
See “States” in the Simulink Coder documentation for more information.
The Diagnostics pane of the Data Store Memory block dialog box
appears as follows:
2-211
Data Store Memory
2-212
Data Store Memory
Detect read before write
Select the diagnostic action to take if the model attempts to read
data from a data store to which it has not written data in this
time step. See also the “Detect read before write” diagnostic in the
Data Store Memory Block section of the Model Configuration
Parameters > Diagnostics > Data Validity pane.
Default: warning
none
Take no action.
warning
Display a warning.
error
Terminate the simulation and display an error message.
Detect write after read
Select the diagnostic action to take if the model attempts to write
data to the data store after previously reading data from it in
the current time step. See also the “Detect write after read”
diagnostic in the Data Store Memory Block section of the
Model Configuration Parameters > Diagnostics > Data
Validity pane.
Default: warning
none
Take no action.
warning
Display a warning.
error
Terminate the simulation and display an error message.
2-213
Data Store Memory
Detect write after write
Select the diagnostic action to take if the model attempts to write
data to the data store twice in succession in the current time step.
See also the “Detect write after write” diagnostic in the Data
Store Memory Block section of the Model Configuration
Parameters > Diagnostics > Data Validity pane.
Default: warning
none
Take no action.
warning
Display a warning.
error
Terminate the simulation and display an error message.
The Logging pane of the Data Store Memory block dialog box appears
as follows:
2-214
Data Store Memory
2-215
Data Store Memory
Log signal data
Select this option to save the values of this signal to the MATLAB
workspace during simulation. See “Signal Logging” for details.
Logging name
Use this pair of controls, consisting of a list box and an edit field,
to specify the name associated with logged signal data.
Simulink uses the signal name as its logging name by default. To
specify a custom logging name, select Custom from the list box and
enter the custom name in the adjacent edit field.
Data
Use this group of controls to limit the amount of data that
Simulink logs for this signal.
• Limit data points to last: Discard all but the last N data
points, where N is the number that you enter in the adjacent
edit field.
• Decimation: Log every Nth data point, where N is the number
that you enter in the adjacent edit field. For example, suppose
that your model uses a fixed-step solver with a step size of 0.1
s. If you select this option and accept the default decimation
value (2), Simulink records data points for this signal at times
0.0, 0.2, 0.4, and so on.
For more information, see “Log Data Stores”
Characteristics Sample Time
See Also
N/A
Dimensionalized
Yes
Multidimensionalized
Yes
• “Data Stores”
• “Access Data Stores with Simulink Blocks”
• Data Store Read
2-216
Data Store Memory
• Data Store Write
• “Log Data Stores”
2-217
Data Store Read
Purpose
Read data from data store
Library
Signal Routing
Description
The Data Store Read block copies data from the named data store to
its output. More than one Data Store Read block can read from the
same data store.
The data store from which the data is read is determined by the location
of the Data Store Memory block or signal object that defines the data
store. For more information, see “Data Stores” and Data Store Memory.
Obtaining correct results from data stores requires ensuring that data
store reads and writes occur in the expected order. See “Order Data
Store Access” and “Data Store Diagnostics” for details.
Data Type
Support
The Data Store Read block can output a real or complex signal of any
data type that Simulink supports, including fixed-point, bus object,
and enumerated data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
You can use arrays of buses with a Data Store Read block. For details
about defining and using an array of buses, see “Combine Buses into
an Array of Buses”.
2-218
Data Store Read
Parameters
and
Dialog
Box
The Parameters pane of the Data Store Read block dialog box appears
as follows:
Data store name
Specifies the name of the data store from which this block reads
data. The adjacent pull-down list lists the names of Data Store
Memory blocks that exist at the same level in the model as
the Data Store Read block or at higher levels. The pulldown
list also includes all Simulink.Signal objects in the base and
model workspaces. To change the name, select a name from the
pull-down list or enter the name directly in the edit field.
When Simulink software compiles the model containing this
block, Simulink software searches the model upwards from this
block’s level for a Data Store Memory block having the specified
data store name. If Simulink software does not find such a block,
it searches the model workspace and the MATLAB workspace for
2-219
Data Store Read
a Simulink.Signal object having the same name. See “Symbol
Resolution” for more information about the search path.
If Simulink software finds the signal object, it creates a hidden
Data Store Memory block at the model’s root level having the
properties specified by the signal object and an initial value of 0. If
Simulink software finds neither the Data Store Memory block nor
the signal object, it halts the compilation and displays an error.
Data store memory block
This field lists the Data Store Memory block that initialized the
store from which this block reads.
Data store write blocks
This parameter lists all the Data Store Write blocks with the same
data store name as this block that are in the same (sub)system or
in any subsystem below it in the model hierarchy. Double-click
any entry on this list to highlight the block and bring it to the
foreground.
Sample time
The sample time, which controls when the block reads from
the data store. A value of -1 indicates that the sample time is
inherited. See “Specify Sample Time” for more information.
The Element Selection pane of the Data Store Read block dialog box
appears as follows:
2-220
Data Store Read
Use the Element Selection pane to select a subset of the bus or
matrix elements defined for the associated data store. The Data Store
Read block icon reflects the elements that you specify. For details, see
“Accessing Specific Bus and Matrix Elements”.
Elements in the array or Signals in the bus (Prompt is specific
to the type of data.)
For bus signals, lists the elements in the associated data store.
The list displays the maximum dimensions for each element, in
parentheses.
For data stores with a bus data type, you can expand the tree to
view the bus elements. For data stores with arrays, you can read
the whole data store, or you can specify one or more elements
of the whole data store.
You can select an element and then use one of the following
approaches:
2-221
Data Store Read
• Click Select>> to display that element (and all its subelements)
in the Selected element(s) list.
• Use the Specify element(s) to select edit box to specify the
bus or matrix elements that you want to select for reading.
Then click Select>>.
To refresh the display to reflect modifications to the bus or matrix
used in the data store, click Refresh.
Specify element(s) to select
Enter a MATLAB expression to define the specific element that
you want to read. For example, for a data store named DSM that
has maximum dimensions of [3,5], you could enter expressions
such as DSM(2, 4) or DSM([1 3], 2) in the edit box and then
click Select>>.
To apply the element selection, click OK.
Selected Element(s)
Displays the elements that you select. The Data Store Read block
icon displays a port for each element that you specify.
To change the order of bus or matrix elements in the list, select
the element in the list and click Up or Down. Changing the
order of the elements in the list changes the order of the ports. To
remove an element, click Remove.
Characteristics Sample Time
See Also
Specified in the Sample time parameter
Dimensionalized
Yes
Multidimensionalized
Yes
• “Data Stores”
• “Access Data Stores with Simulink Blocks”
• Data Store Memory
2-222
Data Store Read
• Data Store Write
2-223
Data Store Write
Purpose
Write data to data store
Library
Signal Routing
Description
The Data Store Write block copies the value at its input to the named
data store. Each write operation performed by a Data Store Write block
writes over the data store, replacing the previous contents.
The data store to which this block writes is determined by the location
of the Data Store Memory block or signal object that defines the data
store. For more information, see “Data Stores” and Data Store Memory.
The size of the data store is set by the signal object or the Data Store
Memory block that defines and initializes the data store. Each Data
Store Write block that writes to that data store must write the same
amount of data.
More than one Data Store Write block can write to the same data store.
However, if two Data Store Write blocks attempt to write to the same
data store during the same simulation step, results are unpredictable.
Obtaining correct results from data stores requires ensuring that data
store reads and writes occur in the expected order. For details, see
“Order Data Store Access” and “Data Store Diagnostics”.
You can log the values of a local or global data store data variable for all
the steps in a simulation. For details, see “Log Data Stores”.
Data Type
Support
The Data Store Write block accepts a real or complex signal of any
data type that Simulink supports, including fixed-point, bus object,
and enumerated data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
You can use an array of buses with a Data Store Write block. For details
about defining and using an array of buses, see “Combine Buses into
an Array of Buses”.
2-224
Data Store Write
Parameters
and
Dialog
Box
The Parameters pane of the Data Store Write block dialog box appears
as follows:
Data store name
Specifies the name of the data store to which this block writes
data. The adjacent pull-down list lists the names of Data Store
Memory blocks that exist at the same level in the model as
the Data Store Write block or at higher levels. The pulldown
list also includes all Simulink.Signal objects in the base and
model workspaces. To change the name, select a name from the
pull-down list or enter the name directly in the edit field.
When Simulink software compiles the model containing this
block, Simulink software searches the model upwards from this
block’s level for a Data Store Memory block having the specified
data store name. If Simulink does not find such a block, it
searches the model workspace and the MATLAB workspace for
2-225
Data Store Write
a Simulink.Signal object having the same name. See “Symbol
Resolution” for more information about the search path.
If Simulink finds the signal object, it creates a hidden Data Store
Memory block at the model’s root level having the properties
specified by the signal object and an initial value of 0. If Simulink
software finds neither the Data Store Memory block nor the signal
object, it halts the compilation and displays an error.
Data store memory block
This field lists the Data Store Memory block that initialized the
store to which this block writes.
Data store read blocks
This parameter lists all the Data Store Read blocks with the same
data store name as this block that are in the same (sub)system or
in any subsystem below it in the model hierarchy. Double-click
any entry on this list to highlight the block and bring it to the
foreground.
Sample time
Specify the sample time that controls when the block writes to
the data store. A value of -1 indicates that the sample time is
inherited. See “Specify Sample Time” for more information.
The Element Assignment pane of the Data Store Write block dialog
box appears as follows:
2-226
Data Store Write
Use the Element Assignment pane to assign a subset of the bus or
matrix elements defined for writing to the associated data store. The
Data Store Write block icon reflects the elements that you specify. For
details, see “Accessing Specific Bus and Matrix Elements”.
Elements in the array or Signals in the bus (Prompt is specific
to the type of data.)
For bus signals, lists the elements in the associated data store.
The list displays the maximum dimensions for each element, in
parentheses.
For data stores with a bus data type, you can expand the tree to
view the bus elements. For data stores with arrays, you can write
the whole data store, or you can assign one or more elements to
the whole data store.
You can select an element and then use one of the following
approaches:
2-227
Data Store Write
• Click Select>> to display that element (and all its subelements)
in the Assigned element(s) list.
• Use the Specify element(s) to assign edit box to specify the
bus or matrix elements that you want to select for reading.
Then click Select>>.
To refresh the display to reflect modifications to the bus or matrix
used in the data store, click Refresh.
Specify element(s) to assign
Enter a MATLAB expression to define the specific element that
you want to write. For example, for a data store named DSM that
has maximum dimensions of [3,5], you could enter expressions
such as DSM(2, 4) or DSM([1 3], 2) in the edit box. Then click
Select>>.
To apply the element selection, click OK.
Assigned Element(s)
Displays the elements that you selected for assignment. The Data
Store Write block icon displays a port for each element that you
specify.
To change the order of bus or matrix elements in the list, select
the element in the list and click Up or Down. Changing the
order of the elements in the list changes the order of the ports. To
remove an element, click Remove.
Characteristics Sample Time
See Also
Specified in the Sample time parameter
Dimensionalized
Yes
Multidimensionalized
Yes
• “Data Stores”
• “Access Data Stores with Simulink Blocks”
2-228
Data Store Write
• Data Store Memory
• Data Store Read
• “Log Data Stores”
2-229
Data Type Conversion
Purpose
Convert input signal to specified data type
Library
Signal Attributes
Description
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 complex-valued signal. If
the input is real, the output is real. If the input is complex, the output
is complex.
Note This block requires that you specify the data type and scaling for
the conversion. If you want to inherit the data type or scaling from an
input signal, use the Data Type Conversion Inherited block.
The Input and output to have equal parameter controls how the
block handles the input. The possible values are Real World Value
(RWV), which is the default value, and Stored Integer (SI):
• Select Real World Value (RWV) to treat the input as V = SQ + B,
where S is the slope and B is the bias. V is used to produce Q = (V –
B)/S, which is stored in the output.
• Select Stored Integer (SI) to treat the input as a stored integer,
Q. The value of Q is directly used to produce the output. In this
mode, the input and output are identical, except that the input is a
raw integer lacking proper scaling information. Selecting Stored
Integer might be useful in the following cases:
2-230
Data Type Conversion
-
Generating code for a fixed-point processor
The resulting code uses only integers and does not use
floating-point operations.
-
Partitioning your model based on hardware characteristics
For example, part of your model might involve simulating
hardware that produces integers as output.
Note When casting NaN values of type double to boolean, the Data
Type Conversion block casts to boolean true.
Casting Enumerated Signals
Use a Data Type Conversion block to cast enumerated signals as follows.
1 To cast a signal of enumerated type to a signal of any numeric type
The underlying integers of all enumerated values input to the Data
Type Conversion block should be within the range of the numeric
type; otherwise, an error occurs during simulation.
2 To cast a signal of any integer type to a signal of enumerated type
The value input to the Data Type Conversion block should match the
underlying value of an enumerated value; otherwise, an error occurs
during simulation.
You can enable the block’s Saturate on integer overflow
parameter so that Simulink uses the default value of the enumerated
type when the value input to the block does not match the underlying
value of an enumerated value. See “Type Casting for Enumerations”.
You cannot use a Data Type Conversion block in the following cases.
• To cast a non-integer numeric signal to an enumerated signal
2-231
Data Type Conversion
• To cast a complex signal to an enumerated signal, regardless of the
data types of the complex signal’s real and imaginary parts.
See “About Simulink Enumerations” for information on working with
enumerated types.
Data Type
Support
The Data Type Conversion block handles any data type that Simulink
supports, including fixed-point and enumerated data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-232
Data Type Conversion
Parameters
and
Dialog
Box
2-233
Data Type Conversion
Show data type assistant
Display the Data Type Assistant.
Settings
The Data Type Assistant helps you set the Output data type
parameter.
For more information, see “Specify Block Output Data Types”.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-234
Data Type Conversion
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
2-235
Data Type Conversion
Input and output to have equal
Specify which type of input and output should be equal.
Settings
Default: Real World Value (RWV)
Real World Value (RWV)
Specifies the goal of making the Real World Value (RWV) of the
input equal to the Real World Value (RWV) of the output.
Stored Integer (SI)
Specifies the goal of making the Stored Integer (SI) value of
the input equal to the Stored Integer (SI) value of the output.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-236
Data Type Conversion
Integer rounding mode
Specify the rounding mode for fixed-point operations.
Settings
Default: Floor
Ceiling
Rounds both positive and negative numbers toward positive
infinity. Equivalent to the MATLAB ceil function.
Convergent
Rounds number to the nearest representable value. If a tie occurs,
rounds to the nearest even integer. Equivalent to the Fixed-Point
Toolbox™ convergent function.
Floor
Rounds both positive and negative numbers toward negative
infinity. Equivalent to the MATLAB floor function.
Nearest
Rounds number to the nearest representable value. If a tie occurs,
rounds toward positive infinity. Equivalent to the Fixed-Point
Toolbox nearest function.
Round
Rounds number to the nearest representable value. If a tie occurs,
rounds positive numbers toward positive infinity and rounds
negative numbers toward negative infinity. Equivalent to the
Fixed-Point Toolbox round function.
Simplest
Automatically chooses between round toward floor and round
toward zero to generate rounding code that is as efficient as
possible.
Zero
Rounds number toward zero. Equivalent to the MATLAB fix
function.
2-237
Data Type Conversion
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Rounding” in the Simulink Fixed Point
documentation.
2-238
Data Type Conversion
Saturate on integer overflow
Specify whether overflows saturate.
Settings
Default: Off
On
Overflows saturate to either the minimum or maximum value
that the data type can represent.
For example, an overflow associated with a signed 8-bit integer
can saturate to -128 or 127.
Off
Overflows wrap to the appropriate value that is representable
by the data type.
For example, the number 130 does not fit in a signed 8-bit integer
and wraps to -126.
Tips
• Consider selecting this check box when your model has possible
overflow and you want explicit saturation protection in the generated
code.
• Consider clearing this check box when you want to optimize efficiency
of your generated code.
Clearing this check box also helps you avoid overspecifying how
a block handles out-of-range signals. For more information, see
“Checking for Signal Range Errors”.
• When you select this check box, saturation applies to every internal
operation on the block, not just the output or result.
• In general, the code generation process can detect when overflow
is not possible. In this case, the code generator does not produce
saturation code.
2-239
Data Type Conversion
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-240
Data Type Conversion
Sample time (-1 for inherited)
Enter the discrete interval between sample time hits or specify another
appropriate sample time such as continuous or inherited.
Settings
Default: -1
By default, the block inherits its sample time based upon the context of
the block within the model. To set a different sample time, enter a valid
sample time based upon the table in “Types of Sample Time”.
See also “Specify Sample Time” in the online documentation for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-241
Data Type Conversion
Output minimum
Specify the minimum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the minimum value for bus data on the block. Simulink ignores
this setting. Instead, set the minimum values for bus elements of the
bus object specified as the data type. For information on the Minimum
property of a bus element, see Simulink.BusElement.
Simulink uses the minimum to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-242
Data Type Conversion
Output maximum
Specify the maximum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the maximum value for bus data on the block. Simulink ignores this
setting. Instead, set the maximum values for bus elements of the bus
object specified as the data type. For information on the Maximum
property of a bus element, see Simulink.BusElement.
Simulink uses the maximum value to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-243
Data Type Conversion
Output data type
Specify the output data type.
Settings
Default: Inherit:
Inherit:
Inherit via back propagation
Inherit via back propagation
Use data type of the driving block.
double
Output data type is double.
single
Output data type is single.
int8
Output data type is int8.
uint8
Output data type is uint8.
int16
Output data type is int16.
uint16
Output data type is uint16.
int32
Output data type is int32.
uint32
Output data type is uint32.
boolean
Output data type is boolean.
fixdt(1,16,0)
Output data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Output data type is fixed point fixdt(1,16,2^0,0).
2-244
Data Type Conversion
Enum:
<class name>
Use an enumerated data type, for example, Enum:
BasicColors.
<data type expression>
Use a data type object, for example, Simulink.NumericType.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specify Block Output Data Types”.
2-245
Data Type Conversion
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables
Inherit via back propagation.
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
• boolean
Fixed point
Fixed-point data types.
Enumerated
Enumerated data types. Selecting Enumerated enables a second
menu/text box to the right, where you can enter the class name.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
2-246
Data Type Conversion
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-247
Data Type Conversion
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-248
Data Type Conversion
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-249
Data Type Conversion
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-250
Data Type Conversion
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-251
Data Type Conversion
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-252
Data Type Conversion
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
Examples
Real World Values Versus Stored Integers
The following model uses the Data Type Conversion block to explain the
difference between a real-world value and a stored integer. Consider
these two fixed-point block diagrams:
2-253
Data Type Conversion
In the top block diagram, the Data Type Conversion block treats the
input as a real-world value, and maps that value to an 8-bit signed
generalized fixed-point data type with a scaling of 2-2. When the value
is then output from the Data Type Conversion1 block as a real-world
value, the scaling and data type information is retained and the output
value is 001111.00, or 15. When the value is output from the Data
Type Conversion2 block as a stored integer, the scaling and data type
information is not retained and the stored integer is interpreted as
00111100, or 60.
In the bottom block diagram, the Data Type Conversion3 block treats
the input as a stored integer, and the data type and scaling information
2-254
Data Type Conversion
is not applied. When the value is then output from the Data Type
Conversion4 block as a real-world value, the scaling and data type
information is applied to the stored integer, and the output value is
000011.11, or 3.75. When the value is output from the Data Type
Conversion5 block as a stored integer, you get back the original input
value of 15.
Real World Values and Stored Integers in Summations
The following model shows how a summation operation applies to
real-world values and stored integers, and how the generated code
handles scaling information.
Note that the summation operation produces the correct result when
the Data Type Conversion (2 or 5) block outputs a real-world value.
This is because the specified scaling information is applied to the stored
integer value. However, when the Data Type Conversion4 block outputs
2-255
Data Type Conversion
a stored integer value, then the summation operation produces an
unexpected result due to the absence of scaling information.
If you generate code for the above model, then the code captures
the appropriate scaling information. The code for the Sum block is
shown below. The inputs to this block are tagged with the specified
scaling information so that the necessary shifts are performed for the
summation operation.
/* Sum Block: <Root>/Sum
*
* y = u0 + u1
*
* Input0 Data Type: Fixed Point
* Input1 Data Type: Fixed Point
* Output0 Data Type: Fixed Point
*
* Round Mode: Floor
* Saturation Mode: Wrap
*
*/
sum = ((in1) << 3);
sum += ((in2) << 1);
Characteristics Direct Feedthrough
See Also
2-256
S16
S16
S16
2^-2
2^-4
2^-5
Yes
Sample Time
Inherited from driving block
Scalar Expansion
N/A
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Data Type Conversion Inherited
Data Type Conversion Inherited
Purpose
Convert from one data type to another using inherited data type and
scaling
Library
Signal Attributes
Description
The Data Type Conversion Inherited block forces dissimilar data types
to be the same. The first input is used as the reference signal and
the second input is converted to the reference type by inheriting the
data type and scaling information. (See “How to Rotate a Block” in the
Simulink documentation for a description of the port order for various
block orientations.) Either input undergoes scalar expansion such that
the output has the same width as the widest input.
Inheriting the data type and scaling provides these advantages:
• It makes reusing existing models easier.
• It allows you to create new fixed-point models with less effort since
you can avoid the detail of specifying the associated parameters.
Data Type
Support
The Data Type Conversion Inherited block accepts signals of the
following data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
2-257
Data Type Conversion Inherited
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
2-258
Input and Output to have equal
Specify whether the Real World Value (RWV) or the Stored
Integer (SI) of the input and output should be the same. Refer
to Description in the Data Type Conversion block reference page
for more information about these choices.
Data Type Conversion Inherited
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
Saturate to max or min when overflows occur
Select to have overflows saturate to the maximum or minimum
value that the data type can represent. Otherwise, overflows
wrap.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result. In
general, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
Characteristics Direct Feedthrough
See Also
Yes
Data Type Conversion
2-259
Data Type Duplicate
Purpose
Force all inputs to same data type
Library
Signal Attributes
Description
The Data Type Duplicate block forces all inputs to have exactly the
same data type. Other attributes of input signals, such as dimension,
complexity, and sample time, are completely independent.
You can use the Data Type Duplicate block to check for consistency of
data types among blocks. If all signals do not have the same data type,
the block returns an error message.
The Data Type Duplicate block is typically used such that one signal to
the block controls the data type for all other blocks. The other blocks
are set to inherit their data types via back propagation.
The block is also used in a user created library. These library blocks
can be placed in any model, and the data type for all library blocks are
configured according to the usage in the model. To create a library block
with more complex data type rules than duplication, use the Data Type
Propagation block.
Data Type
Support
The Data Type Duplicate block accepts signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-260
Data Type Duplicate
Parameters
and
Dialog
Box
Number of input ports
Specify the number of inputs to this block.
Characteristics Sample Time
See Also
Inherited from the driving block
Scalar Expansion
Yes
States
0
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Data Type Propagation
2-261
Data Type Propagation
Purpose
Set data type and scaling of propagated signal based on information
from reference signals
Library
Signal Attributes
Description
The Data Type Propagation block allows you to control the data
type and scaling of signals in your model. You can use this block in
conjunction with fixed-point blocks that have their Output data type
parameter configured to Inherit: Inherit via back propagation.
The block has three inputs: Ref1 and Ref2 are the reference inputs,
while the Prop input back propagates the data type and scaling
information gathered from the reference inputs. This information is
then passed on to other fixed-point blocks.
The block provides you with many choices for propagating data type
and scaling information. For example, you can:
• Use the number of bits from the Ref1 reference signal, or use the
number of bits from widest reference signal.
• Use the range from the Ref2 reference signal, or use the range of the
reference signal with the greatest range.
• Use a bias of zero, regardless of the biases used by the reference
signals.
• Use the precision of the reference signal with the least precision.
You specify how data type information is propagated with the
Propagated data type parameter list. If the parameter list is
configured as Specify via dialog, then you manually specify the data
type via the Propagated data type edit field. If the parameter list is
configured as Inherit via propagation rule, then you must use the
parameters described in “Parameters and Dialog Box” on page 2-265.
You specify how scaling information is propagated with the Propagated
scaling parameter list. If the parameter list is configured as Specify
via dialog, then you manually specify the scaling via the Propagated
scaling edit field. If the parameter list is configured as Inherit via
2-262
Data Type Propagation
propagation rule, then you must use the parameters described in
“Parameters and Dialog Box” on page 2-265.
After you use the information from the reference signals, you can apply
a second level of adjustments to the data type and scaling by using
individual multiplicative and additive adjustments. This flexibility has
a variety of uses. For example, if you are targeting a DSP, then you
can configure the block so that the number of bits associated with a
MAC (multiply and accumulate) operation is twice as wide as the input
signal, and has a certain number of guard bits added to it.
The Data Type Propagation block also provides a mechanism to force
the computed number of bits to a useful value. For example, if you are
targeting a 16-bit micro, then the target C compiler is likely to support
sizes of only 8 bits, 16 bits, and 32 bits. The block will force these three
choices to be used. For example, suppose the block computes a data type
size of 24 bits. Since 24 bits is not directly usable by the target chip, the
signal is forced up to 32 bits, which is natively supported.
There is also a method for dealing with floating-point reference signals.
This makes it easier to create designs that are easily retargeted from
fixed-point chips to floating-point chips or vice versa.
The Data Type Propagation block allows you to set up libraries of useful
subsystems that will be properly configured based on the connected
signals. Without this data type propagation process, a subsystem
that you use from a library will almost certainly not work as desired
with most integer or fixed-point signals, and manual intervention to
configure the data type and scaling would be required. This block can
eliminate the manual intervention in many situations.
Precedence Rules
The precedence of the dialog box parameters decreases from top to
bottom. Additionally:
• Double-precision reference inputs have precedence over all other
data types.
2-263
Data Type Propagation
• Single-precision reference inputs have precedence over integer and
fixed-point data types.
• Multiplicative adjustments are carried out before additive
adjustments.
• The number of bits is determined before the precision or positive
range is inherited from the reference inputs.
Data Type
Support
The Data Type Propagation block accepts signals of the following data
types:
• Floating-point
• Built-in integer
• Fixed-point
• Boolean
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-264
Data Type Propagation
Parameters
and
Dialog
Box
The Propagated type pane of the Data Type Propagation block dialog
box appears as follows:
2-265
Data Type Propagation
If any reference input is double, output is
Specify single or double. This parameter makes it easier to
create designs that are easily retargeted from fixed-point chips to
floating-point chips or vice versa.
This parameter is visible only when you set Propagated data
type to Inherit via propagation rule.
If any reference input is single, output is
Specify single or double. This parameter makes it easier to
create designs that are easily retargeted from fixed-point chips to
floating-point chips or visa versa.
This parameter is visible only when you set Propagated data
type to Inherit via propagation rule.
Is-Signed
Specify the sign of Prop as one of the following values:
Parameter
Value
Description
IsSigned1
Prop is a signed data type if Ref1 is a signed
data type.
IsSigned2
Prop is a signed data type if Ref2 is a signed
data type.
IsSigned1 or
IsSigned2
Prop is a signed data type if either Ref1 or
Ref2 are signed data types.
TRUE
Ref1 and Ref2 are ignored, and Prop is always
a signed data type.
FALSE
Ref1 and Ref2 are ignored, and Prop is always
an unsigned data type.
For example, if the Ref1 signal is ufix(16), the Ref2 signal
is sfix(16), and the Is-Signed parameter is IsSigned1 or
IsSigned2, then Prop is forced to be a signed data type.
2-266
Data Type Propagation
This parameter is visible only when you set Propagated data
type to Inherit via propagation rule.
Number-of-bits: Base
Specify the number of bits used by Prop for the base data type
as one of the following values:
Parameter Value
Description
NumBits1
The number of bits for Prop is given by the
number of bits for Ref1.
NumBits2
The number of bits for Prop is given by the
number of bits for Ref2.
max([NumBits1
NumBits2])
The number of bits for Prop is given by
the reference signal with largest number
of bits.
min([NumBits1
NumBits2])
The number of bits for Prop is given by
the reference signal with smallest number
of bits.
NumBits1+NumBits2 The number of bits for Prop is given by the
sum of the reference signal bits.
For more information about the base data type, refer to
Targeting an Embedded Processor in the Simulink Fixed Point
documentation.
This parameter is visible only when you set Propagated data
type to Inherit via propagation rule.
Number-of-bits: Multiplicative adjustment
Specify the number of bits used by Prop by including a
multiplicative adjustment. For example, suppose you want to
guarantee that the number of bits associated with a multiply and
accumulate (MAC) operation is twice as wide as the input signal.
To do this, you configure this parameter to the value 2.
2-267
Data Type Propagation
This parameter is visible only when you set Propagated data
type to Inherit via propagation rule.
Number-of-bits: Additive adjustment
Specify the number of bits used by Prop by including an additive
adjustment. For example, if you are performing multiple additions
during a MAC operation, the result might overflow. To prevent
overflow, you can associate guard bits with the propagated data
type. To associate four guard bits, you specify the value 4.
This parameter is visible only when you set Propagated data
type to Inherit via propagation rule.
Number-of-bits: Allowable final values
Force the computed number of bits used by Prop to a useful value.
For example, if you are targeting a processor that supports only 8,
16, and 32 bits, then you configure this parameter to [8,16,32].
The block always propagates the smallest specified value that
fits. If you want to allow all fixed-point data types, you would
specify the value 1:128.
This parameter is visible only when you set Propagated data
type to Inherit via propagation rule.
The Propagated scaling pane of the Data Type Propagation block
dialog box appears as follows:
2-268
Data Type Propagation
2-269
Data Type Propagation
Propagated scaling
Use the parameter list to propagate the scaling via the dialog box,
inherit the scaling from the reference signals, or calculate the
scaling to obtain best precision.
Propagated scaling (Slope or [Slope Bias])
Specify the scaling as either a slope or a slope and bias.
This parameter is visible only when you set Propagated scaling
to Specify via dialog.
Values used to determine best precision scaling
Specify any values to be used to constrain the precision, such as
the upper and lower limits on the propagated input. Based on
the data type, the scaling will automatically be selected such
that these values can be represented with no overflow error and
minimum quantization error.
This parameter is visible only when you set Propagated scaling
to Obtain via best precision.
Slope: Base
Specify the slope used by Prop for the base data type as one of
the following values:
2-270
Parameter Value
Description
Slope1
The slope of Prop is given by the slope
of Ref1.
Slope2
The slope of Prop is given by the slope
of Ref2.
max([Slope1
Slope2])
The slope of Prop is given by the
maximum slope of the reference
signals.
min([Slope1
Slope2])
The slope of Prop is given by the
minimum slope of the reference
signals.
Data Type Propagation
Parameter Value
Description
Slope1*Slope2
The slope of Prop is given by the
product of the reference signal slopes.
Slope1/Slope2
The slope of Prop is given by the ratio
of the Ref1 slope to the Ref2 slope.
PosRange1
The range of Prop is given by the range
of Ref1.
PosRange2
The range of Prop is given by the range
of Ref2.
max([PosRange1
PosRange2])
The range of Prop is given by the
maximum range of the reference
signals.
min([PosRange1
PosRange2])
The range of Prop is given by the
minimum range of the reference
signals.
PosRange1*PosRange2
The range of Prop is given by the
product of the reference signal ranges.
PosRange1/PosRange2
The range of Prop is given by the ratio
of the Ref1 range to the Ref2 range.
You control the precision of Prop with Slope1 and Slope2, and
you control the range of Prop with PosRange1 and PosRange2.
Additionally, PosRange1 and PosRange2 are one bit higher than
the maximum positive range of the associated reference signal.
This parameter is visible only when you set Propagated scaling
to Inherit via propagation rule.
Slope: Multiplicative adjustment
Specify the slope used by Prop by including a multiplicative
adjustment. For example, if you want 3 bits of additional precision
(with a corresponding decrease in range), the multiplicative
adjustment is 2^-3.
2-271
Data Type Propagation
This parameter is visible only when you set Propagated scaling
to Inherit via propagation rule.
Slope: Additive adjustment
Specify the slope used by Prop by including an additive
adjustment. An additive slope adjustment is often not needed.
The most likely use is to set the multiplicative adjustment to
0, and set the additive adjustment to force the final slope to a
specified value.
This parameter is visible only when you set Propagated scaling
to Inherit via propagation rule.
Bias: Base
Specify the bias used by Prop for the base data type. The
parameter values are described as follows:
2-272
Parameter
Value
Description
Bias1
The bias of Prop is given by the bias of Ref1.
Bias2
The bias of Prop is given by the bias of Ref2.
max([Bias1
Bias2])
The bias of Prop is given by the maximum
bias of the reference signals.
min([Bias1
Bias2])
The bias of Prop is given by the minimum
bias of the reference signals.
Bias1*Bias2
The bias of Prop is given by the product of
the reference signal biases.
Bias1/Bias2
The bias of Prop is given by the ratio of the
Ref1 bias to the Ref2 bias.
Bias1+Bias2
The bias of Prop is given by the sum of the
reference biases.
Bias1-Bias2
The bias of Prop is given by the difference of
the reference biases.
Data Type Propagation
This parameter is visible only when you set Propagated scaling
to Inherit via propagation rule.
Bias: Multiplicative adjustment
Specify the bias used by Prop by including a multiplicative
adjustment.
This parameter is visible only when you set Propagated scaling
to Inherit via propagation rule.
Bias: Additive adjustment
Specify the bias used by Prop by including an additive adjustment.
If you want to guarantee that the bias associated with Prop is
zero, you should configure both the multiplicative adjustment and
the additive adjustment to 0.
This parameter is visible only when you set Propagated scaling
to Inherit via propagation rule.
Characteristics Direct Feedthrough
See Also
Yes
Scalar Expansion
Yes
Zero-Crossing Detection
No
Data Type Duplicate
2-273
Data Type Scaling Strip
Purpose
Remove scaling and map to built in integer
Library
Signal Attributes
Description
The Scaling Strip block strips the scaling off a fixed point signal. It
maps the input data type to the smallest built in data type that has
enough data bits to hold the input. The stored integer value of the input
is the value of the output. The output always has nominal scaling (slope
= 1.0 and bias = 0.0), so the output does not make a distinction between
real world value and stored integer value.
Data Type
Support
The Data Type Scaling Strip block accepts signals of any numeric data
type that Simulink supports, including fixed-point data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-274
Data Type Scaling Strip
Parameters
and
Dialog
Box
Characteristics Direct Feedthrough
Yes
Scalar Expansion
Yes
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
2-275
Dead Zone
Purpose
Provide region of zero output
Library
Discontinuities
Description
The Dead Zone block generates zero output within a specified region,
called its dead zone. You specify the lower limit (LL) and upper limit
(UL) of the dead zone as the Start of dead zone and End of dead
zone parameters, respectively. The block output depends on the input
(U) and the values for the lower and upper limits:
Data Type
Support
Input
Output
U >= LL and U <= UL
Zero
U > UL
U – UL
U < LL
U – LL
The Dead Zone block accepts and outputs real signals of the following
data types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-276
Dead Zone
Parameters
and
Dialog
Box
Start of dead zone
Specify the lower limit of the dead zone. The default is -0.5.
End of dead zone
Specify the upper limit of the dead zone. The default is 0.5.
2-277
Dead Zone
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow,
and you want explicit
saturation protection
in the generated code.
Overflows saturate to
either the minimum
or maximum value
that the data type can
represent.
An overflow associated
with a signed 8-bit
integer can saturate to
–128 or 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
–126.
You want to avoid
overspecifying how
a block handles
out-of-range signals.
For more information,
see “Checking for
Signal Range Errors”.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result.
Usually, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
Treat as gain when linearizing
The linearization commands in Simulink software treat this
block as a gain in state space. Select this check box to cause the
commands to treat the gain as 1; otherwise, the commands treat
the gain as 0.
Enable zero-crossing detection
Select to enable zero-crossing detection. For more information,
see “Zero-Crossing Detection” in the Simulink documentation.
2-278
Dead Zone
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See Specifying Sample Time in
the Simulink documentation.
Examples
The following model uses lower and upper limits of -0.5 and 0.5, with a
sine wave as input.
This plot shows the effect of the Dead Zone block on the sine wave.
When the input sine wave is between –0.5 and 0.5, the output is zero.
Characteristics Direct Feedthrough
Yes
Sample Time
Specified in the Sample time parameter
Scalar Expansion
Yes, of parameters
2-279
Dead Zone
See Also
2-280
Dimensionalized
Yes
Zero-Crossing Detection
Yes, if enabled
Dead Zone Dynamic
Dead Zone Dynamic
Purpose
Set inputs within bounds to zero
Library
Discontinuities
Description
The Dead Zone Dynamic block dynamically bounds the range of the
input signal, providing a region of zero output. The bounds change
according to the upper and lower limit input signals where
• The input within the bounds is set to zero.
• The input below the lower limit is shifted down by the lower limit.
• The input above the upper limit is shifted down by the upper limit.
The input for the upper limit is the up port, and the input for the lower
limit is the lo port.
Data Type
Support
The Dead Zone Dynamic block accepts signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-281
Dead Zone Dynamic
Parameters
and
Dialog
Box
Characteristics Direct Feedthrough
Scalar Expansion
See Also
2-282
Dead Zone
Yes
Yes
Decrement Real World
Purpose
Decrease real world value of signal by one
Library
Additional Math & Discrete / Additional Math: Increment - Decrement
Description
The Decrement Real World block decreases the real world value of the
signal by one. Overflows always wrap.
Data Type
Support
The Decrement Real World block accepts signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
2-283
Decrement Real World
Characteristics Direct Feedthrough
See Also
2-284
Yes
Scalar Expansion
No
Multidimensionalized
No
Zero-Crossing Detection
No
Decrement Stored Integer, Decrement Time To Zero, Decrement To
Zero, Increment Real World
Decrement Stored Integer
Purpose
Decrease stored integer value of signal by one
Library
Additional Math & Discrete / Additional Math: Increment - Decrement
Description
The Decrement Stored Integer block decreases the stored integer value
of a signal by one.
Floating-point signals also decrease by one, and overflows always wrap.
Data Type
Support
The Decrement Stored Integer block accepts signals of the following
data types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
2-285
Decrement Stored Integer
Characteristics Direct Feedthrough
See Also
2-286
Yes
Scalar Expansion
No
Multidimensionalized
No
Zero-Crossing Detection
No
Decrement Real World, Decrement Time To Zero, Decrement To Zero,
Increment Stored Integer
Decrement Time To Zero
Purpose
Decrease real-world value of signal by sample time, but only to zero
Library
Additional Math & Discrete / Additional Math: Increment - Decrement
Description
The Decrement Time To Zero block decreases the real-world value of
the signal by the sample time, Ts. The output never goes below zero.
This block works only with fixed sample rates and does not work inside
a triggered subsystem.
Data Type
Support
The Decrement Time To Zero block accepts signals of the following
data types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-287
Decrement Time To Zero
Parameters
and
Dialog
Box
Characteristics Direct Feedthrough
See Also
2-288
Yes
Scalar Expansion
No
Multidimensionalized
No
Zero-Crossing Detection
No
Decrement Real World, Decrement Stored Integer, Decrement To Zero
Decrement To Zero
Purpose
Decrease real-world value of signal by one, but only to zero
Library
Additional Math & Discrete / Additional Math: Increment - Decrement
Description
The Decrement To Zero block decreases the real-world value of the
signal by one. The output never goes below zero.
Data Type
Support
The Decrement To Zero block accepts signals of the following data types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-289
Decrement To Zero
Parameters
and
Dialog
Box
Characteristics Direct Feedthrough
See Also
2-290
Yes
Scalar Expansion
No
Multidimensionalized
No
Zero-Crossing Detection
No
Decrement Real World, Decrement Stored Integer, Decrement Time
To Zero
Delay
Purpose
Delay input signal by fixed or variable sample periods
Library
Discrete
Description
Supported Block Operations
The Delay block supports:
• Variable delay length
• Specification of the initial condition from an input port
• Resetting the state to the initial condition with an external reset
signal
• State storage
• Using a circular buffer instead of an array buffer for state storage
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. The initial block output depends
on the Initial condition parameter, which you specify on the dialog
box, or an initial condition that a signal supplies to the x0 input port.
Whether or not the block output resets to the initial condition depends
on the External reset parameter, which you specify on the dialog box.
The following dimensional requirements apply:
• Delay length and External reset must be scalar.
• Initial condition can be scalar or nonscalar.
• For frame-based processing, signal dimensions of the data input port
u cannot be larger than two.
2-291
Delay
Block Icon Appearance
The icon changes depending on the number of block inputs.
Icon
Number of Inputs
One:
• Input signal to delay, u
Two:
• Input signal to delay, u
• Delay length, d
Three:
• Input signal to delay, u
• Delay length, d
• External reset
Four:
• Input signal to delay, u
• Delay length, d
• External reset
• Initial condition, x0
2-292
Delay
Data Type
Support
The block supports input signals of the following data types:
Input Signal
Supported Data Types
u
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
d
• Floating point
• Fixed-point integer
x0
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
When u is Boolean, x0 must be Boolean. When u uses an enumerated
type, x0 must use the same enumerated type. Otherwise, x0 can use
a floating-point, built-in integer, or fixed-point data type that fits in
the data type of u. For example, when u uses int32, x0 can use int8
but not double.
The data type of the output signal is the same as the input signal u.
When you specify Delay length and Initial condition on the dialog
box, you can use the following data types for those parameters:
2-293
Delay
Parameter
Supported Data Types
Delay length
• Floating point
• Fixed-point integer
Initial condition
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-294
Delay
Parameters
and
Dialog
Box
The Main pane of the Delay block dialog box appears as follows:
Delay length
Specify whether to enter the delay length directly on the dialog
box (fixed delay) or to inherit the delay from an input port
(variable delay).
• If you set Source to Dialog, enter the delay length in the edit
field under Value.
2-295
Delay
• If you set Source to Input port, verify that an upstream
signal supplies a delay length for the d input port. You can also
specify an Upper limit for the delay length.
The scalar delay length (from the dialog parameter or an input
port) must be a real, positive integer.
Initial condition
Specify whether to enter the initial condition directly on the dialog
box or to inherit the initial condition from an input port.
• If you set Source to Dialog, enter the initial condition in the
edit field under Value.
• If you set Source to Input port, verify that an upstream
signal supplies an initial condition for the x0 input port.
Simulink converts offline the data type of Initial condition
to the data type of the input signal u using a round-to-nearest
operation and saturation.
Note When State name must resolve to Simulink signal
object is selected on the State Attributes pane, the block copies
the initial value of the signal object to the Initial condition
parameter. However, when the source for Initial condition is
Input port, the block ignores the initial value of the signal object.
External reset
Specify the trigger event to use to reset the states to the initial
conditions.
2-296
Reset Mode
Behavior
None
No reset.
Rising
Reset on a rising edge.
Falling
Reset on a falling edge.
Delay
Reset Mode
Behavior
Either
Reset on either a rising or
falling edge.
Level
Reset in either of these cases:
• when there is a nonzero at
the current time step
• when the time step value
changes from nonzero at the
previous time step to zero at
the current time step
Level hold
Reset when nonzero at the
current time step.
The reset signal must be scalar.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
2-297
Delay
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
Yes
Inherited
Yes
Yes
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
Use circular buffer for state
Select to use a circular buffer for storing the state in simulation
and code generation. Otherwise, an array buffer stores the state.
2-298
Delay
Using a circular buffer can improve execution speed when the
delay length is large. For an array buffer, the number of copy
operations increases as the delay length goes up. For a circular
buffer, the number of copy operations is constant for increasing
delay length.
If one of the following conditions is true, an array buffer always
stores the state because a circular buffer does not improve
execution speed:
• For sample-based signals, the delay length is 1.
• For frame-based signals, the delay length is no larger than the
frame size.
Prevent direct feedthrough by increasing delay length to lower
limit
Select to increase the delay length from zero to the lower limit for
the Input processing mode:
• For sample-based signals, increase the minimum delay length
to 1.
• For frame-based signals, increase the minimum delay length to
the frame length.
Selecting this check box prevents direct feedthrough from the
input port, u, to the output port. However, this check box cannot
prevent direct feedthrough from the initial condition port, x0,
to the output port.
This check box is available when you set Delay length: Source
to Input port.
Remove protection against out-of-range delay length in
generated code
Select to remove code that checks for out-of-range delay length.
2-299
Delay
Check Box
Result
When to Use
Selected
Generated code
does not include
conditional
statements to check
for out-of-range
delay length.
For code efficiency
Cleared
Generated code
includes conditional
statements to check
for out-of-range
delay length.
For safety-critical
applications
This check box is available when you set Delay length: Source
to Input port.
Diagnostic for out-of-range delay length
Specify whether to produce a warning or error when the input d
is less than the lower limit or greater than the Delay length:
Upper limit. The lower limit depends on the setting for Prevent
direct feedthrough by increasing delay length to lower
limit.
• If the check box is cleared, the lower limit is zero.
• If the check box is selected, the lower limit is 1 for sample-based
signals and frame length for frame-based signals.
Options for the diagnostic include:
• None — No warning or error appears.
• Warning — Display a warning in the MATLAB Command
Window and continue the simulation.
• Error — Stop the simulation and display an error in the
Simulation Diagnostics Viewer.
2-300
Delay
This parameter is available when you set Delay length: Source
to Input port.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. This block supports discrete
sample time, but not continuous sample time.
As described in “Specify Sample Time”, you can specify a discrete
sample time as [Tsampling, Toffset], where Tsampling is the
sampling period and Toffset is the initial time offset. If Tstart
is the simulation start time and n is the delay length, the Delay
block output is as follows.
Simulation Time Range
Block
Output
(Tstart) to (Tstart + Toffset)
Zero
(Tstart + Toffset) to (Tstart + Toffset +
n * Tsampling)
Initial
condition
After (Tstart + Toffset + n * Tsampling)
Input
signal
If the Delay block inherits or specifies a nonzero value for
Toffset, the Delay block outputs zero at Tstart. Otherwise, the
Delay block outputs the initial condition at Tstart.
The State Attributes pane of the Delay block dialog box appears as
follows:
2-301
Delay
State name
Use this parameter to assign a unique name to the block state.
The default is ' '. When this field is blank, no name is assigned.
When using this parameter, remember these considerations:
• A valid identifier starts with an alphabetic or underscore
character, followed by alphanumeric or underscore characters.
• The state name applies only to the selected block.
2-302
Delay
This parameter enables State name must resolve to Simulink
signal object when you click Apply.
For more information, see “States” in the Simulink Coder
documentation.
State name must resolve to Simulink signal object
Select this check box to require that the state name resolve to a
Simulink signal object. This check box is cleared by default.
State name enables this parameter.
Selecting this check box disables Code generation storage
class.
Package
Select a package that defines the custom storage class you want
to apply. If you have defined any packages of your own, click
Refresh. This action adds all user-defined packages on your
search path to the package list.
Code generation storage class
From the list, select a state storage class.
Auto
Auto is the storage class to use for states that do not need
to interface to external code.
ExportedGlobal
The state is stored in a global variable.
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
State name enables this parameter.
2-303
Delay
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage
type qualifier.
Code generation storage type qualifier
Specify a Simulink Coder storage type qualifier. The default is '
'. When this field is blank, no qualifier is assigned.
The Simulink Coder product does not check this string for errors.
Thus, whatever value you enter appears automatically in the
variable declaration.
Setting Code generation storage class to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables this
parameter.
Variable-Size
Support
The Delay block provides the following support for variable-size signals:
• The data input port u accepts variable-size signals. The other input
ports do not accept variable-size signals.
• The output port has the same signal dimensions as the data input
port u for variable-size inputs.
The rules that apply to variable-size signals depend on the input
processing mode of the Delay block.
2-304
Input Processing
Mode
Rules for Variable-Size Signal Support
Elements as
channels (sample
based)
• The signal dimensions change only during
state reset when the block is enabled.
Columns as
channels (frame
based)
• No support
• The initial condition must be scalar.
Delay
Input Processing
Mode
Rules for Variable-Size Signal Support
Inherited
• The signal dimensions change only during
state reset when the block is enabled.
(where input is
a sample-based
signal)
Inherited
(where input is a
frame-based signal)
• The initial condition must be scalar.
• The channel size changes only during state
reset when the block is enabled.
• The initial condition must be scalar.
• The frame size must be constant.
Bus
Support
The Delay block provides the following support for bus signals:
• The data input port u accepts virtual and nonvirtual bus signals. The
other input ports do not accept bus signals.
• The output port has the same bus type as the data input port u for
bus inputs.
• Buses work with:
-
Sample-based and frame-based processing
Fixed and variable delay length
Array and circular buffers
To use a bus signal as the input to a Delay block, you must specify the
initial condition on the dialog box. In other words, the initial condition
cannot come from the input port x0. Support for virtual and nonvirtual
buses depends on the initial condition that you specify and whether the
State name parameter is empty or not.
2-305
Delay
Initial Condition
Examples
State Name
Empty
Not Empty
Zero
Virtual and
nonvirtual bus
support
Nonvirtual bus
support only
Nonzero scalar
Virtual and
nonvirtual bus
support
No bus support
Nonscalar
No bus support
No bus support
Structure
Virtual and
nonvirtual bus
support
Nonvirtual bus
support only
Partial structure
Virtual and
nonvirtual bus
support
Nonvirtual bus
support only
Variable-Size Signals for Sample-Based Processing
This model shows how the Delay block supports variable-size signals for
sample-based processing.
2-306
Delay
The Switch block controls whether the input signal to the enabled
subsystem is a 3-by-3 or 3-by-2 matrix. The Delay block appears inside
the enabled subsystem.
The model follows the rules for variable-size signals when the Delay
block uses sample-based processing.
2-307
Delay
Rule
How the Model Follows the Rule
The signal dimensions
change only during state
reset when the block is
enabled.
The Enable block sets Propagate
sizes of variable-size signals to
Only when enabling.
The initial condition must be
scalar.
The Delay block sets Initial
condition to 0.0, a scalar value.
Bus Signals for Frame-Based Processing
This model shows how the Delay block supports bus signals for
frame-based processing.
Each Constant block supplies an input signal to the Bus Creator block,
which outputs a two-dimensional bus signal. After the Delay block
delays the bus signal by three sample periods, the Bus Selector block
separates the bus back into the two original signals.
The model follows the rules for bus signals when the Delay block uses
frame-based processing.
2-308
Delay
Rule
How the Model Follows the Rule
For the initial condition, set
the value on the dialog box.
The Delay block sets Initial
condition to 0, a scalar value.
For frame-based processing,
signal dimensions of the data
input port u cannot be larger
than two. (This rule applies
to all inputs for the port u,
not just bus signals.)
The bus input to the Delay block has
two dimensions.
Characteristics Direct Feedthrough
See Also
Yes, when you clear Prevent
direct feedthrough by
increasing delay length
to lower limit
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes, of the input u when Initial
condition is nonscalar and
sample-based processing applies
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
• Resettable Delay
• Variable Integer Delay
2-309
Demux
Purpose
Extract and output elements of vector signal
Library
Signal Routing
Description
The Demux block extracts the components of an input signal and
outputs the components as separate signals. The output signals are
ordered from top to bottom output port. See “How to Rotate a Block”
for a description of the port order for various block orientations. To
avoid adding clutter to a model, Simulink hides the name of a Demux
block when you copy it from the Simulink library to a model. See “Mux
Signals” for information about creating and decomposing vectors.
The Number of outputs parameter allows you to specify the number
and, optionally, the dimensionality of each output port. If you do not
specify the dimensionality of the outputs, the block determines the
dimensionality of the outputs for you.
The Demux block operates in either vector mode or bus selection mode,
depending on whether you selected the Bus selection mode parameter.
The two modes differ in the types of signals they accept. Vector mode
accepts only a vector-like signal, that is, either a scalar (one-element
array), vector (1-D array), or a column or row vector (one row or one
column 2-D array). Bus selection mode accepts only a bus signal.
Note MathWorks discourages enabling Bus selection mode and
using a Demux block to extract elements of a bus signal. Muxes and
buses should not be intermixed in new models. See “Avoid Mux/Bus
Mixtures” for more information.
The Number of outputs parameter determines the number and
dimensionality of the block outputs, depending on the mode in which
the block operates.
Specifying the Number of Outputs in Vector Mode
In vector mode, the value of the parameter can be a scalar specifying
the number of outputs or a vector whose elements specify the widths of
2-310
Demux
the block’s output ports. The block determines the size of its outputs
from the size of the input signal and the value of the Number of
outputs parameter.
The following table summarizes how the block determines the outputs
for an input vector of width n.
Parameter Value
Block outputs...
Comments
p = n
p scalar signals
For example, if the input is
a three-element vector and
you specify three outputs,
the block outputs three
scalar signals.
p > n
Error
p < n
p vector signals each having
n/p elements
If the input is a six-element
vector and you specify three
outputs, the block outputs
three two-element vectors.
m vector signals each having
(n/p)+1 elements and p-m
signals having n/p elements
If the input is a five-element
vector and you specify
three outputs, the block
outputs two two-element
vector signals and one scalar
signal.
m vector signals having
widths p1, p2, ... pm
If the input is a five-element
vector and you specify [3,
2] as the output, the block
outputs three of the input
elements on one port and the
other two elements on the
other port.
n mod p = 0
p < n
n mod p = m
[p1 p2 ...
pm ]
p1+p2+...+pm=n
pi > 0
2-311
Demux
Parameter Value
Block outputs...
Comments
[p1 p2 ...
m vector signals
If pi is greater than zero,
the corresponding output
has width pi. If pi is -1, the
width of the corresponding
output is dynamically sized.
pm ]
p1+p2+...+pm=n
some or all
pi = -1
[p1 p2 ...
pm ]
Error
p1+p2+...+pm!=n
pi = > 0
Note that you can specify the number of outputs as fewer than the
number of input elements, in which case the block distributes the
elements as evenly as possible over the outputs as illustrated in the
following example:
You can use –1 in a vector expression to indicate that the block should
dynamically size the corresponding port. For example, the expression
[-1, 3 -1] causes the block to output three signals where the second
signal always has three elements. The sizes of the first and third
signals depend on the size of the input signal.
If a vector expression comprises positive values and –1 values, the block
assigns as many elements as needed to the ports with positive values
2-312
Demux
and distributes the remain elements as evenly as possible over the ports
with –1 values. For example, suppose that the block input is seven
elements wide and you specify the output as [-1, 3 -1]. In this case,
the block outputs two elements on the first port, three elements on the
second, and two elements on the third.
Specifying the Number of Outputs in Bus Selection Mode
In bus selection mode, the value of the Number of outputs parameter
can be a:
• Scalar specifying the number of output ports
The specified value must equal the number of input signals. For
example, if the input bus comprises two signals and the value of this
parameter is a scalar, the value must equal 2.
2-313
Demux
• Vector each of whose elements specifies the number of signals to
output on the corresponding port
For example, if the input bus contains five signals, you can specify
the output as [3, 2], in which case the block outputs three of the
input signals on one port and the other two signals on a second port.
• Cell array each of whose elements is a cell array of vectors specifying
the dimensions of the signals output by the corresponding port
The cell array format constrains the Demux block to accept only signals
of specified dimensions. For example, the cell array {{[2 2], 3} {1}}
tells the block to accept only a bus signal comprising a 2-by-2 matrix,
a three-element vector, and a scalar signal. You can use the value –1
in a cell array expression to let the block determine the dimensionality
of a particular output based on the input. For example, the following
diagram uses the cell array expression {{ 1}, { 1, 1}} to specify the
output of the leftmost Demux block.
2-314
Demux
In bus selection mode, if you specify the dimensionality of an output
port (that is, specify any value other than –1), the corresponding input
element must match the specified dimensionality.
Note MathWorks discourages enabling Bus selection mode and
using a Demux block to extract elements of a bus signal. Muxes and
buses should not be intermixed in new models. See “Avoid Mux/Bus
Mixtures” for more information.
Data Type
Support
The Demux block accepts and outputs complex or real signals of any
data type that Simulink supports, including fixed-point and enumerated
data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-315
Demux
Parameters
and
Dialog
Box
2-316
Demux
Number of outputs
Specify the number and dimensions of outputs.
Settings
Default: 2
This block interprets this parameter depending on the Bus selection
mode parameter. See the block description for more information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See the Demux block reference page for more information.
2-317
Demux
Display option
Select options to display the Demux block. The options are
Settings
Default: bar
bar
Display the icon as a solid bar of the block’s foreground color.
none
Display the icon as a box containing the block’s type name.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See the Demux block reference page for more information.
2-318
Demux
Bus selection mode
Enable bus selection mode.
Settings
Default: Off
On
Enable bus selection mode.
Off
Disable bus selection mode.
Tips
MathWorks discourages enabling Bus selection mode and using
a Demux block to extract elements of a bus signal. Muxes and buses
should not be intermixed in new models. See “Avoid Mux/Bus Mixtures”
for more information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Characteristics Virtual
Yes
For more information, see “Virtual
Blocks” in the Simulink documentation.
See Also
Mux
2-319
Derivative
Purpose
Output time derivative of input
Library
Continuous
Description
The Derivative block approximates the derivative of the input signal u
with respect to the simulation time t. You obtain the approximation of
du
,
dt
by computing a numerical difference u t , where u is the change in
input value and t is the change in time since the previous simulation
(major) time step.
This block accepts one input and generates one output. The initial
output for the block is zero.
The precise relationship between the input and output of this block is:
y(t) 
u u(t)  u(Tprevious )

t  Tprevious ,
t
t  Tprevious
where t is the current simulation time and Tprevious is the time of the
last output time of the simulation. The latter is the same as the time of
the last major time step.
The Derivative block output might be very sensitive to the dynamics
of the entire model. The accuracy of the output signal depends on the
size of the time steps taken in the simulation. Smaller steps allow a
smoother and more accurate output curve from this block. However,
unlike with blocks that have continuous states, the solver does not take
smaller steps when the input to this block changes rapidly. Depending
on the dynamics of the driving signal and model, the output signal of
this block might contain unexpected fluctuations. These fluctuations
are primarily due to the driving signal output and solver step size.
2-320
Derivative
Because of these sensitivities, structure your models to use integrators
(such as Integrator blocks) instead of Derivative blocks. Integrator
blocks have states that allow solvers to adjust step size and improve
accuracy of the simulation. See “Circuit Model” for an example of
choosing the best-form mathematical model to avoid using Derivative
blocks in your models,
If you must use the Derivative block with a variable step solver, set the
solver maximum step size settings to a value such that the Derivative
block can generate answers with adequate accuracy. To determine this
value, you might need to repeatedly run the simulation using different
solver settings.
When the input to this block is a discrete signal, the continuous
derivative of the input exhibits an impulse when the value of the input
changes. Otherwise, it is 0. Alternatively, you can define the discrete
derivative of a discrete signal using the difference of the last two values
of the signal, as follows:
y(k) =
1
(u(k) − u(k − 1))
Δt
Taking the z-transform of this equation results in:
Y ( z) 1 − z−1 z − 1
=
=
.
Δt ⋅ z
Δt
u( z)
The Discrete Derivative block models this behavior. Use this block
instead of the Derivative bock to approximate the discrete-time
derivative of a discrete signal.
Improved Linearization with Transfer Fcn Blocks
The Laplace domain transfer function for the operation of differentiation
is:
Y (s)
X (s)
s
2-321
Derivative
This equation is not a proper transfer function, nor does it have a
state-space representation. As such, the Simulink software linearizes
this block as an effective gain of 0 unless you explicitly specify that a
proper first-order transfer function should be used to approximate the
linear behavior of this block (see “Coefficient c in the transfer function
approximation s/(c*s + 1) used for linearization” on page 2-324).
To improve linearization, you can also try to incorporate the derivative
term in other blocks. For example, if you have a Derivative block in
series with a Transfer Fcn block, try using a single Transfer Fcn block
of the form
s
.
s+ a
For example, you can replace the first set of blocks in this figure with
the blocks below them.
Data Type
Support
2-322
The Derivative block accepts and outputs a real signal of type double.
For more information, see “Data Types Supported by Simulink”.
Derivative
Parameters
and
Dialog
Box
2-323
Derivative
Coefficient c in the transfer function approximation s/(c*s +
1) used for linearization
Specify the time constant c to approximate the linearization of your
system.
Settings
Default: inf
• The exact linearization of the Derivative block is difficult, because
the dynamic equation for the block is y = u , which you cannot
represent as a state-space system. However, you can approximate the
linearization by adding a pole to the Derivative to create a transfer
function s / (c  s  1). The addition of a pole filters the signal before
differentiating it, which removes the effect of noise.
• The default value inf corresponds to a linearization of 0.
Tips
• A best practice is to change the value of c to f1 , where fb is the break
b
frequency for the filter.
• Coefficient c in the transfer function approximation s/(c*s+1)
used for linearization must be a finite positive value. This value
must be nonzero.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Characteristics Direct Feedthrough
2-324
Yes
Sample Time
Continuous
Scalar Expansion
N/A
Dimensionalized
Yes
Zero-Crossing Detection
No
Derivative
See Also
Discrete Derivative
2-325
Detect Change
Purpose
Detect change in signal value
Library
Logic and Bit Operations
Description
The Detect Change block determines if an input does not equal its
previous value.
• The output is true (equal to 1) when the input signal does not equal
its previous value.
• The output is false (equal to 0) when the input signal equals its
previous value.
Data Type
Support
The Detect Change block accepts signals of the following data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-326
Detect Change
Parameters
and
Dialog
Box
Initial condition
Set the initial condition for the previous input U/z.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
2-327
Detect Change
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
2-328
Yes
Inherited
Yes
Yes
Detect Change
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
Output data type
Set the output data type to boolean or uint8.
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes
Detect Decrease, Detect Fall Negative, Detect Fall Nonpositive, Detect
Increase, Detect Rise Nonnegative, Detect Rise Positive
2-329
Detect Decrease
Purpose
Detect decrease in signal value
Library
Logic and Bit Operations
Description
The Detect Decrease block determines if an input is strictly less than
its previous value.
• The output is true (equal to 1) when the input signal is less than
its previous value.
• The output is false (equal to 0) when the input signal is greater than
or equal to its previous value.
Data Type
Support
The Detect Decrease block accepts signals of the following data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-330
Detect Decrease
Parameters
and
Dialog
Box
Initial condition
Set the initial condition for the previous input U/z.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
2-331
Detect Decrease
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
2-332
Yes
Inherited
Yes
Yes
Detect Decrease
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
Output data type
Set the output data type to boolean or uint8.
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes
Detect Change, Detect Fall Negative, Detect Fall Nonpositive, Detect
Increase, Detect Rise Nonnegative, Detect Rise Positive
2-333
Detect Fall Negative
Purpose
Detect falling edge when signal value decreases to strictly negative
value, and its previous value was nonnegative
Library
Logic and Bit Operations
Description
The Detect Fall Negative block determines if the input is less than zero,
and its previous value was greater than or equal to zero.
• The output is true (equal to 1) when the input signal is less than zero,
and its previous value was greater than or equal to zero.
• The output is false (equal to 0) when the input signal is greater than
or equal to zero, or if the input signal is negative, its previous value
was also negative.
Data Type
Support
The Detect Fall Negative block accepts signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-334
Detect Fall Negative
Parameters
and
Dialog
Box
Initial condition
Set the initial condition of the Boolean expression U/z < 0.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
2-335
Detect Fall Negative
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
2-336
Yes
Inherited
Yes
Yes
Detect Fall Negative
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
Output data type
Set the output data type to boolean or uint8.
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes
Detect Change, Detect Decrease, Detect Fall Nonpositive, Detect
Increase, Detect Rise Nonnegative, Detect Rise Positive
2-337
Detect Fall Nonpositive
Purpose
Detect falling edge when signal value decreases to nonpositive value,
and its previous value was strictly positive
Library
Logic and Bit Operations
Description
The Detect Fall Nonpositive block determines if the input is less than or
equal to zero, and its previous value was greater than zero.
• The output is true (equal to 1) when the input signal is less than or
equal to zero, and its previous value was greater than zero.
• The output is false (equal to 0) when the input signal is greater than
zero, or if it is nonpositive, its previous value was also nonpositive.
Data Type
Support
The Detect Fall Nonpositive block accepts signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-338
Detect Fall Nonpositive
Parameters
and
Dialog
Box
Initial condition
Set the initial condition of the Boolean expression U/z <= 0.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
2-339
Detect Fall Nonpositive
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
2-340
Yes
Inherited
Yes
Yes
Detect Fall Nonpositive
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
Output data type
Set the output data type to boolean or uint8.
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes
Detect Change, Detect Decrease, Detect Fall Negative, Detect Increase,
Detect Rise Nonnegative, Detect Rise Positive
2-341
Detect Increase
Purpose
Detect increase in signal value
Library
Logic and Bit Operations
Description
The Detect Increase block determines if an input is strictly greater than
its previous value.
• The output is true (equal to 1) when the input signal is greater than
its previous value.
• The output is false (equal to 0) when the input signal is less than or
equal to its previous value.
Data Type
Support
The Detect Increase block accepts signals of the following data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-342
Detect Increase
Parameters
and
Dialog
Box
Initial condition
Set the initial condition for the previous input U/z.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
2-343
Detect Increase
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
2-344
Yes
Inherited
Yes
Yes
Detect Increase
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
Output data type
Set the output data type to boolean or uint8.
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes
Detect Change, Detect Decrease, Detect Fall Negative, Detect Fall
Nonpositive, Detect Rise Nonnegative, Detect Rise Positive
2-345
Detect Rise Nonnegative
Purpose
Detect rising edge when signal value increases to nonnegative value,
and its previous value was strictly negative
Library
Logic and Bit Operations
Description
The Detect Rise Nonnegative block determines if the input is greater
than or equal to zero, and its previous value was less than zero.
• The output is true (equal to 1) when the input signal is greater than
or equal to zero, and its previous value was less than zero.
• The output is false (equal to 0) when the input signal is less than
zero, or if the input signal is nonnegative, its previous value was
also nonnegative.
Data Type
Support
The Detect Rise Nonnegative block accepts signals of the following
data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-346
Detect Rise Nonnegative
Parameters
and
Dialog
Box
Initial condition
Set the initial condition of the Boolean expression U/z >= 0.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
2-347
Detect Rise Nonnegative
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
2-348
Yes
Inherited
Yes
Yes
Detect Rise Nonnegative
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
Output data type
Set the output data type to boolean or uint8.
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes
Detect Change, Detect Decrease, Detect Fall Negative, Detect Fall
Nonpositive, Detect Increase, Detect Rise Positive
2-349
Detect Rise Positive
Purpose
Detect rising edge when signal value increases to strictly positive value,
and its previous value was nonpositive
Library
Logic and Bit Operations
Description
The Detect Rise Positive block determines if the input is strictly
positive, and its previous value was nonpositive.
• The output is true (equal to 1) when the input signal is greater than
zero, and the previous value was less than or equal to zero.
• The output is false (equal to 0) when the input is negative or zero, or
if the input is positive, the previous value was also positive.
Data Type
Support
The Detect Rise Positive block accepts signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-350
Detect Rise Positive
Parameters
and
Dialog
Box
Initial condition
Set the initial condition of the Boolean expression U/z > 0.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
2-351
Detect Rise Positive
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
2-352
Yes
Inherited
Yes
Yes
Detect Rise Positive
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
Output data type
Set the output data type to boolean or uint8.
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes
Detect Change, Detect Decrease, Detect Fall Negative, Detect Fall
Nonpositive, Detect Increase, Detect Rise Nonnegative
2-353
Difference
Purpose
Calculate change in signal over one time step
Library
Discrete
Description
The Difference block outputs the current input value minus the
previous input value.
Data Type
Support
The Difference block accepts signals of any numeric data type that
Simulink supports, including fixed-point data types. For more
information, see “Data Types Supported by Simulink” in the Simulink
documentation.
2-354
Difference
Parameters
and
Dialog
Box
The Main pane of the Difference block dialog box appears as follows:
Initial condition for previous input
Set the initial condition for the previous input.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
2-355
Difference
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
2-356
Yes
Inherited
Yes
Yes
Difference
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
The Signal Attributes pane of the Difference block dialog box appears
as follows:
Output minimum
Specify the minimum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
2-357
Difference
Output maximum
Specify the maximum value that the block should output. The
default value is[] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output data type
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output data type parameter.
See “Specify Block Output Data Types” in the Simulink User’s
Guide for more information.
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
2-358
Difference
Saturate to max or min when overflows occur
Select to have overflows saturate to the maximum or minimum
value that the data type can represent. Otherwise, overflows
wrap.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result. In
general, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
Characteristics Direct Feedthrough
Scalar Expansion
Yes
Yes, of inputs and gain
2-359
Digital Clock
Purpose
Output simulation time at specified sampling interval
Library
Sources
Description
The Digital Clock block outputs the simulation time only at the specified
sampling interval. At other times, the block holds the output at the
previous value. To control the precision of this block, set the Sample
time parameter in the block dialog box.
Use this block rather than the Clock block (which outputs continuous
time) when you need the current simulation time within a discrete
system.
Data Type
Support
2-360
The Digital Clock block outputs a real signal of type double. For more
information, see “Data Types Supported by Simulink” in the Simulink
documentation.
Digital Clock
Parameters
and
Dialog
Box
Sample time
Specify the sampling interval. The default value is 1 second. For
more information, see Specifying Sample Time in the Simulink
documentation.
Do not specify a continuous sample time, either 0 or [0,0]. Also,
avoid specifying -1 (inheriting the sample time) because this
block is a source.
Examples
In the following model, the Scope block shows the output of a Digital
Clock block with a Sample time of 0.2.
The Digital Clock block outputs the simulation time every 0.2 seconds.
Otherwise, the block holds the output at the previous value.
2-361
Digital Clock
Characteristics Sample Time
See Also
2-362
Specified in the Sample time parameter
Scalar Expansion
No
Dimensionalized
No
Multidimensionalized
No
Zero-Crossing Detection
No
Clock
Direct Lookup Table (n-D)
Purpose
Index into N-dimensional table to retrieve element, column, or 2-D
matrix
Library
Lookup Tables
Description
Block Inputs and Outputs
The Direct Lookup Table (n-D) block uses inputs as zero-based indices
into an n-dimensional table. The number of inputs varies with the
shape of the output: an element, column, or 2-D matrix.
You define a set of output values as the Table data parameter. The
first input specifies the zero-based index to the table dimension that is
one higher than the output dimensionality. The next input specifies the
zero-based index to the next table dimension, and so on.
Output
Shape
Output
Dimensionality
Table Dimension That Maps to
the First Input
Element
0
1
Column
1
2
Matrix
2
3
Suppose that you want to select a column of values from a 4-D table:
The following mapping of block input port to table dimension applies:
This input port...
Is the index for this table dimension...
1
2
2
3
3
4
2-363
Direct Lookup Table (n-D)
Changes in Block Icon Appearance
Depending on parameters you set, the block icon changes appearance.
For table dimensions higher than 4, the icon matches the 4-D version
but shows the exact number of dimensions in the top text.
When you use the Table data parameter, you see the following icons:
Object That
Inputs Select
from the
Table
Number of Table Dimensions
1
Element
Column
2-D Matrix
2-364
Not applicable
2
3
4
Direct Lookup Table (n-D)
When you use the table input port, you see the following icons:
Object That
Inputs Select
from the
Table
Number of Table Dimensions
1
2
3
4
Element
Column
2-D Matrix
Not applicable
2-365
Direct Lookup Table (n-D)
Data Type
Support
The Direct Lookup Table (n-D) block accepts input signals of different
data types.
Type of Input Port
Data Types Supported
Index port
• Floating point
• Built-in integer
• Boolean
Table port (with the label T)
• Floating point
• Built-in integer
• Fixed point
• Boolean
The output data type is the same as the table data type. Inputs for
indexing must be real, but table data can be complex.
When the table data is...
The block inherits the output
type from...
Not an input
The Table data type parameter
An input
The table input port
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-366
Direct Lookup Table (n-D)
Parameters
and
Dialog
Box
The Main pane of the Direct Lookup Table (n-D) block appears as
follows:
Number of table dimensions
Specify the number of dimensions that the Table data parameter
must have. This value determines the number of independent
variables for the table and the number of inputs to the block.
2-367
Direct Lookup Table (n-D)
To specify...
Do this...
1, 2, 3, or 4
Select the value from the
drop-down list.
A higher number of table
dimensions
Enter a positive integer
directly in the field.
The maximum number of table
dimensions that this block
supports is 30.
Inputs select this object from table
Specify whether the output data is a single element, a column, or
a 2-D matrix. The number of input ports for indexing depends
on your selection.
Selection
Number of Input Ports for Indexing
Element
Number of table dimensions
Column
Number of table dimensions – 1
2-D Matrix
Number of table dimensions – 2
This numbering matches MATLAB indexing. For example, if you
have a 4-D table of data, follow these guidelines:
To access...
Specify...
As in...
An element
Four indices
array(1,2,3,4)
A column
Three indices
array(:,2,3,4)
A 2-D matrix
Two indices
array(:,:,3,4)
Make table an input
Select this check box to force the Direct Lookup Table (n-D) block
to ignore the Table data parameter. Instead, a new input port
appears with T next to it. Use this port to input table data.
2-368
Direct Lookup Table (n-D)
Table data
Specify the table of output values. The matrix size must match
the dimensions of the Number of table dimensions parameter.
The Table data field is available only if you clear the Make
table an input check box.
Tip During block diagram editing, you can leave the Table
data field empty. But for simulation, you must match the
number of dimensions in Table data to the Number of table
dimensions. For details on how to construct multidimensional
MATLAB arrays, see “Multidimensional Arrays” in the MATLAB
documentation.
Click Edit to open the Lookup Table Editor. For more information,
see “Edit Existing LookupTables” in the Simulink documentation.
Diagnostic for out-of-range input
Specify whether to show a warning or error when an index is out
of range with respect to the table dimension. Options include:
• None — do not display any warning or error message
• Warning — display a warning message in the MATLAB
Command Window and continue the simulation
• Error — halt the simulation and display an error message in
the Simulation Diagnostics Viewer
When you select None or Warning, the block clamps out-of-range
indices to fit table dimensions. For example, if the specified index
is 5.3 and the maximum index for that table dimension is 4, the
block clamps the index to 4.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink documentation for more information.
2-369
Direct Lookup Table (n-D)
The Table Attributes pane of the Direct Lookup Table (n-D) block
appears as follows:
Note The parameters in the Table Attributes pane are not available
if you select Make table an input. In this case, the block inherits all
table attributes from the input port with the label T.
Table minimum
Specify the minimum value for table data. The default value is []
(unspecified).
2-370
Direct Lookup Table (n-D)
Table maximum
Specify the maximum value for table data. The default value is []
(unspecified).
Table data type
Specify the table data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit from 'Table data'
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the Table
data type parameter.
Lock data type settings against changes by the fixed-point tools
Select to lock all data type settings of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor. For more
information, see “Locking the Output Data Type Setting”in the
Simulink Fixed Point documentation.
2-371
Direct Lookup Table (n-D)
Examples
When Table Data Is Not an Input
Suppose that you have the following model:
The Direct Lookup Table (n-D) block parameters are:
Block Parameter
Value
Number of table dimensions
4
Inputs select this object from
table
Column
Make table an input
off
Table data
a
Diagnostic for out-of-range
input
Warning
Sample time
2-372
1
Table minimum
[]
Table maximum
[]
Table data type
int16
Lock data type settings
against changes by the
fixed-point tools
off
Direct Lookup Table (n-D)
In this example, a is a 4-D array of linearly increasing values that you
define with the following model preload function:
a = reshape(1:2800, [4 5 20 7]);
When you run the model, you get the following results:
Because the Direct Lookup Table (n-D) block uses zero-based indexing,
the output is:
a(:,2,4,3)
The output has the same data type as the table: int16.
2-373
Direct Lookup Table (n-D)
When Table Data Is an Input
Suppose that you have the following model:
The Direct Lookup Table (n-D) block parameters are:
Block Parameter
Value
Number of table dimensions
4
Inputs select this object from
table
Column
Make table an input
on
Diagnostic for out-of-range
input
Warning
Sample time
2-374
1
Direct Lookup Table (n-D)
The key parameters of the Constant3 block are:
Block Parameter
Value
Constant value
a
Output data type
fixdt(1,16,2)
In this example, a is a 4-D array of linearly increasing values that you
define with the following model preload function:
a = reshape(1:2800, [4 5 20 7]);
When you run the model, you get the following results:
The Constant3 block feeds the 4-D array to the Direct Lookup Table
(n-D) block, using the fixed-point data type fixdt(1,16,2). Because the
Direct Lookup Table (n-D) block uses zero-based indexing, the output is:
a(:,2,4,3)
The output has the same data type as the table: fixdt(1,16,2).
2-375
Direct Lookup Table (n-D)
Characteristics Direct Feedthrough
See Also
2-376
Yes
Sample Time
Specified in the Sample time parameter
Scalar Expansion
For scalar lookups only (not when
returning a column or a 2-D matrix from
the table)
Dimensionalized
For scalar lookups only (not when
returning a column or a 2-D matrix from
the table)
Multidimensionalized
Yes
Zero-Crossing Detection
No
n-D Lookup Table
Discrete Derivative
Purpose
Compute discrete-time derivative
Library
Discrete
Description
The Discrete Derivative block computes an optionally scaled discrete
time derivative as follows
y(tn ) =
Ku(tn ) Ku(tn−1 )
−
Ts
Ts
where u(tn ) and y(tn ) are the block’s input and output at the current
time step, respectively, u(tn−1 ) is the block’s input at the previous time
step, K is a scaling factor, and Ts is the simulation’s discrete step size,
which must be fixed.
Guidelines for Usage in Triggered Subsystems
When you use the Discrete Derivative block in triggered subsystems,
follow these guidelines:
• When the Sample time type parameter of the trigger port is
triggered, verify that your model does not trigger the subsystem at
the first time step.
If your model triggers the subsystem at the first time step, the
Discrete Derivative block generates a divide-by-zero warning
message. This behavior occurs because the time step at t = 0 is zero.
• When the Sample time type parameter of the trigger port is
periodic, your model can trigger the subsystem at any time step.
Data Type
Support
The Discrete Derivative block supports all numeric Simulink data
types, including fixed-point data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-377
Discrete Derivative
Parameters
and
Dialog
Box
The Main pane of the Discrete Derivative block dialog box appears
as follows:
Gain value
Scaling factor used to weight the block’s input at the current
time step.
Initial condition for previous weighted input K*u/Ts
Set the initial condition for the previous scaled input.
2-378
Discrete Derivative
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as a separate channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column
of the input as a separate channel (frame-based processing).
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
• Inherited — Inherit the processing mode from the input signal
and delay the input accordingly. You can identify whether the
input signal is sample or frame based by looking at the signal
line. Simulink represents sample-based signals with a single
line and frame-based signals with a double line.
Note When you choose the Inherited option for the Input
processing parameter, and the input signal is frame-based,
Simulink® will generate a warning or error in future releases.
Use Input processing to specify whether the block performs
sample- or frame-based processing. The block accepts frame-based
signals for the input u. All other input signals must be sample
based.
2-379
Discrete Derivative
Input Signal u
Input Processing
Mode
Block Works?
Sample based
Sample based
Yes
Frame based
Sample based
No, produces an
error
Frame based
Yes
Frame based
Sample based
Frame based
Yes
Inherited
Yes
Yes
For more information about these two processing modes, see
“Sample- and Frame-Based Concepts” in the DSP System Toolbox
documentation.
The Signal Attributes pane of the Discrete Derivative block dialog box
appears as follows:
2-380
Discrete Derivative
Output minimum
Specify the minimum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output maximum
Specify the maximum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
2-381
Discrete Derivative
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output data type
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output data type parameter.
See “Specify Block Output Data Types” in Simulink User’s Guide
for more information.
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
Saturate to max or min when overflows occur
Select to have overflows saturate to the maximum or minimum
value that the data type can represent. Otherwise, overflows
wrap.
2-382
Discrete Derivative
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result. In
general, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
Characteristics Direct Feedthrough
Scalar Expansion
See Also
Yes
Yes, of inputs and gain
Derivative
2-383
Discrete Filter
Purpose
Model Infinite Impulse Response (IIR) filters
Library
Discrete
Description
The Discrete Filter block independently filters each channel of the
input signal with the specified digital IIR filter. You can specify
the filter structure as one of | Direct form I | Direct form I
transposed | Direct form II | Direct form II transposed. The
block implements static filters with fixed coefficients. You can tune the
coefficients of these static filters.
This block filters each channel of the input signal independently over
time. The Input processing parameter allows you to specify how
the block treats each element of the input. You can specify treating
input elements as an independent channel (sample-based processing),
or treating each column of the input as an independent channel
(frame-based processing). To perform frame-based processing, you must
have a DSP System Toolbox license.
The output dimensions equal those of the input, except when you specify
a matrix of filter taps for the Numerator coefficients parameter.
When you do so, the output dimensions depend on the number of
different sets of filter taps you specify.
Use the Numerator coefficients parameter to specify the coefficients
of the discrete filter numerator polynomial. Use the Denominator
coefficients parameter to specify the coefficients of the denominator
polynomial of the function. The Denominator coefficients parameter
must be a vector of coefficients.
Specify the coefficients of the numerator and denominator polynomials
in ascending powers of z-1. The Discrete Filter block lets you use
polynomials in z-1 (the delay operator) to represent a discrete system.
This method is the one that signal processing engineers typically use.
Conversely, the Discrete Transfer Fcn block lets you use polynomials
in z to represent a discrete system. This method is the one that
control engineers typically use. When the numerator and denominator
polynomials have the same length, the two methods are identical.
2-384
Discrete Filter
Coefficient Source
The Digital Filter block can operate in three different modes. Select the
mode in the Coefficient source group box.
• Dialog parameters Enter information about the filter such as
structure and coefficients in the block mask.
• Input port(s) Enter the filter structure in the block mask, and the
filter coefficients come in through one or more block ports. This mode
is useful for specifying time-varying filters.
• Discrete-time filter object (DFILT) Specify the filter using a
dfilt object.
Supported Filter Structures
When you select Discrete-time filter object (DFILT), the following
dfilt structures are supported:
• dfilt.df1
• dfilt.df1t
• dfilt.df2
• dfilt.df2t
The following table shows the vector of filter coefficients you must
provide for each filter structure. For more information on how to specify
filter coefficients for various filter structures, see “Specify Static Filters”
and “Specify Time-Varying Filters”.
2-385
Discrete Filter
Filter Structures and Filter Coefficients
Supported Filter Structures
Filter Coefficient Specification
Direct form I
• Numerator coefficients vector [b0, b1, b2, ...,
bn]
Direct form I transposed
• Denominator coefficients vector [a0, a1, a2,
..., am]
Direct form II
Direct form II transposed
See Special Consideration for the Leading
Denominator Coefficient.
Note Each structure listed in the preceding table supports both
fixed-point and floating-point signals.
Special Considerations for the Leading Denominator Coefficient
In some cases, the Digital Filter block requires the leading denominator
coefficient (a0) to be 1. This requirement applies under the following
conditions:
• The Digital Filter block is operating in a fixed-point mode. The block
operates in a fixed-point mode when at least one of the following
statements is true:
-
The input to the Digital Filter block has a fixed-point or integer
data type.
-
The Fixed-point instrumentation mode parameter in the
Fixed-Point Tool has a setting of Minimums, maximums and
overflows.
• The Coefficient source has a setting of Dialog or Input port(s).
2-386
Discrete Filter
Note The fixed-point modeling situations described in the previous
bullet, require additional settings, if Coefficient source is set
to Input port(s). You must select the First denominator
coefficient = 1 and also select the remove a0 term in the
structure check box.
If you use such a configuration and your leading denominator coefficient
(a0) does not equal 1, the Digital Filter block produces an error. To
resolve the error, set your leading denominator coefficient to 1 by
scaling all numerator and denominator coefficients by a factor of a0.
Specifying Initial States
In Dialog parameters and Input port(s) modes, the block initializes
the internal filter states to zero by default, which is equivalent to
assuming past inputs and outputs are zero. You can optionally use the
Initial states parameter to specify nonzero initial states for the filter
delays.
To determine the number of initial state values you must specify, and
how to specify them, see the following table on Valid Initial States
and Number of Delay Elements (Filter States) on page 2-389. The
Initial states parameter can take one of four forms as described in
the following table.
Valid Initial States
Initial state
Examples
Description
Scalar
5
The block initializes all delay elements
in the filter to the scalar value.
Each delay element for each
channel is set to 5.
Vector
(for applying
the same
delay
For a filter with two delay
elements: [d1 d2]
Each vector element specifies a unique
initial condition for a corresponding
delay element. The block applies the
same vector of initial conditions to each
2-387
Discrete Filter
Valid Initial States (Continued)
Initial state
elements to
each channel)
Vector or
matrix
(for applying
different
delay
elements to
each channel)
Examples
Description
The delay elements for all
channels are d1 and d2.
channel of the input signal. The vector
length must equal the number of delay
elements in the filter (specified in the
table Number of Delay Elements (Filter
States) on page 2-389).
For a 3-channel input signal and
a filter with two delay elements:
Each vector or matrix element
specifies a unique initial condition for
a corresponding delay element in a
corresponding channel:
[d1 d2 D1 D2 d1 d2] or
⎡ d1
⎢d
⎣ 2
D1
D2
d1 ⎤
d2 ⎥⎦
• The delay elements for
channel 1 are d1 and d2.
• The delay elements for
channel 2 are D1 and D2.
• The delay elements for
channel 3 are d1and d2.
Empty matrix
[ ]
Each delay element for each
channel is set to 0.
• The vector length must be equal to
the product of the number of input
channels and the number of delay
elements in the filter (specified in
the table Number of Delay Elements
(Filter States) on page 2-389).
• The matrix must have the same
number of rows as the number of
delay elements in the filter (specified
in the table Number of Delay
Elements (Filter States) on page
2-389), and must have one column
for each channel of the input signal.
The empty matrix, [], is equivalent
to setting the Initial conditions
parameter to the scalar value 0.
The number of delay elements (filter states) per input channel depends
on the filter structure, as indicated in the following table.
2-388
Discrete Filter
Number of Delay Elements (Filter States)
Number of Delay Elements
per Channel
Filter Structure
Direct form I
Direct form I transposed
• number of zeros - 1
Direct form II
Direct form II transposed
max(number of zeros,
number of poles)-1
• number of poles - 1
The following tables describe the valid initial states for different sizes
of input and different number of channels. These tables provide this
information according to whether you set the Input processing
parameter to frame based or sample based.
Frame-Based Processing
Input
Number of
Channels
Valid Initial
States (Dialog
Box)
Valid Initial
States (Input
Port)
• Column
vector
(K-by-1)
1
• Scalar
• Scalar
• Column
vector
(M-by-1)
• Column
vector
(M-by-1)
• Unoriented
vector (K)
• Row vector
(1-by-N)
• Matrix
(K-by-N)
• Row vector
(1-by-M)
N
• Scalar
• Scalar
• Column
vector
(M-by-1)
• Matrix
(M-by-N)
• Row vector
(1-by-M)
2-389
Discrete Filter
Frame-Based Processing (Continued)
Input
Number of
Channels
Valid Initial
States (Dialog
Box)
Valid Initial
States (Input
Port)
• Matrix
(M-by-N)
Sample-Based Processing
Input
Number of
Channels
Valid Initial
States (Dialog
Box)
Valid Initial
States (Input
Port)
• Scalar
1
• Scalar
• Scalar
• Column
vector
(M-by-1)
• Column
vector
(M-by-1)
• Row vector
(1-by-M)
• Row vector
(1-by-M)
• Scalar
• Scalar
• Row vector
(1-by-N)
N
• Column
vector
(M-by-1)
• Column
vector
(N-by–1)
• Row vector
(1-by-M)
• Unoriented
vector (N)
• Matrix
(K-by-N)
2-390
• Matrix
(M-by-N)
K×N
• Scalar
• Column
vector
(M-by-1)
• Scalar
Discrete Filter
Sample-Based Processing (Continued)
Input
Number of
Channels
Valid Initial
States (Dialog
Box)
Valid Initial
States (Input
Port)
• Row vector
(1-by-M)
• Matrix
(M-by-(K×N))
When the Initial states is a scalar, the block initializes all filter states
to the same scalar value. Enter 0 to initialize all states to zero. When
the Initial states is a vector or a matrix, each vector or matrix element
specifies a unique initial state. This unique state corresponds to a delay
element in a corresponding channel:
• The vector length must equal the number of delay elements in the
filter, M = max(number of zeros, number of poles).
• The matrix must have the same number of rows as the number of
delay elements in the filter, M = max(number of zeros, number of
poles). The matrix must also have one column for each channel
of the input signal.
The following example shows the relationship between the initial filter
output and the initial input and state. Given an initial input u1, the
first output y1 is related to the initial state [x1, x2] and initial input by:
⎡ ( u − a2 x1 − a3 x2 ) ⎤
y1 = b1 ⎢ 1
⎥ + b2 x1 + b3 x2
a1
⎣
⎦
2-391
Discrete Filter
u
+
1/a1
b1
-a 2
z-1
-a 3
z-1
x1
x2
+
y
b2
b3
To see an example of how to set initial conditions as a vector:
• Click on the model ex_discretefilter_nonzero_ic, or type it at
the MATLAB command prompt.
• Double-click on the Discrete Filter block, and set the parameters.
The following shows how to set the initial conditions of the Discrete
Filter block to [1 2].
2-392
Discrete Filter
2-393
Discrete Filter
• Simulate the model, by left-clicking the green simulation icon.
2-394
Discrete Filter
2-395
Discrete Filter
• Double-click the scope. You can see that the difference between the
signal filtered by the Discrete Filter block, and the signal from the
filter’s building blocks, is zero.
This demonstrates that you can enter the initial conditions of the
Discrete Filter block as a vector of [1 2]. You can also set the initial
2-396
Discrete Filter
condition of the first Unit Delay to 1 and the second Unit Delay to 2.
The resulting outputs are the same.
2-397
Discrete Filter
Data Type
Support
The Discrete Filter block accepts and outputs real and complex signals
of any signed numeric data type that Simulink supports. The block
supports the same types for the numerator and denominator coefficients.
Numerator and denominator coefficients must have the same
complexity. They can have different word lengths and fraction lengths.
The following diagrams show the filter structure and the data types
used within the Discrete Filter block for fixed-point signals.
1
Input
+
--
1/a 0
b0
+
++
1
Output
z-1
a1
b1
z-1
aM
bN
The block omits the dashed divide when you select the Optimize
by skipping divide by leading denominator coefficient (a0)
parameter.
2-398
Discrete Filter
1
Input
Input
data type
Cast
Denominator
accumulator
data type
+
+
-
Cast
-
Denominator
accumulator
data type
State
data type
b0
Numerator
product output
data type
Cast
Numerator
accumulator
data type
+
+
+
+
Cast
Output
data type
1
Output
z-1
Denominator
product output
data type
Cast
Denominator
accumulator
data type
a1
b1
Denominator
coefficient
data type
Numerator
product output
data type
Cast
Numerator
accumulator
data type
Numerator
coefficient
data type
z-1
Cast
Denominator
product output
data type
a2
Denominator
coefficient
data type
Parameters
and
Dialog
Box
b2
Numerator
product output
data type
Cast
Numerator
accumulator
data type
Numerator
coefficient
data type
The Main pane of the Discrete Filter block dialog box appears as follows.
2-399
Discrete Filter
Numerator
Numerator coefficients of the discrete filter. To specify the
coefficients, set the Source to Dialog. Then, enter the coefficients
in Value as descending powers of z. Use a row vector to specify
the coefficients for a single numerator polynomial.
2-400
Discrete Filter
Denominator
Denominator coefficients of the discrete filter. To specify the
coefficients, set the Source to Dialog. Then, enter the coefficients
in Value as descending powers of z. Use a row vector to specify
the coefficients for a single denominator polynomial.
Initial states
If the Source is Dialog, then, in Value, specify the initial states
of the filter states. To learn how to specify initial states, see
“Specifying Initial States” on page 2-518.
If the Source is Input port, then you do not need to specify
Value.
External reset
Specify the trigger event to use to reset the states to the initial
conditions.
Reset Mode
Behavior
None
No reset.
Rising
Reset on a rising edge.
Falling
Reset on a falling edge.
Either
Reset on either a rising or
falling edge.
Level
Reset in either of these cases:
• when there is a nonzero at
the current time step
• when the time step value
changes from nonzero at the
previous time step to zero at
the current time step
Level hold
Reset when nonzero at the
current time step.
2-401
Discrete Filter
The reset signal must be scalar.
Input processing
Specify whether the block performs sample- or frame-based
processing.
• Elements as channels (sample based) — Process each
element of the input as an independent channel.
• Columns as channels (frame based) — Process each column
of the input as an independent channel.
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
Optimize by skipping divide by leading denominator coefficient
(a0)
Select when the leading denominator coefficient, a0, equals 1.
This parameter optimizes your code.
When you select this check box, the block does not perform a
divide-by-a0 either in simulation or in the generated code. An
error occurs if a0 is not equal to one.
When you clear this check box, the block is fully tunable during
simulation. It performs a divide-by-a0 in both simulation and
code generation.
Sample time
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in
“How Simulink Works” in the Simulink User’s Guide.
2-402
Discrete Filter
The Data Types pane of the Discrete Filter block dialog box appears
as follows.
State
Specify the state data type. You can set this parameter to:
2-403
Discrete Filter
• A rule that inherits a data type, for example, Inherit:
Same
as input
• A built-in integer, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the State
parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
Numerator coefficients
Specify the numerator coefficient data type. You can set this
parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in integer, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Numerator coefficients parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
2-404
Discrete Filter
Numerator coefficient minimum
Specify the minimum value that a numerator coefficient can have.
The default value is [] (unspecified). Simulink software uses this
value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Numerator coefficient maximum
Specify the maximum value that a numerator coefficient can
have. The default value is [] (unspecified). Simulink software
uses this value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Numerator product output
Specify the product output data type for the numerator
coefficients. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Numerator product output parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
2-405
Discrete Filter
Numerator accumulator
Specify the accumulator data type for the numerator coefficients.
You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Numerator accumulator parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
Denominator coefficients
Specify the denominator coefficient data type. You can set this
parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in integer, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Denominator coefficients parameter.
2-406
Discrete Filter
See “Specify Data Types Using Data Type Assistant” for more
information.
Denominator coefficient minimum
Specify the minimum value that a denominator coefficient can
have. The default value is [] (unspecified). Simulink software
uses this value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Denominator coefficient maximum
Specify the maximum value that a denominator coefficient can
have. The default value is [] (unspecified). Simulink software
uses this value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Denominator product output
Specify the product output data type for the denominator
coefficients. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Denominator product output parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
2-407
Discrete Filter
Denominator accumulator
Specify the accumulator data type for the denominator
coefficients. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Denominator accumulator parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
Output
Specify the output data type. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output parameter.
2-408
Discrete Filter
See “Specify Block Output Data Types” for more information.
Output minimum
Specify the minimum value that the block can output. The default
value is [] (unspecified). Simulink software uses this value to
perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output maximum
Specify the maximum value that the block can output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Lock data type settings against changes by the fixed-point tools
Select to lock all data type settings of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor. For more
information, see “Locking the Output Data Type Setting”in the
Simulink Fixed Point documentation.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
2-409
Discrete Filter
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow,
and you want explicit
saturation protection
in the generated code.
Overflows saturate to
either the minimum
or maximum value
that the data type can
represent.
An overflow associated
with a signed 8-bit
integer can saturate to
–128 or 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
–126.
You want to avoid
overspecifying how
a block handles
out-of-range signals.
For more information,
see “Checking for
Signal Range Errors”.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result.
Usually, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
The State Attributes pane of the Discrete Filter block dialog box
appears as follows.
2-410
Discrete Filter
State name
Use this parameter to assign a unique name to the block state.
The default is ' '. When this field is blank, no name is assigned.
When using this parameter, remember these considerations:
• A valid identifier starts with an alphabetic or underscore
character, followed by alphanumeric or underscore characters.
2-411
Discrete Filter
• The state name applies only to the selected block.
This parameter enables State name must resolve to Simulink
signal object when you click Apply.
For more information, see “States” in the Simulink Coder
documentation.
State name must resolve to Simulink signal object
Select this check box to require that the state name resolve to a
Simulink signal object. This check box is cleared by default.
State name enables this parameter.
Selecting this check box disables Code generation storage
class.
Package
Select a package that defines the custom storage class you want
to apply. If you have defined any packages of your own, click
Refresh. This action adds all user-defined packages on your
search path to the package list.
Code generation storage class
From the list, select a state storage class.
Auto
Auto is the storage class to use for states that do not need
to interface to external code.
ExportedGlobal
The state is stored in a global variable.
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
State name enables this parameter.
2-412
Discrete Filter
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage
type qualifier.
Code generation storage type qualifier
Specify a Simulink Coder storage type qualifier. The default is '
'. When this field is blank, no qualifier is assigned.
The Simulink Coder product does not check this string for errors.
Thus, whatever value you enter appears automatically in the
variable declaration.
Setting Code generation storage class to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables this
parameter.
During simulation, the block uses the following values:
• The initial value of the signal object to which the state name resolves
• Minimum and maximum values of the signal object
For more information, see “States” in the Simulink Coder
documentation.
Characteristics Direct Feedthrough
Only when the leading numerator
coefficient does not equal zero
Sample Time
Specified in the Sample time parameter
Scalar Expansion
Yes, of initial states
States
See “Specifying Initial States” on page
2-387
Dimensionalized
Yes
Zero-Crossing Detection
No
2-413
Discrete Filter
Filter
Structure
Diagrams
The diagrams in the following sections show the filter structures
supported by the Digital Filter block. They also show the data types
used in the filter structures for fixed-point signals. You can set the
coefficient, output, accumulator, product output, and state data types
shown in these diagrams in the block dialog.
• “IIR direct form I” on page 2-414
• “IIR direct form I transposed” on page 2-417
• “IIR direct form II” on page 2-420
• “IIR direct form II transposed” on page 2-422
IIR direct form I
2-414
Discrete Filter
The following constraints are applicable when processing a fixed-point
signal with this filter structure:
• Inputs can be real or complex.
• Numerator and denominator coefficients can be real or complex.
• Numerator and denominator coefficients must have the same
complexity characteristics.
-
When the numerator and denominator coefficients are specified
using input ports and have different complexities from each other,
you get an error.
-
When the numerator and denominator coefficients are specified in
the dialog box and have different complexities from each other, the
block does not error. Instead, it processes the filter as if two sets of
complex coefficients are provided. The real-valued coefficient set
is treated as if it is a complex vector with zero-valued imaginary
parts.
• Numerator and denominator coefficients must have the same word
length. They can have different fraction lengths.
• The State data type cannot be specified on the block mask for this
structure. Doing so is not possible because the input and output
states have the same data types as the input and output buffers.
2-415
Discrete Filter
2-416
Discrete Filter
IIR direct form I transposed
2-417
Discrete Filter
The following constraints are applicable when processing a fixed-point
signal with this filter structure:
• Inputs can be real or complex.
• Numerator and denominator coefficients can be real or complex.
• Numerator and denominator coefficients must have the same
complexity characteristics.
-
When the numerator and denominator coefficients are specified
using input ports and have different complexities from each other,
you get an error.
-
When the numerator and denominator coefficients are specified in
the dialog box and have different complexities from each other, the
block does not error. Instead, it processes the filter as if two sets of
complex coefficients are provided. The real-valued coefficient set
is treated as if it is a complex vector with zero-valued imaginary
parts.
• States are complex when either the input or the coefficients are
complex.
• Numerator and denominator coefficients must have the same word
length. They can have different fraction lengths.
2-418
Discrete Filter
2-419
Discrete Filter
IIR direct form II
The following constraints are applicable when processing a fixed-point
signal with this filter structure:
• Inputs can be real or complex.
• Numerator and denominator coefficients can be real or complex.
• Numerator and denominator coefficients must have the same
complexity characteristics.
-
2-420
When the numerator and denominator coefficients are specified
using input ports and have different complexities from each other,
you get an error.
Discrete Filter
-
When the numerator and denominator coefficients are specified in
the dialog box and have different complexities from each other, the
block does not error. Instead, it processes the filter as if two sets of
complex coefficients are provided. The real-valued coefficient set
is treated as if it is a complex vector with zero-valued imaginary
parts.
• States are complex when either the inputs or the coefficients are
complex.
• Numerator and denominator coefficients must have the same word
length. They can have different fraction lengths.
2-421
Discrete Filter
IIR direct form II transposed
The following constraints are applicable when processing a fixed-point
signal with this filter structure:
• Inputs can be real or complex.
2-422
Discrete Filter
• Numerator and denominator coefficients can be real or complex.
• Numerator and denominator coefficients must have the same
complexity characteristics.
-
When the numerator and denominator coefficients are specified
using input ports and have different complexities from each other,
you get an error.
-
When the numerator and denominator coefficients are specified in
the dialog box and have different complexities from each other, the
block does not error. Instead, it processes the filter as if two sets of
complex coefficients are provided. The real-valued coefficient set
is treated as if it is a complex vector with zero-valued imaginary
parts.
• States are complex when either the inputs or the coefficients are
complex.
• Numerator and denominator coefficients must have the same word
length. They can have different fraction lengths.
2-423
Discrete Filter
2-424
Discrete Filter
Supported
Data
Types
• Double-precision floating point
• Single-precision floating point
• Fixed point (signed only)
• 8-, 16-, and 32-bit signed integers
See Also
Allpole Filter
DSP System Toolbox
Digital Filter Design
DSP System Toolbox
Digital Filter
DSP System Toolbox
Discrete FIR Filter
Simulink
Filter Realization
Wizard
DSP System Toolbox
dfilt
DSP System Toolbox
fdatool
DSP System Toolbox
fvtool
Signal Processing Toolbox
2-425
Discrete FIR Filter
Purpose
Model FIR filters
Library
Discrete
Description
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. You can tune the
coefficients of a static filter during simulation.
This block filters each channel of the input signal independently
over time. The Input processing parameter allows you to specify
whether the block treats each element of the input as an independent
channel (sample-based processing), or each column of the input as an
independent channel (frame-based processing). To perform frame-based
processing, you must have a DSP System Toolbox license.
The output dimensions equal those of the input, except when you
specify a matrix of filter taps for the Coefficients parameter. When
you do so, the output dimensions depend on the number of different sets
of filter taps you specify.
The outputs of this block numerically match the outputs of the DSP
System Toolbox Digital Filter Design block and of the Signal Processing
Toolbox™ dfilt object.
This block supports the Simulink state logging feature. See “States” in
the Simulink User’s Guide for more information.
Filter Structure Support
You can change the filter structure implemented with the Discrete FIR
Filter block by selecting one of the following from the Filter structure
parameter:
• Direct form
• Direct form symmetric
• Direct form antisymmetric
2-426
Discrete FIR Filter
• Direct form transposed
• Lattice MA
You must have an available DSP System Toolbox license to run a model
with any of these filter structures other than direct form.
Specifying Initial States
The Discrete FIR Filter block initializes the internal filter states to zero
by default, which has the same effect as assuming that past inputs and
outputs are zero. You can optionally use the Initial states parameter
to specify nonzero initial conditions for the filter delays.
To determine the number of initial states you must specify and how to
specify them, see the table on valid initial states. The Initial states
parameter can take one of the forms described in the next table.
Valid Initial States
Initial Condition
Description
Scalar
The block initializes all delay elements in the filter to the scalar
value.
Vector or matrix
(for applying different
delay elements to each
channel)
Each vector or matrix element specifies a unique initial condition
for a corresponding delay element in a corresponding channel:
• The vector length equal the product of the number of input
channels and the number of delay elements in the filter,
#_of_filter_coeffs-1 (or #_of_reflection_coeffs for
Lattice MA).
• The matrix must have the same number of rows as the number
of delay elements in the filter, #_of_filter_coeffs-1
(#_of_reflection_coeffs for Lattice MA), and must have
one column for each channel of the input signal.
2-427
Discrete FIR Filter
Data Type
Support
The Discrete FIR Filter block accepts and outputs real and complex
signals of any numeric data type supported by Simulink. The block
supports the same types for the coefficients.
The following diagrams show the filter structure and the data types
used within the Discrete FIR Filter block for fixed-point signals.
Direct Form
You cannot specify the state data type on the block mask for this
structure because the input states have the same data types as the
input.
b0
1
Input
z-1
b1
z-1
z-1
bN
2-428
+
++
1
Output
Discrete FIR Filter
1
Input
Input
data type
z-1
b0
Cast
Accumulator
data type
+
Product output
data type
Cast
Accumulator
data type
+
+
Numerator
coefficient
data type
b1
z-1
Product output
data type
+
Cast
Output
data type
1
Output
Accumulator
data type
Numerator
coefficient
data type
bN
Product output
data type
Cast
Accumulator
data type
Numerator
coefficient
data type
2-429
Discrete FIR Filter
Direct Form Symmetric
You cannot specify the state data type on the block mask for this
structure because the input states have the same data types as the
input.
It is assumed that the filter coefficients are symmetric. The block only
uses the first half of the coefficients for filtering.
1
Input
+
+
b0
z-1
z-1
+
++
1
Output
2
Input
+
+
z-1
+
+
b1
+
z-1
bM
z-1
+
+
+
z-1
z-1
z-1
z-1
Even Order - Type I
2-430
b0
Odd Order - Type II
b1
bM
+
++
2
Output
Discrete FIR Filter
1
Input
Input
data type
Cast
Tap sum
data type
+
+
b0
Product output
data type
Cast
Accumulator
data type
+
+
Numerator
coefficient
data type
z-1
+
+
Cast
Output
data type
1
Output
Cast
Tap sum
data type
z
-1
+
b1
+
Product output
data type
Numerator
coefficient
data type
Product output
data type
bM
z-1
Cast
Accumulator
data type
Numerator
coefficient
data type
Tap sum
data type
Cast
Cast
Accumulator
data type
Cast
z-1
Even Order - Type I
2-431
Discrete FIR Filter
1
Input
Input
data type
Cast
Tap sum
data type
b0
+
+
Product output
data type
Cast
Accumulator
data type
Cast
Tap sum
data type
+
b1
+
z-1
Product output
data type
Cast
Accumulator
data type
Numerator
coefficient
data type
Cast
+
z-1
Tap sum
data type
bM
+
Tap sum
data type
Cast
Tap sum
data type
Cast
Numerator
coefficient
data type
Cast
z-1
Product output
data type
Tap sum
data type
Cast
z-1
Odd Order - Type II
2-432
+
+
Numerator
coefficient
data type
z-1
+
Accumulator
data type
+
Cast
Output
data type
1
Output
Discrete FIR Filter
Direct Form Antisymmetric
You cannot specify the state data type on the block mask for this
structure because the input states have the same data types as the
input.
It is assumed that the filter coefficients are antisymmetric. The block
only uses the first half of the coefficients for filtering.
1
Input
+
-
b0
z-1
z-1
+
++
1
Output
2
Input
b0
+
-
+
++
2
Output
z-1
+
-
b1
+
z-1
bM
z-1
b1
-
+
-
bM
z-1
z-1
z-1
z-1
Even Order - Type III
Odd Order - Type IV
2-433
Discrete FIR Filter
1
Input
Input
data type
Cast
Tap sum
data type
+
-
b0
Product output
data type
Cast
Accumulator
data type
Cast
Tap sum
data type
z
-1
+
b1
-
Product output
data type
Numerator
coefficient
data type
Product output
data type
bM
z-1
Cast
Accumulator
data type
Accumulator
data type
Numerator
coefficient
data type
Tap sum
data type
Cast
Cast
Cast
z-1
Even Order - Type III
2-434
+
+
Numerator
coefficient
data type
z-1
+
+
Cast
Output
data type
1
Output
Discrete FIR Filter
1
Input
Input
data type
Cast
Tap sum
data type
b0
+
-
Product output
data type
Cast
Accumulator
data type
Cast
+
+
Numerator
coefficient
data type
z-1
+
+
Cast
Output
data type
1
Output
Tap sum
data type
+
b1
-
z-1
Product output
data type
Cast
Accumulator
data type
Numerator
coefficient
data type
Cast
+
z-1
Tap sum
data type
bM
-
Tap sum
data type
Cast
Tap sum
data type
Cast
Accumulator
data type
Numerator
coefficient
data type
Cast
z-1
Product output
data type
Tap sum
data type
Cast
z-1
Odd Order - Type IV
2-435
Discrete FIR Filter
Direct Form Transposed
States are complex when either the inputs or the coefficients are
complex.
1
Section
input
b0
+
+
z-1
b1
+
+
z-1
bN-1
bN
2-436
+
+
z-1
1
Section
output
Discrete FIR Filter
1
Input
Input
data type
b0
Product output
data type
Cast
Accumulator
data type
Cast
+
+
Ouput
data type
1
Output
Accumulator
data type
z-1
Numerator
coefficient
data type
b1
Product output
data type
Cast
Accumulator
data type
Accumulator
data type
+
+
z-1
Numerator
coefficient
data type
Numerator
coefficient
data type
bN-1
bN
Product output
data type
Product output
data type
Cast
Cast
Accumulator
data type
Accumulator
data type
+
+
Accumulator
data type
Accumulator
data type
z-1
2-437
Discrete FIR Filter
Lattice MA
1
Input
+
1
Output
+
+
+
k0
k1
CONJ(k0)
+
+
z-1
1
Input
Input
data type
Accumulator
data type
Cast
z-1
+
+
Accumulator
data type
Cast
1
Output
+
+
Accumulator
data type
Cast
Cast
State
data type
k0
Product output
data type
Coefficient
data type
CONJ(k0)
z
-1
2-438
Cast
Product output
data type
Product output
data type
Accumulator
data type
k1
Cast
Accumulator
data type
+
+
Cast
Coefficient
data type
State
data type
z-1
Discrete FIR Filter
Parameters
and
Dialog
Box
The Main pane of the Discrete FIR Filter block dialog box appears
as follows.
Coefficient source
Select whether you want to specify the filter coefficients on the
block mask or through an input port.
2-439
Discrete FIR Filter
Filter structure
Select the filter structure you want the block to implement. You
must have an available DSP System Toolbox license to run a
model with a Discrete FIR Filter block that implements any filter
structure other than direct form.
Coefficients
Specify the vector coefficients of the filter’s transfer function.
Filter coefficients must be specified as a row vector. When you
specify a row vector of filter taps, the block applies a single filter
to the input. To apply multiple filters to the same input, specify a
matrix of coefficients, where each row represents a different set
of filter taps. This parameter is visible only when Coefficient
source is set to Dialog parameters . For multiple filter, Filter
structure must be Direct form, and the input must be a scalar.
Input processing
Specify whether the block performs sample- or frame-based
processing. You can select one of the following options:
• Elements as channels (sample based) — Treat each
element of the input as an independent channel (sample-based
processing).
• Columns as channels (frame based) — Treat each column of
the input as an independent channel (frame-based processing).
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
Initial states
Specify the initial conditions of the filter states. To learn how to
specify initial states, see “Specifying Initial States” on page 2-427.
2-440
Discrete FIR Filter
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in
“How Simulink Works” in the Simulink User’s Guide.
The Data Types pane of the Discrete FIR Filter block dialog box
appears as follows.
Tap sum
Specify the tap sum data type of a direct form symmetric or direct
form antisymmetric filter, which is the data type the filter uses
2-441
Discrete FIR Filter
when it sums the inputs prior to multiplication by the coefficients.
You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in integer, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
This parameter is only visible when the selected filter structure is
either Direct form symmetric or Direct form antisymmetric.
to
Click the Show data type assistant button
display the Data Type Assistant, which helps you set the Tap
sum parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
Coefficients
Specify the coefficient data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Same
word length as input
• A built-in integer, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
2-442
Discrete FIR Filter
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Coefficients parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
Coefficients minimum
Specify the minimum value that a filter coefficient should have.
The default value is [] (unspecified). Simulink software uses this
value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Coefficients maximum
Specify the maximum value that a filter coefficient should have.
The default value is [] (unspecified). Simulink software uses this
value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Product output
Specify the product output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
2-443
Discrete FIR Filter
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Product output parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
Accumulator
Specify the accumulator data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Accumulator parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
State
Specify the state data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Same
as accumulator
• A built-in integer, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
2-444
Discrete FIR Filter
This parameter is only visible when the selected filter structure
is Lattice MA.
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the State
parameter.
See “Specify Data Types Using Data Type Assistant” for more
information.
Output
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Same
as accumulator
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output parameter.
See “Specify Block Output Data Types” in the Simulink User’s
Guide for more information.
Output minimum
Specify the minimum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
2-445
Discrete FIR Filter
Output maximum
Specify the maximum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Lock data type settings against changes by the fixed-point tools
Select to lock all data type settings of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor. For more
information, see “Locking the Output Data Type Setting”in the
Simulink Fixed Point documentation.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow,
and you want explicit
saturation protection
in the generated code.
Overflows saturate to
either the minimum
or maximum value
that the data type can
represent.
An overflow associated
with a signed 8-bit
integer can saturate to
–128 or 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
–126.
You want to avoid
overspecifying how
a block handles
out-of-range signals.
For more information,
2-446
Discrete FIR Filter
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
see “Checking for
Signal Range Errors”.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result.
Usually, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
Characteristics Direct Feedthrough
Yes
Sample Time
Specified in the Sample time parameter
Scalar Expansion
Yes, of initial states
States
See “Specifying Initial States” on page
2-427
Dimensionalized
Yes
Zero-Crossing Detection
No
2-447
Discrete State-Space
Purpose
Implement discrete state-space system
Library
Discrete
Description
Block Behavior for Non-Empty Matrices
The Discrete State-Space block implements the system described by
x(n + 1) = Ax(n) + Bu(n)
y(n) = Cx(n) + Du(n),
where u is the input, x is the state, and y is the output. The matrix
coefficients must have these characteristics, as illustrated in the
following diagram:
• A must be an n-by-n matrix, where n is the number of states.
• B must be an n-by-m matrix, where m is the number of inputs.
• C must be an r-by-n matrix, where r is the number of outputs.
• D must be an r-by-m matrix.
The block accepts one input and generates one output. The width of
the input vector is the number of columns in the B and D matrices.
The width of the output vector is the number of rows in the C and D
2-448
Discrete State-Space
matrices. To define the initial state vector, use the Initial conditions
parameter.
To specify a vector or matrix of zeros for A, B, C, D, or Initial
conditions, use the zeros function.
Block Behavior for Empty Matrices
When the matrices A, B, and C are empty (for example, []), the
functionality of the block becomes y(n) = Du(n). If the Initial
conditions vector is also empty, the block uses an initial state vector
of zeros.
Data Type
Support
The Discrete State Space block accepts and outputs a real signal of type
single or double. For more information, see “Data Types Supported
by Simulink” in the Simulink documentation.
2-449
Discrete State-Space
Parameters
and
Dialog
Box
2-450
The Main tab of the Discrete State-Space block dialog box appears
as follows:
Discrete State-Space
A, B, C, D
Specify the matrix coefficients, as defined in the Description
section.
Initial conditions
Specify the initial state vector. The default value is 0. Simulink
does not allow the initial states of this block to be inf or NaN.
Sample time (–1 for inherited)
Specify the time interval between samples. See “Specify Sample
Time” in the Simulink documentation.
The State Attributes tab of the Discrete State-Space block dialog box
appears as follows:
2-451
Discrete State-Space
2-452
Discrete State-Space
State name
Use this parameter to assign a unique name to the block state.
The default is ' '. When this field is blank, no name is assigned.
When using this parameter, remember these considerations:
• A valid identifier starts with an alphabetic or underscore
character, followed by alphanumeric or underscore characters.
• The state name applies only to the selected block.
This parameter enables State name must resolve to Simulink
signal object when you click Apply.
For more information, see “States” in the Simulink Coder
documentation.
State name must resolve to Simulink signal object
Select this check box to require that the state name resolve to a
Simulink signal object. This check box is cleared by default.
State name enables this parameter.
Selecting this check box disables Code generation storage
class.
Package
Select a package that defines the custom storage class you want
to apply. If you have defined any packages of your own, click
Refresh. This action adds all user-defined packages on your
search path to the package list.
Code generation storage class
From the list, select a state storage class.
Auto
Auto is the storage class to use for states that do not need
to interface to external code.
ExportedGlobal
The state is stored in a global variable.
2-453
Discrete State-Space
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
State name enables this parameter.
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage
type qualifier.
Code generation storage type qualifier
Specify a Simulink Coder storage type qualifier. The default is '
'. When this field is blank, no qualifier is assigned.
The Simulink Coder product does not check this string for errors.
Thus, whatever value you enter appears automatically in the
variable declaration.
Setting Code generation storage class to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables this
parameter.
During simulation, the block uses the following values:
• The initial value of the signal object to which the state name is
resolved
• Min and Max values of the signal object
For more information, see “States” in the Simulink Coder
documentation.
Characteristics Direct Feedthrough
Sample Time
2-454
Only if D ≠ 0
Specified in the Sample time parameter
Discrete State-Space
Scalar Expansion
Yes, of the initial conditions
States
Determined by the size of A
Dimensionalized
Yes
Zero-Crossing Detection
No
2-455
Discrete-Time Integrator
Purpose
Perform discrete-time integration or accumulation of signal
Library
Discrete
Description
Capabilities of the Discrete-Time Integrator Block
You can use the Discrete-Time Integrator block in place of the Integrator
block to create a purely discrete system. With the Discrete-Time
Integrator block, you can:
• Define initial conditions on the block dialog box or as input to the
block.
• Define an input gain (K) value.
• Output the block state.
• Define upper and lower limits on the integral.
• Reset the state depending on an additional reset input.
Integration and Accumulation Methods
The block can integrate or accumulate using the Forward Euler,
Backward Euler, and Trapezoidal methods. Assume that u is the input,
y is the output, and x is the state. For a given step n, Simulink updates
y(n) and x(n+1). In integration mode, T is the block sample time
(delta T in the case of triggered sample time). In accumulation mode, T
= 1; the block sample time determines when the output is computed
but not the output value. K is the gain value. Values clip according to
upper or lower limits.
• Forward Euler method (the default), also known as Forward
Rectangular, or left-hand approximation.
For this method, 1/s is approximated by T/(z-1). The resulting
expression for the output of the block at step n is:
y(n) = y(n-1) + K*T*u(n-1)
2-456
Discrete-Time Integrator
Let x(n+1) = x(n) + K*T*u(n). The block uses the following steps
to compute its output:
Step 0:
x(1)
y(0)
= x(0) = IC (clip if necessary)
= y(0) + K*T*u(0)
Step 1:
x(2)
y(1)
= x(1)
= x(1) + K*T*u(1)
Step n:
y(n)
= x(n)
x(n+1) = x(n) + K*T*u(n) (clip if necessary)
With this method, input port 1 does not have direct feedthrough.
• Backward Euler method, also known as Backward Rectangular or
right-hand approximation.
For this method, 1/s is approximated by T*z/(z-1). The resulting
expression for the output of the block at step n is:
y(n) = y(n-1) + K*T*u(n)
Let x(n) = y(n-1). The block uses the following steps to compute its
output
Step 0:
x(1)
y(0)
= x(0) = IC (clipped if necessary)
= y(0)
or, depending on Use initial condition as initial and reset value
for parameter:
Step 0:
x(1)
x(0) = IC (clipped if necessary)
= y(0) = x(0) + K*T*u(0)
Step 1:
x(2)
y(1)
= x(1) + K*T*u(1)
= y(1)
Step n:
y(n)
= x(n) + K*T*u(n)
x(n+1) = y(n)
2-457
Discrete-Time Integrator
With this method, input port 1 has direct feedthrough.
• Trapezoidal method. For this method, 1/s is approximated by
T/2*(z+1)/(z-1)
When T is fixed (equal to the sampling period), let
x(n) = y(n-1) + K*T/2 * u(n-1)
The block uses the following steps to compute its output
Step 0:
x(1)
x(0) = IC (clipped if necessary)
= y(0) + K*T/2 * u(0)
or, depending on Use initial condition as initial and reset value
for parameter:
Step 0:
x(1)
y(0)
= x(0) = IC (clipped if necessary)
= y(0) = x(0) + K*T/2*u(0)
Step 1:
x(2)
y(1)
= x(1) + K*T/2 * u(1)
= y(1) + K*T/2 * u(1)
Step n:
y(n)
= x(n) + K*T/2 * u(n)
x(n+1) = y(n) + K*T/2 * u(n)
Here, x(n+1) is the best estimate of the next output. It is not the
same as the state, in the sense that x(n) != y(n).
If T is variable (for example, obtained from the triggering times), the
block uses the following algorithm to compute the outputs
Step 0:
x(1)
y(0)
= x(0) = IC (clipped if necessary)
= y(0)
or, depending on Use initial condition as initial and reset value
for parameter:
Step 0:
2-458
y(0)
= x(0) = IC (clipped if necessary)
Discrete-Time Integrator
x(1)
Step 1:
x(2)
= y(0) = x(0) + K*T/2*u(0)
y(1)
= x(1) + T/2 * (u(1) + u(0))
= y(1)
Step n:
y(n)
= x(n) + T/2 * (u(n) + u(n-1))
x(n+1) = y(n)
With this method, input port 1 has direct feedthrough.
How to Define Initial Conditions
You can define the initial conditions as a parameter on the block dialog
box or input them from an external signal:
• To define the initial conditions as a block parameter, specify the
Initial condition source parameter as internal and enter the
value in the Initial condition parameter field.
• To provide the initial conditions from an external source, specify the
Initial condition source parameter as external. An additional
input port appears under the block input:
When to Use the State Port
In two situations, you must use the state port instead of the output port:
• When the output of the block is fed back into the block
through the reset port or the initial condition port, causing
an algebraic loop. For an example of this situation, see the
sldemo_bounce_two_integrators model.
2-459
Discrete-Time Integrator
• When you want to pass the state from one conditionally executed
subsystem to another, which can cause timing problems. For an
example of this situation, see the sldemo_clutch model.
You can work around these problems by passing the state through the
state port rather than the output port. Simulink generates the state
at a slightly different time from the output, which protects your model
from these problems. You output the block state by selecting the Show
state port check box.
By default, the state port appears on the top of the block:
How to Limit the Integral
To prevent the output from exceeding specifiable levels, select the Limit
output check box and enter the limits in the appropriate parameter
fields. Doing so causes the block to function as a limited integrator.
When the output reaches the limits, the integral action is turned off to
prevent integral wind up. During a simulation, you can change the
limits but you cannot change whether the output is limited. The block
determines output as follows:
2-460
Discrete-Time Integrator
When the integral is...
The output is...
Less than or equal to the Lower
saturation limit and the input
is negative
Held at the Lower saturation
limit
Between the Lower saturation
limit and the Upper saturation
limit
The integral
Greater than or equal to the
Upper saturation limit and the
input is positive
Held at the Upper saturation
limit
To generate a signal that indicates when the state is being limited,
select the Show saturation port check box. A saturation port appears
below the block output port:
The signal has one of three values:
• 1 indicates that the upper limit is being applied.
• 0 indicates that the integral is not limited.
• -1 indicates that the lower limit is being applied.
How to Reset the State
The block can reset its state to the initial condition you specify, based
on an external signal. To cause the block to reset its state, select one of
the External reset parameter choices. A trigger port appears below
the block input port to indicate the trigger type:
2-461
Discrete-Time Integrator
The reset port has direct feedthrough. If the block output feeds back
into this port, either directly or through a series of blocks with direct
feedthrough, an algebraic loop results. To resolve this loop, feed the
output of the block state port into the reset port instead. To access the
block state, select the Show state port check box.
Reset Trigger Types
The External reset parameter lets you determine the attribute of the
reset signal that triggers the reset. The trigger options include:
• rising
Resets the state when the reset signal has a rising edge. For example,
the following figure shows the effect that a rising reset trigger has
on backward Euler integration.
Reset
Rising
Reset
Integrate
Input
• falling
2-462
No Integration
Discrete-Time Integrator
Resets the state when the reset signal has a falling edge. For
example, the following figure shows the effect that a falling reset
trigger has on backward Euler integration.
Reset
Falling
Reset
Integrate
No Integration
Input
• either
Resets the state when the reset signal rises or falls. For example,
the following figure shows the effect that an either reset trigger has
on backward Euler integration.
Reset
Either
Reset
Integrate
No Integration
Input
• level
2-463
Discrete-Time Integrator
Resets and holds the output to the initial condition while the reset
signal is nonzero. For example, the following figure shows the effect
that a level reset trigger has on backward Euler integration.
Reset
Level
Reset
Input
Integrate
No Integration
• sampled level
Resets the output to the initial condition when the reset signal is
nonzero. For example, the following figure shows the effect that a
sampled level reset trigger has on backward Euler integration.
Reset
Sampled
Level Reset
Input
2-464
No Integration
Integrate
Discrete-Time Integrator
Note The sampled level reset option requires fewer computations
and hence is more efficient than the level reset option. However,
the sampled level reset option might introduce a discontinuity
when integration resumes.
Block Icon When Selecting All Options
When you select all options, the icon looks like this:
Behavior When Using Simplified Initialization Mode
If you use simplified initialization mode, the behavior of the
Discrete-Time Integrator block differs from its behavior in classic
initialization mode. The new initialization behavior is more robust, and
provides more consistent behavior in these cases:
• In algebraic loops
• On enable and disable
• When comparing results using triggered sample time against results
using explicit sample time, where the block is triggered at the same
rate as the explicit sample time
In addition, the simplified initialization behavior makes it easier to
convert Continuous-Time Integrator blocks to Discrete-Time Integrator
blocks, because the initial conditions have the same meaning for both
blocks.
2-465
Discrete-Time Integrator
For more information on classic and simplified initialization modes, see
“Underspecified initialization detection”.
Initial Conditions in Simplified Initialization Mode
When you use simplified initialization mode, the Initial condition
parameter applies only to the integrator output.
In addition, the Use initial condition as initial and reset value
for parameter is disabled. The block uses the initial condition as the
initial and reset value for the output.
Input-Output Equations in Simplified Initialization Mode
When you use simplified initialization mode, the block starts from first
time step n = 0 with initial output y(0) = IC ( clipped if necessary).
For a given step n > 0 with simulation time t(n), Simulink updates
output y(n) as follows:
• Forward Euler Method:
y(n) = y(n-1) + K*[t(n)-t(n-1)]*u(n-1)
• Backward Euler Method:
y(n) = y(n-1) + K*[t(n)-t(n-1)]*u(n)
• Trapezoidal Method:
y(n) = y(n-1) + K*[t(n)-t(n-1)]*[u(n)+u(n-1)]/2
Simulink automatically selects a state-space realization of these
input-output equations depending on the block sample time, which can
be explicit or triggered. When using explicit sample time, t(n)-t(n-1)
reduces to the sample time T for all n > 0.
Enable and Disable Behavior in Simplified Initialization Mode
When you use simplified initialization mode, the enable and disable
behavior of the block is simplified as follows:
At disable time td:
y(td) = y(td-1)
2-466
Discrete-Time Integrator
At enable time te:
• If parent subsystem resets on enable:
y(te) = IC
• In all other cases (see below):
y(te) = y(td)
2-467
Discrete-Time Integrator
Iterator Subsystems
When using simplified initialization mode, you cannot place the
Discrete-Time Integrator block in an Iterator Subsystem.
In simplified initialization mode, Iterator subsystems do not maintain
elapsed time, so Simulink reports an error if any block needing elapsed
2-468
Discrete-Time Integrator
time, such as the Discrete-Time Integrator, is placed inside an Iterator
Subsystem block.
Behavior When Used in an Enabled Subsystem Inside a
Function-Call Subsystem
Suppose that you have a function-call subsystem that contains an
enabled subsystem, which contains a Discrete-Time Integrator block.
The following behavior applies.
Integrator Method
Sample Time Type
of Function-Call
Trigger Port
delta T When
Forward Euler
Triggered
t
tstart
When the
function-call
subsystem executes
for the first time, the
integrator algorithm
uses tstart as the
previous simulation
time.
Backward Euler and
Trapezoidal
Triggered
t
tprevious
When the
function-call
subsystem executes
for the first time, the
integrator algorithm
uses tprevious
Value of
Reason for
Behavior
Function-Call
Subsystem
Executes for the
First Time After
Enabled
2-469
Discrete-Time Integrator
Integrator Method
Sample Time Type
of Function-Call
Trigger Port
Value of
delta T When
Reason for
Behavior
Function-Call
Subsystem
Executes for the
First Time After
Enabled
as the previous
simulation time.
Forward Euler,
Backward Euler,
and Trapezoidal
Data Type
Support
Periodic
Sample time of
the function-call
generator
In periodic mode,
the Discrete-Time
Integrator block
uses sample time
of the function-call
generator for delta
T.
The Discrete-Time Integrator block accepts real signals of the following
data types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-470
Discrete-Time Integrator
Parameters
and
Dialog
Box
The Main pane of the Discrete-Time Integrator block dialog box
appears as follows:
2-471
Discrete-Time Integrator
The Signal Attributes pane of the Discrete-Time Integrator block
dialog box appears as follows:
2-472
Discrete-Time Integrator
2-473
The State Attributes pane of the Discrete-Time Integrator block dialog
box appears as follows:
Discrete-Time Integrator
2-474
During simulation, the block uses the following values:
Discrete-Time Integrator
• The initial value of the signal object to which the state name is
resolved
• Min and Max values of the signal object
For more information, see “States” in the Simulink Coder
documentation.
• “Show data type assistant” on page 2-1665
• “Integrator method” on page 2-478
• “Gain value” on page 2-479
• “External reset” on page 2-480
• “Initial condition source” on page 2-824
• “Initial condition” on page 2-482
• “Use initial condition as initial and reset value for” on page 2-483
• “Sample time (-1 for inherited)” on page 2-485
• “Limit output” on page 2-826
• “Upper saturation limit” on page 2-827
• “Lower saturation limit” on page 2-828
• “Show saturation port” on page 2-829
• “Show state port” on page 2-830
• “Ignore limit and reset when linearizing” on page 2-491
• “Lock output data type setting against changes by the fixed-point
tools” on page 2-1713
• “Integer rounding mode” on page 2-1714
• “Saturate on integer overflow” on page 2-1716
• “State name” on page 2-1939
• “State name must resolve to Simulink signal object” on page 2-1940
2-475
Discrete-Time Integrator
• “Package” on page 2-1941
• “Code generation storage class (when Package is selected)” on page
2-1943
• “Code generation storage class (when Package is selected)” on page
2-1943
• “Code generation storage type qualifier” on page 2-1945
• “Output minimum” on page 2-1719
• “Output maximum” on page 2-1720
• “Output data type” on page 2-506
• “Mode” on page 2-508
• “Data type override” on page 2-1892
• “Signedness” on page 2-1893
• “Word length” on page 2-1896
• “Scaling” on page 2-1728
• “Fraction length” on page 2-1897
• “Slope” on page 2-1898
• “Bias” on page 2-1898
2-476
Discrete-Time Integrator
Show data type assistant
Display the Data Type Assistant.
Settings
The Data Type Assistant helps you set the Output data type
parameter.
For more information, see “Specify Block Output Data Types”.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-477
Discrete-Time Integrator
Integrator method
Specify the integration or accumulation method.
Settings
Default: Integration:
Integration:
Forward Euler
Forward Euler
Integrator method is Forward Euler.
Integration:
Backward Euler
Integrator method is Backward Euler.
Integration:
Trapezoidal
Integrator method is Trapezoidal.
Accumulation:
Forward Euler
Accumulation method is Forward Euler.
Accumulation:
Backward Euler
Accumulation method is Backward Euler.
Accumulation:
Trapezoidal
Accumulation method is Trapezoidal.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-478
Discrete-Time Integrator
Gain value
Specify a scalar, vector, or matrix by which to multiply the integrator
input. Each element of the gain must be a positive real number.
Settings
Default: 1.0
• Specifying a value other than 1.0 (the default) is semantically
equivalent to connecting a Gain block to the input of the integrator.
• Valid entries include:
-
double(1.0)
single(1.0)
[1.1 2.2 3.3 4.4]
[1.1 2.2; 3.3 4.4]
• Using this parameter to specify the input gain eliminates a
multiplication operation in the generated code. Realizing this benefit,
however, requires that this parameter be nontunable. Accordingly,
the Simulink Coder software generates a warning during code
generation if the Model Parameter Configuration dialog box for this
model declares this parameter to be tunable. If you want to tune
the input gain, set this parameter to 1.0 and use an external Gain
block to specify the input gain.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-479
Discrete-Time Integrator
External reset
Reset the states to their initial conditions when a trigger event occurs
in the reset signal.
Settings
Default: none
none
Do not reset the state to initial conditions.
rising
Reset the state when the reset signal has a rising edge.
falling
Reset the state when the reset signal has a falling edge.
either
Reset the state when the reset signal rises or falls.
level
Reset and holds the output to the initial condition while the reset
signal is nonzero.
sampled level
Reset the output to the initial condition when the reset signal
is nonzero.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-480
Discrete-Time Integrator
Initial condition source
Get the initial conditions of the states.
Settings
Default: internal
internal
Get the initial conditions of the states from the Initial condition
parameter.
external
Get the initial conditions of the states from an external block.
Tips
Simulink software does not allow the initial condition of this block to
be inf or NaN.
Dependencies
Selecting internal enables the Initial condition parameter.
Selecting external disables the Initial condition parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-481
Discrete-Time Integrator
Initial condition
Specify the states’ initial conditions.
Settings
Default: 0
Minimum: value of Output minimum parameter
Maximum: value of Output maximum parameter
Tips
Simulink software does not allow the initial condition of this block to
be inf or NaN.
Dependencies
Setting Initial condition source to internal enables this parameter.
Setting Initial condition source to external disables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-482
Discrete-Time Integrator
Use initial condition as initial and reset value for
Specify whether to apply the initial condition as the initial and reset
value for the state and output, or the state only.
Note If you are using simplified initialization mode, this parameter
is disabled. The initial condition is always used as the initial and
reset value for the output. For more information, see “Underspecified
initialization detection”.
Settings
Default: State and output
State and output
Set the following for initial
y(0) = IC
x(0) = IC
or at reset
y(n) = IC
x(n) = IC
State only (most efficient)
Set the following for initial
x(0) = IC
or at reset
x(n) = IC
2-483
Discrete-Time Integrator
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-484
Discrete-Time Integrator
Sample time (-1 for inherited)
Enter the discrete interval between sample time hits.
Settings
Default: 1
By default, the block uses a discrete sample time of 1. To set a different
sample time, enter another discrete value, such as 0.1.
See also “Specify Sample Time” in the online documentation for more
information.
Tips
• Do not specify a sample time of 0. This value specifies a continuous
sample time, which the Discrete-Time Integrator block does not
support.
• Do not specify a sample time of inf or NaN because these values are
not discrete.
• If you specify -1 to inherit the sample time from an upstream block,
verify that the upstream block uses a discrete sample time. For
example, the Discrete-Time Integrator block cannot inherit a sample
time of 0.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-485
Discrete-Time Integrator
Limit output
Limit the block’s output to a value between the Lower saturation
limit and Upper saturation limit parameters.
Settings
Default: Off
On
Limit the block’s output to a value between the Lower
saturation limit and Upper saturation limit parameters.
Off
Do not limit the block’s output to a value between the Lower
saturation limit and Upper saturation limit parameters.
Dependencies
This parameter enables Upper saturation limit.
This parameter enables Lower saturation limit.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-486
Discrete-Time Integrator
Upper saturation limit
Specify the upper limit for the integral.
Settings
Default: inf
Minimum: value of Output minimum parameter
Maximum: value of Output maximum parameter
Dependencies
Limit output enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-487
Discrete-Time Integrator
Lower saturation limit
Specify the lower limit for the integral.
Settings
Default: -inf
Minimum: value of Output minimum parameter
Maximum: value of Output maximum parameter
Dependencies
Limit output enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-488
Discrete-Time Integrator
Show saturation port
Add a saturation output port to the block.
Settings
Default: Off
On
Add a saturation output port to the block.
Off
Do not add a saturation output port to the block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-489
Discrete-Time Integrator
Show state port
Add an output port to the block for the block’s state.
Settings
Default: Off
On
Add an output port to the block for the block’s state.
Off
Do not add an output port to the block for the block’s state.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-490
Discrete-Time Integrator
Ignore limit and reset when linearizing
Cause Simulink linearization commands to treat this block as not
resettable and as having no limits on its output, regardless of the
settings of the block reset and output limitation options.
Settings
Default: Off
On
Cause Simulink linearization commands to treat this block as not
resettable and as having no limits on its output, regardless of the
settings of the block reset and output limitation options.
Off
Do not cause Simulink linearization commands to treat this block
as not resettable and as having no limits on its output, regardless
of the settings of the block reset and output limitation options.
Tips
Ignoring the limit and resetting allows you to linearize a model around
an operating point. This point may cause the integrator to reset or
saturate.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-491
Discrete-Time Integrator
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
2-492
Discrete-Time Integrator
Integer rounding mode
Specify the rounding mode for fixed-point operations.
Settings
Default: Floor
Ceiling
Rounds both positive and negative numbers toward positive
infinity. Equivalent to the MATLAB ceil function.
Convergent
Rounds number to the nearest representable value. If a tie occurs,
rounds to the nearest even integer. Equivalent to the Fixed-Point
Toolbox convergent function.
Floor
Rounds both positive and negative numbers toward negative
infinity. Equivalent to the MATLAB floor function.
Nearest
Rounds number to the nearest representable value. If a tie occurs,
rounds toward positive infinity. Equivalent to the Fixed-Point
Toolbox nearest function.
Round
Rounds number to the nearest representable value. If a tie occurs,
rounds positive numbers toward positive infinity and rounds
negative numbers toward negative infinity. Equivalent to the
Fixed-Point Toolbox round function.
Simplest
Automatically chooses between round toward floor and round
toward zero to generate rounding code that is as efficient as
possible.
Zero
Rounds number toward zero. Equivalent to the MATLAB fix
function.
2-493
Discrete-Time Integrator
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Rounding” in the Simulink Fixed Point
documentation.
2-494
Discrete-Time Integrator
Saturate on integer overflow
Specify whether overflows saturate.
Settings
Default: Off
On
Overflows saturate to either the minimum or maximum value
that the data type can represent.
For example, an overflow associated with a signed 8-bit integer
can saturate to -128 or 127.
Off
Overflows wrap to the appropriate value that is representable
by the data type.
For example, the number 130 does not fit in a signed 8-bit integer
and wraps to -126.
Tips
• Consider selecting this check box when your model has possible
overflow and you want explicit saturation protection in the generated
code.
• Consider clearing this check box when you want to optimize efficiency
of your generated code.
Clearing this check box also helps you avoid overspecifying how
a block handles out-of-range signals. For more information, see
“Checking for Signal Range Errors”.
• When you select this check box, saturation applies to every internal
operation on the block, not just the output or result.
• In general, the code generation process can detect when overflow
is not possible. In this case, the code generator does not produce
saturation code.
2-495
Discrete-Time Integrator
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-496
Discrete-Time Integrator
State name
Use this parameter to assign a unique name to each state.
Settings
Default: '
'
• If left blank, no name is assigned.
Tips
• A valid identifier starts with an alphabetic or underscore character,
followed by alphanumeric or underscore characters.
• The state name applies only to the selected block.
Dependency
This parameter enables State name must resolve to Simulink
signal object when you click the Apply button.
For more information, see “States” in the Simulink Coder
documentation.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-497
Discrete-Time Integrator
State name must resolve to Simulink signal object
Require that state name resolve to Simulink signal object.
Settings
Default: Off
On
Require that state name resolve to Simulink signal object.
Off
Do not require that state name resolve to Simulink signal object.
Dependencies
State name enables this parameter.
Selecting this check box disables Code generation storage class.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-498
Discrete-Time Integrator
Package
Select a package that defines the custom storage class you want to
apply.
Settings
Default: ---None-----None---
Sets internal storage class attributes.
mpt
Applies the built-in mpt package.
Simulink
Applies the built-in Simulink package.
Dependencies
If you have defined any packages of your own, click Refresh. This action
adds all user-defined packages on your search path to the package list.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-499
Discrete-Time Integrator
Code generation storage class
Select state storage class.
Settings
Default: Auto
Auto
Auto is the appropriate storage class for states that you do not
need to interface to external code.
ExportedGlobal
State is stored in a global variable
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
Dependencies
State name enables this parameter.
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage type
qualifier.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
“State Storage Classes” in the Simulink Coder documentation.
2-500
Discrete-Time Integrator
Code generation storage class (when Package is selected)
Select custom storage class for state.
Settings
Default: Auto
Auto
Auto is the appropriate storage class for states that you do not
need to interface to external code.
SimulinkGlobal
model_P initializes the state to its corresponding value in the
workspace.
ExportedGlobal
State is stored in a global variable
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
Default
A non-editable placeholder storage class is created.
BitField
A struct declaration is created that embeds Boolean data.
Volatile
Volatile type qualifier is used in state declaration.
ExportToFile
Header (.h) file containing global variable declarations is
generated with user-specified name.
ImportFromFile
Predefined header (.h) files containing global variable
declarations are included.
2-501
Discrete-Time Integrator
FileScope
A static qualifier is generated in front of the state declaration to
make the state visible only to the current file.
Struct
A struct declaration is created to encapsulate parameter or
signal object data.
StructVolatile
Volatile type qualifier is used in struct declaration.
GetSet
Supports specialized function calls to read and write memory.
Dependencies
State name enables this parameter.
The list of valid storage classes differs based on the Package selection.
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage type
qualifier.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
“State Storage Classes” in the Simulink Coder documentation.
2-502
Discrete-Time Integrator
Code generation storage type qualifier
Specify the Simulink Coder storage type qualifier.
Settings
Default: '
'
If left blank, no qualifier is assigned.
Dependency
Setting Code generation storage class to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-503
Discrete-Time Integrator
Output minimum
Specify the minimum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the minimum value for bus data on the block. Simulink ignores
this setting. Instead, set the minimum values for bus elements of the
bus object specified as the data type. For information on the Minimum
property of a bus element, see Simulink.BusElement.
Simulink uses the minimum to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-504
Discrete-Time Integrator
Output maximum
Specify the maximum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the maximum value for bus data on the block. Simulink ignores this
setting. Instead, set the maximum values for bus elements of the bus
object specified as the data type. For information on the Maximum
property of a bus element, see Simulink.BusElement.
Simulink uses the maximum value to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-505
Discrete-Time Integrator
Output data type
Specify the output data type.
Settings
Default: Inherit:
Inherit:
Inherit via internal rule
Inherit via internal rule
Simulink chooses a combination of output scaling and data type
that requires the smallest amount of memory consistent with
accommodating the calculated output range and maintaining
the output precision of the block and with the word size of the
targeted hardware implementation specified for the model. If the
Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic), i.e., a generic 32-bit
microprocessor, is specified as the target hardware, the output
data type is int32. If none of the word lengths provided by
the target microprocessor can accommodate the output range,
Simulink software displays an error message in the Simulation
Diagnostics Viewer.
Inherit:
Inherit via back propagation
Use data type of the driving block.
double
Output data type is double.
single
Output data type is single.
int8
Output data type is int8.
2-506
Discrete-Time Integrator
uint8
Output data type is uint8.
int16
Output data type is int16.
uint16
Output data type is uint16.
int32
Output data type is int32.
uint32
Output data type is uint32.
fixdt(1,16,0)
Output data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Output data type is fixed point fixdt(1,16,2^0,0).
<data type expression>
Use a data type object, for example, Simulink.NumericType.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specify Block Output Data Types”.
2-507
Discrete-Time Integrator
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second menu/text box to the right. Select one of the following
choices:
• Inherit via internal rule (default)
• Inherit via back propagation
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Fixed-point data types.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
2-508
Discrete-Time Integrator
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-509
Discrete-Time Integrator
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-510
Discrete-Time Integrator
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-511
Discrete-Time Integrator
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-512
Discrete-Time Integrator
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-513
Discrete-Time Integrator
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-514
Discrete-Time Integrator
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-515
Discrete-Time Integrator
Examples
The sldemo_fuelsys model uses a Discrete-Time Integrator block in
the fuel_rate_control/airflow_calc subsystem. This block uses the
Forward Euler integration method.
When the Switch block feeds a nonzero value into the Discrete-Time
Integrator block, integration occurs. Otherwise, integration does not
occur.
Characteristics Direct Feedthrough
2-516
Yes, of the reset and external initial
condition source ports. The input has
direct feedthrough for every integration
method except Forward Euler and
accumulation Forward Euler.
Sample Time
Specified in the Sample time parameter
Scalar Expansion
Yes, of parameters
Discrete-Time Integrator
See Also
States
Inherited from driving block and
parameter
Dimensionalized
Yes
Multidimensionalized
No
Zero-Crossing Detection
No
Integrator
2-517
Discrete Transfer Fcn
Purpose
Implement discrete transfer function
Library
Discrete
Description
The Discrete Transfer Fcn block implements the z-transform transfer
function:
H ( z) =
num( z) num0 zm + num1 zn−1 + ... + numm
=
den( z)
den0 zn + den1 zn−1 + ... + denn
where m+1 and n+1 are the number of numerator and denominator
coefficients, respectively. num and den contain the coefficients of the
numerator and denominator in descending powers of z. num can be
a vector or matrix, den must be a vector, and you specify both as
parameters on the block dialog box. The order of the denominator must
be greater than or equal to the order of the numerator.
Specify the coefficients of the numerator and denominator polynomials
in descending powers of z. This block lets you use polynomials in z to
represent a discrete system, a method that control engineers typically
use. Conversely, the Discrete Filter block lets you use polynomials in z-1
(the delay operator) to represent a discrete system, a method that signal
processing engineers typically use. The two methods are identical when
the numerator and denominator polynomials have the same length.
The Discrete Transfer Fcn block applies the z-transform transfer
function to each independent channel of the input. The Input
processing parameter allows you to specify whether the block treats
each element of the input as an individual channel (sample-based
processing), or each column of the input as an individual channel
(frame-based processing). To perform frame-based processing, you must
have a DSP System Toolbox license.
Specifying Initial States
Use the Initial states parameter to specify initial filter states. To
determine the number of initial states you must specify and how to
specify them, see the following tables.
2-518
Discrete Transfer Fcn
Frame-Based Processing
Input
Number of
Channels
Valid Initial
States (Dialog
Box)
Valid Initial
States (Input
Port)
• Column
vector
(K-by-1)
1
• Scalar
• Scalar
• Column
vector
(M-by-1)
• Column
vector
(M-by-1)
• Unoriented
vector (K)
• Row vector
(1-by-N)
• Row vector
(1-by-M)
N
• Matrix
(K-by-N)
• Scalar
• Scalar
• Column
vector
(M-by-1)
• Matrix
(M-by-N)
• Row vector
(1-by-M)
• Matrix
(M-by-N)
Sample-Based Processing
Input
Number of
Channels
Valid Initial
States (Dialog
Box)
Valid Initial
States (Input
Port)
• Scalar
1
• Scalar
• Scalar
• Column
vector
(M-by-1)
• Column
vector
(M-by-1)
2-519
Discrete Transfer Fcn
Sample-Based Processing (Continued)
Input
• Row vector
(1-by-N)
Number of
Channels
N
Valid Initial
States (Input
Port)
• Row vector
(1-by-M)
• Row vector
(1-by-M)
• Scalar
• Scalar
• Column
vector
(M-by-1)
• Column
vector
(N-by-1)
• Row vector
(1-by-M)
• Unoriented
vector (N)
• Matrix
(K-by-N)
Valid Initial
States (Dialog
Box)
• Matrix
(M-by-N)
K×N
• Scalar
• Scalar
• Column
vector
(M-by-1)
• Row vector
(1-by-M)
• Matrix
(M-by-(K×N))
When the Initial states is a scalar, the block initializes all filter states
to the same scalar value. Enter 0 to initialize all states to zero. When
the Initial states is a vector or a matrix, each vector or matrix element
specifies a unique initial state for a corresponding delay element in
a corresponding channel:
• The vector length must equal the number of delay elements in the
filter, M = max(number of zeros, number of poles).
2-520
Discrete Transfer Fcn
• The matrix must have the same number of rows as the number of
delay elements in the filter, M = max(number of zeros, number of
poles). The matrix must also have one column for each channel
of the input signal.
The following example shows the relationship between the initial filter
output and the initial input and state. Given an initial input u1, the
first output y1 is related to the initial state [x1, x2] and initial input by:
⎡ ( u − a2 x1 − a3 x2 ) ⎤
y1 = b1 ⎢ 1
⎥ + b2 x1 + b3 x2
a1
⎦
⎣
u
Data Type
Support
+
1/a1
b1
-a 2
z-1
-a 3
z-1
x1
x2
+
y
b2
b3
The Discrete Transfer Function block accepts and outputs real and
complex signals of any signed numeric data type that Simulink
supports. The block supports the same types for the numerator and
denominator coefficients.
Numerator and denominator coefficients must have the same
complexity. They can have different word lengths and fraction lengths.
States are complex when either the input or the coefficients are complex.
The following diagrams show the filter structure and the data types
that the block uses for floating-point and fixed-point signals.
2-521
Discrete Transfer Fcn
1
Input
+
---
1/a 0
+
+
1
Output
z-1
a1
z-1
a2
b0
z-1
a3
b1
The block omits the dashed divide when you select the Optimize
by skipping divide by leading denominator coefficient (a0)
parameter.
2-522
Discrete Transfer Fcn
1
Input
Input
data type
Cast
Denominator
accumulator
data type
+
+
+
-
-
-
Denominator
accumulator
data type
Cast
State
data type
+
+
Cast
Output
data type
1
Output
z-1
Denominator
product output
data type
Cast
a1
Denominator
coefficient
data type
Denominator
accumulator
data type
z-1
Denominator
product output
data type
Cast
b0
a2
Cast
z-1
Denominator
product output
data type
a2
Denominator
coefficient
data type
Parameters
and
Dialog
Box
Cast
Numerator
accumulator
data type
Numerator
coefficient
data type
Denominator
coefficient
data type
Denominator
accumulator
data type
Numerator
product output
data type
b1
Numerator
product output
data type
Cast
Numerator
accumulator
data type
Numerator
coefficient
data type
The Main pane of the Discrete Transfer Fcn block dialog box appears
as follows.
2-523
Discrete Transfer Fcn
Numerator
Numerator coefficients of the discrete transfer function. To
specify the coefficients, set the Source to Dialog. Then enter the
coefficients in Value as descending powers of z. Use a row vector
to specify the coefficients for a single numerator polynomial. Use
a matrix to specify coefficients for multiple filters to be applied to
the same input. Each matrix row represents a set of filter taps.
2-524
Discrete Transfer Fcn
Denominator
Denominator coefficients of the discrete transfer function. To
specify the coefficients, set the Source to Dialog. Then, enter the
coefficients in Value as descending powers of z. Use a row vector
to specify the coefficients for a single denominator polynomial.
Use a matrix to specify coefficients for multiple filters to be applied
to the same input. Each matrix row represents a set of filter taps.
Initial states
If the Source is Dialog, then, in Value, specify the initial states
of the filter states. To learn how to specify initial states, see
“Specifying Initial States” on page 2-518.
If the Source is Input port, then there is nothing to be specified
for Value.
External reset
Specify the trigger event to use to reset the states to the initial
conditions.
Reset Mode
Behavior
None
No reset.
Rising
Reset on a rising edge.
Falling
Reset on a falling edge.
Either
Reset on either a rising or
falling edge.
Level
Reset in either of these cases:
• when there is a nonzero at
the current time step
• when the time step value
changes from nonzero at the
previous time step to zero at
the current time step
Level hold
Reset when nonzero at the
current time step.
2-525
Discrete Transfer Fcn
The reset signal must be scalar.
Input processing
Specify whether the block performs sample- or frame-based
processing.
• Elements as channels (sample based) — Process each
element of the input as an independent channel.
• Columns as channels (frame based) — Process each column
of the input as an independent channel.
Note Frame-based processing requires a DSP System Toolbox
license.
For more information, see “Sample- and Frame-Based
Concepts” in the DSP System Toolbox documentation.
Optimize by skipping divide by leading denominator coefficient
(a0)
Select when the leading denominator coefficient, a0, equals one.
This parameter optimizes your code.
When you select this check box, the block does not perform a
divide-by-a0 either in simulation or in the generated code. An
error occurs if a0 is not equal to one.
When you clear this check box, the block is fully tunable during
simulation, and performs a divide-by-a0 in both simulation and
code generation.
Sample time
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in
“How Simulink Works” in the Simulink User’s Guide.
2-526
Discrete Transfer Fcn
The Data Types pane of the Discrete Transfer Function block dialog
box appears as follows.
State
Specify the state data type. You can set it to:
2-527
Discrete Transfer Fcn
• A rule that inherits a data type, for example, Inherit:
Same
as input
• A built-in integer, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the State
parameter.
See “Specify Data Types Using Data Type Assistant” in the
Simulink User’s Guide for more information.
Numerator coefficients
Specify the numerator coefficient data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in integer, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Numerator coefficients parameter.
See “Specify Data Types Using Data Type Assistant” in the
Simulink User’s Guide for more information.
2-528
Discrete Transfer Fcn
Numerator coefficient minimum
Specify the minimum value that a numerator coefficient can have.
The default value is [] (unspecified). Simulink software uses this
value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Numerator coefficient maximum
Specify the maximum value that a numerator coefficient can
have. The default value is [] (unspecified). Simulink software
uses this value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Numerator product output
Specify the product output data type for the numerator
coefficients. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Numerator product output parameter.
See “Specify Data Types Using Data Type Assistant” in the
Simulink User’s Guide for more information.
2-529
Discrete Transfer Fcn
Numerator accumulator
Specify the accumulator data type for the numerator coefficients.
You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Numerator accumulator parameter.
See “Specify Data Types Using Data Type Assistant” in the
Simulink User’s Guide for more information.
Denominator coefficients
Specify the denominator coefficient data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in integer, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Denominator coefficients parameter.
2-530
Discrete Transfer Fcn
See “Specify Data Types Using Data Type Assistant” in the
Simulink User’s Guide for more information.
Denominator coefficient minimum
Specify the minimum value that a denominator coefficient can
have. The default value is [] (unspecified). Simulink software
uses this value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Denominator coefficient maximum
Specify the maximum value that a denominator coefficient can
have. The default value is [] (unspecified). Simulink software
uses this value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Denominator product output
Specify the product output data type for the denominator
coefficients. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Denominator product output parameter.
See “Specify Data Types Using Data Type Assistant” in
theSimulink User’s Guide for more information.
2-531
Discrete Transfer Fcn
Denominator accumulator
Specify the accumulator data type for the denominator
coefficients. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Denominator accumulator parameter.
See “Specify Data Types Using Data Type Assistant” in the
Simulink User’s Guide for more information.
Output
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• A built-in data type, for example, int8
• A data type object, for example, a Simulink.NumericType
object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output parameter.
2-532
Discrete Transfer Fcn
See “Specify Block Output Data Types” in the Simulink User’s
Guide for more information.
Output minimum
Specify the minimum value that the block can output. The default
value is [] (unspecified). Simulink uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output maximum
Specify the maximum value that the block can output. The default
value is [] (unspecified). Simulink uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Lock data type settings against changes by the fixed-point tools
Select to lock all data type settings of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor. For more
information, see “Locking the Output Data Type Setting”in the
Simulink Fixed Point documentation.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow,
and you want explicit
Overflows saturate to
either the minimum
or maximum value
An overflow associated
with a signed 8-bit
2-533
Discrete Transfer Fcn
Action
Do not select
this check
box.
Reasons for Taking
This Action
What Happens for
Overflows
Example
saturation protection
in the generated code.
that the data type can
represent.
integer can saturate to
–128 or 127.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
–126.
You want to avoid
overspecifying how
a block handles
out-of-range signals.
For more information,
see “Checking for
Signal Range Errors”.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result.
Usually, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
The State Attributes pane of the Discrete Filter block dialog box
appears as follows.
2-534
Discrete Transfer Fcn
State name
Use this parameter to assign a unique name to the block state.
The default is ' '. When this field is blank, no name is assigned.
When using this parameter, remember these considerations:
• A valid identifier starts with an alphabetic or underscore
character, followed by alphanumeric or underscore characters.
2-535
Discrete Transfer Fcn
• The state name applies only to the selected block.
This parameter enables State name must resolve to Simulink
signal object when you click Apply.
For more information, see “States” in the Simulink Coder
documentation.
State name must resolve to Simulink signal object
Select this check box to require that the state name resolve to a
Simulink signal object. This check box is cleared by default.
State name enables this parameter.
Selecting this check box disables Code generation storage
class.
Package
Select a package that defines the custom storage class you want
to apply. If you have defined any packages of your own, click
Refresh. This action adds all user-defined packages on your
search path to the package list.
Code generation storage class
From the list, select a state storage class.
Auto
Auto is the storage class to use for states that do not need
to interface to external code.
ExportedGlobal
The state is stored in a global variable.
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
State name enables this parameter.
2-536
Discrete Transfer Fcn
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage
type qualifier.
Code generation storage type qualifier
Specify a Simulink Coder storage type qualifier. The default is '
'. When this field is blank, no qualifier is assigned.
The Simulink Coder product does not check this string for errors.
Thus, whatever value you enter appears automatically in the
variable declaration.
Setting Code generation storage class to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables this
parameter.
During simulation, the block uses the following values:
• The initial value of the signal object to which the state name resolves
• Minimum and maximum values of the signal object
For more information, see “States” in the Simulink Coder
documentation.
Characteristics Direct Feedthrough
Only when the leading numerator
coefficient is not equal to zero and the
numerator order equals the denominator
order
Sample Time
Specified in the Sample time parameter
Scalar Expansion
Yes, of initial states
States
See “Specifying Initial States” on page
2-518
2-537
Discrete Transfer Fcn
2-538
Dimensionalized
Yes
Zero-Crossing Detection
No
Discrete Zero-Pole
Purpose
Model system defined by zeros and poles of discrete transfer function
Library
Discrete
Description
The Discrete Zero-Pole block models a discrete system defined by
the zeros, poles, and gain of a z-domain transfer function. This block
assumes that the transfer function has the following form:
H ( z) = K
( z − Z1 )( z − Z2 )...( z − Zm )
Z ( z)
=K
,
P ( z)
( z − P1 )( z − P2 )...( z − Pn )
where Z represents the zeros vector, P the poles vector, and K the gain.
The number of poles must be greater than or equal to the number of
zeros (n ≥ m). If the poles and zeros are complex, they must be complex
conjugate pairs.
The block displays the transfer function depending on how the
parameters are specified. See Zero-Pole for more information.
Data Type
Support
The Discrete Zero-Pole block accepts and outputs real signals of type
double and single. For more information, see “Data Types Supported
by Simulink” in the Simulink documentation.
2-539
Discrete Zero-Pole
Parameters
and
Dialog
Box
Zeros
Specify the matrix of zeros. The default is [1].
Poles
Specify the vector of poles. The default is [0 0.5].
Gain
Specify the gain. The default is 1.
2-540
Discrete Zero-Pole
Sample time
Specify the time interval between samples. See Specifying Sample
Time in the “How Simulink Works” chapter of the Simulink
documentation.
The State Attributes pane of the Discrete Zero-Pole block dialog box
appears as follows:
2-541
Discrete Zero-Pole
State name
Use this parameter to assign a unique name to the block state.
The default is ' '. When this field is blank, no name is assigned.
When using this parameter, remember these considerations:
• A valid identifier starts with an alphabetic or underscore
character, followed by alphanumeric or underscore characters.
• The state name applies only to the selected block.
This parameter enables State name must resolve to Simulink
signal object when you click Apply.
For more information, see “States” in the Simulink Coder
documentation.
State name must resolve to Simulink signal object
Select this check box to require that the state name resolve to a
Simulink signal object. This check box is cleared by default.
State name enables this parameter.
Selecting this check box disables Code generation storage
class.
Package
Select a package that defines the custom storage class you want
to apply. If you have defined any packages of your own, click
Refresh. This action adds all user-defined packages on your
search path to the package list.
Code generation storage class
From the list, select a state storage class.
Auto
Auto is the storage class to use for states that do not need
to interface to external code.
ExportedGlobal
The state is stored in a global variable.
2-542
Discrete Zero-Pole
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
State name enables this parameter.
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage
type qualifier.
Code generation storage type qualifier
Specify a Simulink Coder storage type qualifier. The default is '
'. When this field is blank, no qualifier is assigned.
The Simulink Coder product does not check this string for errors.
Thus, whatever value you enter appears automatically in the
variable declaration.
Setting Code generation storage class to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables this
parameter.
During simulation, the block uses the following values:
• The initial value of the signal object to which the state name is
resolved
• Min and Max values of the signal object
For more information, see “States” in the Simulink Coder
documentation.
2-543
Discrete Zero-Pole
Characteristics Direct Feedthrough
2-544
Yes, if the number of zeros and poles are
equal
Sample Time
Specified in the Sample time parameter
Scalar Expansion
No
States
Length of Poles vector
Dimensionalized
No
Zero Crossing
No
Display
Purpose
Show value of input
Library
Sinks
Description
Format Options
You control the display format using the Format parameter:
If you select...
The block displays...
short
A 5-digit scaled value with fixed
decimal point
long
A 15-digit scaled value with fixed
decimal point
short_e
A 5-digit value with a floating
decimal point
long_e
A 16-digit value with a floating
decimal point
bank
A value in fixed dollars and cents
format (but with no $ or commas)
hex (Stored Integer)
The stored integer value of a
fixed-point input in hexadecimal
format
binary (Stored Integer)
The stored integer value of a
fixed-point input in binary format
2-545
Display
If you select...
The block displays...
decimal (Stored Integer)
The stored integer value of a
fixed-point input in decimal
format
octal (Stored Integer)
The stored integer value of a
fixed-point input in octal format
If the input to a Display block has an enumerated data type (see “About
Simulink Enumerations” and “Define Simulink Enumerations”):
• The block displays enumerated values, not the values of underlying
integers.
• Setting Format to any of the Stored Integer settings causes an
error.
Display Abbreviations
The following abbreviations appear on the Display block to help you
identify the format of the value.
When you see...
The value that appears is...
(SI)
The stored integer value
Note (SI) does not appear when the signal is
of an integer data type.
2-546
hex
In hexadecimal format
bin
In binary format
oct
In octal format
Display
Frequency of Data Display
The amount of data that appears and the time steps at which the
data appears depend on the Decimation block parameter and the
SampleTime property:
• The Decimation parameter enables you to display data at every nth
sample, where n is the decimation factor. The default decimation, 1,
displays data at every time step.
Note The Display block updates its display at the initial time, even
when the Decimation value is greater than one.
• The SampleTime property, which you can set with set_param, enables
you to specify a sampling interval at which to display points. This
property is useful when you are using a variable-step solver where
the interval between time steps is not the same. The default sample
time, -1, causes the block to ignore the sampling interval when
determining the points to display.
Resizing Options
If the block input is an array, you can resize the block to show more
than just the first element. You can resize the block vertically or
horizontally, and the block adds display fields in the appropriate
direction. A black triangle indicates that the block is not displaying
all input array elements.
The Display block shows the first 200 elements of a vector signal and
the first 20 rows and 10 columns of a matrix signal.
Floating Display
To use the block as a floating display, select the Floating display
check box. The block input port disappears and the block displays the
value of the signal on a selected line.
If you select Floating display:
2-547
Display
• Turn off signal storage reuse for your model. See “Signal storage
reuse” in the Simulink documentation for more information.
• Do not connect a multidimensional signal to a floating display.
Otherwise, you get a simulation error because the block does not
support multidimensional signals.
Data Type
Support
The Display block accepts real or complex signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-548
Display
Parameters
and
Dialog
Box
Format
Specify the format of the data that appears, as discussed in
“Format Options” on page 2-545. The default is short.
Decimation
Specify how often to display data, as discussed in “Frequency of
Data Display” on page 2-547. The default is 1.
Floating display
Select to use the block as a floating display, as discussed in
“Floating Display” on page 2-547.
2-549
Display
Examples
The sldemo_auto_climatecontrol model shows how you can use the
Display block.
Characteristics Sample Time
See Also
2-550
Use set_param to specify the SampleTime
property
Dimensionalized
Yes
Multidimensionalized
No
Zero-Crossing Detection
No
Scope
Divide
Purpose
Divide one input by another
Library
Math Operations
Description
Supported Block Operations
The Divide block outputs the result of dividing its first input by
its second. The inputs can be scalars, a scalar and a nonscalar, or
two nonscalars that have the same dimensions. The Divide block is
functionally a Product block that has two block parameter values preset:
• Multiplication: Element-wise(.*)
• Number of Inputs: */
Setting non-default values for either of those parameters can change
a Divide block to be functionally equivalent to a Product block or a
Product of Elements block. See the documentation of those two blocks
for more information.
Expected Differences Between Simulation and Code
Generation
The generated code might not produce the exact same pattern of NaN
and inf values as simulation when these values are mathematically
meaningless. For example, if the simulation output contains a NaN,
output from the generated code also contains a NaN, but not necessarily
in the same place.
Code Optimizations
The Simulink Coder build process provides efficient code for matrix
inverse and division operations. The following summary describes the
benefits and when each benefit is available:
2-551
Divide
Benefit
Small
matrices
(2-by-2 to
5-by-5)
Medium
matrices
(6-by-6 to
20-by-20)
Large
matrices
(larger than
20-by-20)
Faster code
execution time,
compared to
R2011a and
earlier releases
Yes
No
Yes
Reduced
ROM and
RAM usage,
compared to
R2011a and
earlier releases
Yes, for real
values
Yes, for real
values
Yes, for real
values
Reuse of
variables
Yes
Yes
Yes
Dead code
elimination
Yes
Yes
Yes
Constant
folding
Yes
Yes
Yes
Expression
folding
Yes
Yes
Yes
Consistency
with MATLAB
Coder results
Yes
Yes
Yes
For blocks that have three or more inputs of different dimensions, the
code might include an extra buffer to store temporary variables for
intermediate results.
2-552
Divide
Parameters
and
Dialog
Box
The Divide block has the same parameters and dialog box as the
Product block. If all you need is to divide two inputs to create an output,
you can use the Divide block with default parameter values. If you need
additional capabilities, see the Product block documentation, which
also describes the capabilities of the Divide block’s “Signal Attributes
Pane” on page 2-1308.
Examples
The following examples show the output of the Divide block for some
typical inputs using default block parameter values.
2-553
DocBlock
Purpose
Create text that documents model and save text with model
Library
Model-Wide Utilities
Description
The DocBlock allows you to create and edit text that documents a
model, and save that text with the model. Double-clicking an instance
of the block creates a temporary file containing the text associated with
this block and opens the file in an editor. Use the editor to modify the
text and save the file. Simulink software stores the contents of the
saved file in the model file.
The DocBlock supports HTML, Rich Text Format (RTF), and ASCII
text document types. The default editors for these different document
types are
• HTML — Microsoft® Word (if available). Otherwise, the DocBlock
opens HTML documents using the editor specified on the
Editor/Debugger Preferences pane of the Preferences dialog box.
• RTF — Microsoft Word (if available). Otherwise, the DocBlock opens
RTF documents using the editor specified on the Editor/Debugger
Preferences pane of the Preferences dialog box.
• Text — The DocBlock opens text documents using the editor specified
on the Editor/Debugger Preferences pane of the Preferences
dialog box.
Use the docblock command to change the default editors.
Data Type
Support
2-554
Not applicable.
DocBlock
Parameters
and
Dialog
Box
Double-clicking an instance of the DocBlock opens an editor. To access
the DocBlock parameter dialog box, select the block in the Model Editor
and then select Mask Parameters from either the Edit menu or the
block’s context menu.
Code generation template symbol (Embedded Coder™ license
required)
Enter a template symbol name in this field. Embedded Coder
software uses this symbol to add comments to the code generated
from the model. For more information, see “Add Global
Comments”.
Document type
Select the type of document associated with the DocBlock. The
options are:
• Text (the default)
2-555
DocBlock
• RTF
• HTML
Note If you are using a DocBlock to add comments to your code
during code generation, ensure that you set the Document Type
as Text. If you set the Document Type as RTF or HTML, your
comments will not appear in the code.
Characteristics Not applicable
2-556
Dot Product
Purpose
Generate dot product of two vectors
Library
Math Operations
Description
The Dot Product block generates the dot product of the vectors at its
inputs. The scalar output, y, is equal to the MATLAB operation
y = sum(conj(u1) .* u2 )
where u1 and u2 represent the vectors at the block’s top and bottom
inputs, respectively. (See “How to Rotate a Block” in the Simulink
documentation for a description of the port order for various block
orientations.) The inputs can be vectors, column vectors (single-column
matrices), or scalars. If both inputs are vectors or column vectors, they
must be the same length. If u1 and u2 are both column vectors, the
block outputs the equivalent of the MATLAB expression u1'*u2.
The elements of the input vectors can be real- or complex-valued
signals. The signal type (complex or real) of the output depends on the
signal types of the inputs.
Input 1
Input 2
Output
real
real
real
real
complex
complex
complex
real
complex
complex
complex
complex
To perform element-by-element multiplication without summing, use
the Product block.
Data Type
Support
The Dot Product block accepts and outputs signals of any numeric data
type that Simulink supports, including fixed-point data types.
For more information, see “Data Types Supported by Simulink”.
2-557
Dot Product
Parameters
and
Dialog
Box
The Main pane of the Dot Product block dialog box appears as follows:
The Signal Attributes pane of the Dot Product block dialog box
appears as follows:
2-558
Dot Product
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink documentation for more information.
Require all inputs to have same data type
Select to require all inputs to have the same data type.
2-559
Dot Product
Output minimum
Specify the minimum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output maximum
Specify the maximum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output data type
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output data type parameter.
See “Specify Block Output Data Types” for more information.
2-560
Dot Product
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow,
and you want explicit
saturation protection
in the generated code.
Overflows saturate to
either the minimum
or maximum value
that the data type can
represent.
An overflow associated
with a signed 8-bit
integer can saturate to
–128 or 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
–126.
You want to avoid
overspecifying how
a block handles
out-of-range signals.
For more information,
see “Checking for
Signal Range Errors”.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result.
Usually, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
2-561
Dot Product
Characteristics Direct Feedthrough
See Also
2-562
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
No
States
0
Dimensionalized
Yes
Zero-Crossing Detection
No
Product
Enable
Purpose
Add enabling port to system
Library
Ports & Subsystems
Description
Adding an Enable block to a subsystem or at the root level of a model
makes it an enabled system. A subsystem can contain no more than one
Enable block. An enabled system executes while the input received at
the Enable port is greater than zero.
At the start of a simulation, Simulink software initializes the states of
blocks inside an enabled system to their initial conditions.
If you use an enable port for a root-level model:
• For multi-rate enabled models, set the solver to single-tasking.
• If the enabled model has a fixed-step size, at least one block in that
model must run at that fixed-step size rate.
The Enable block supports signal label propagation.
Data Type
Support
The Enable block accepts signals of supported Simulink numeric data
types, including fixed-point data types. For more information, see “Data
Types Supported by Simulink”.
2-563
Enable
Parameters
and
Dialog
Box
The Main pane of the Enable block dialog box appears as follows:
Placing the Enable block at the root of a model enables the Signal
Attributes pane:
2-564
Enable
• “States when enabling” on page 2-567
• “Propagate sizes of variable-size signals” on page 2-568
• “Show output port” on page 2-569
• “Enable zero-crossing detection” on page 2-570
• “Port dimensions” on page 2-571
2-565
Enable
• “Sample time” on page 2-572
• “Minimum” on page 2-1886
• “Maximum” on page 2-1887
• “Data type” on page 2-575
• “Show data type assistant” on page 2-1665
• “Mode” on page 2-578
• “Interpolate data” on page 2-580
2-566
Enable
States when enabling
At the instant when an enabled system is being disabled, specify what
happens to the states of blocks in the enabled system.
Settings
Default: held
held
Holds the states at their previous values.
reset
Resets the states to their initial conditions (zero if not defined).
Command-Line Information
Parameter: StatesWhenEnabling
Type: string
Value: 'held' | 'reset'
Default: 'held'
2-567
Enable
Propagate sizes of variable-size signals
Specify when to propagate a variable-size signal.
Settings
Default: Only when enabling
Only when enabling
Propagates variable-size signals only when reenabling the system
containing the Enable Port block. When you select this option,
sample time must be periodic.
During execution
Propagates variable-size signals at each time step.
Command-Line Information
Parameter: PropagateVarSize
Type: string
Value: 'Only when enabling' | 'During execution'
Default: 'Only when enabling'
2-568
Enable
Show output port
Select this check box to output the enabling signal.
Settings
Default: On
On
Shows the Enable block output port and outputs the enabling
signal. Selecting this option allows the system to process the
enabling signal.
Off
Removes the output port from the Enable block.
Command-Line Information
Parameter: ShowOutputPort
Type: string
Value: 'on' | 'off'
Default: 'on'
2-569
Enable
Enable zero-crossing detection
Select this check box to enable zero-crossing detection.
Settings
Default: On
On
Detect zero crossings.
Off
Do not detect zero crossings.
Command-Line Information
Parameter: ZeroCross
Type: string
Value: 'on' | 'off'
Default: 'on'
2-570
Enable
Port dimensions
Specify the dimensions of the input signal to the block.
Settings
Default: 1
Valid values are:
n
Vector signal of width n accepted
[m n]
Matrix signal having m rows and n columns accepted
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-571
Enable
Sample time
Specify the time interval between samples.
Settings
Default: -1
See “Specify Sample Time” in the online documentation for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-572
Enable
Minimum
Specify the minimum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the minimum value for bus data on the block. Simulink ignores
this setting. Instead, set the minimum values for bus elements of the
bus object specified as the data type. For information on the Minimum
property of a bus element, see Simulink.BusElement.
Simulink software uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-573
Enable
Maximum
Specify the maximum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the maximum value for bus data on the block. Simulink ignores this
setting. Instead, set the maximum values for bus elements of the bus
object specified as the data type. For information on the Maximum
property of a bus element, see Simulink.BusElement.
Simulink software uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-574
Enable
Data type
Specify the output data type of the external input.
Settings
Default: double
double
Data type is double.
single
Data type is single.
int8
Data type is int8.
uint8
Data type is uint8.
int16
Data type is int16.
uint16
Data type is uint16.
int32
Data type is int32.
uint32
Data type is uint32.
boolean
Data type is boolean.
fixdt(1,16,0)
Data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Data type is fixed point fixdt(1,16,2^0,0).
<data type expression>
The name of a data type object, for example
Simulink.NumericType
2-575
Enable
Do not specify a bus object as the expression.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-576
Enable
Show data type assistant
Display the Data Type Assistant.
Settings
The Data Type Assistant helps you set the Output data type
parameter.
For more information, see “Specify Block Output Data Types”.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-577
Enable
Mode
Select the category of data to specify.
Settings
Default: double
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
• boolean
Fixed point
Fixed-point data types.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
Do not specify a bus object as the expression.
Dependency
Clicking the Show data type assistant button enables this parameter.
2-578
Enable
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-579
Enable
Interpolate data
Cause the block to interpolate or extrapolate output at time steps for
which no corresponding workspace data exists when loading data from
the workspace.
Settings
Default: On
On
Cause the block to interpolate or extrapolate output at time steps
for which no corresponding workspace data exists when loading
data from the workspace.
Off
Do not cause the block to interpolate or extrapolate output at time
steps for which no corresponding workspace data exists when
loading data from the workspace.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Characteristics Sample Time
Determined by the signal at the enable
port
Dimensionalized
Yes
Virtual
Yes, if not connected directly to an
Outport block
For more information, see
“Virtual Blocks” in the Simulink
documentation.
Zero-Crossing Detection
2-580
Yes, if enabled
Enabled and Triggered Subsystem
Purpose
Represent subsystem whose execution is enabled and triggered by
external input
Library
Ports & Subsystems
Description
This block is a Subsystem block that is preconfigured to serve as the
starting point for creating an enabled and triggered subsystem. For
more information, see “Triggered and Enabled Subsystems” in the
online Simulink help.
2-581
Enabled Subsystem
Purpose
Represent subsystem whose execution is enabled by external input
Library
Ports & Subsystems
Description
This block is a Subsystem block that is preconfigured to serve as the
starting point for creating an enabled subsystem. For more information,
see “Enabled Subsystems” in the “Creating a Model” chapter of the
Simulink documentation.
2-582
Enumerated Constant
Purpose
Generate enumerated constant value
Library
Sources
Description
The Enumerated Constant block outputs a scalar, array, or matrix of
enumerated values. You can also use the Constant block to output
enumerated values, but it provides block parameters that do not
apply to enumerated types, such as Output minimum and Output
maximum. When you need a block that outputs only constant
enumerated values, preferably use Enumerated Constant rather than
Constant. For more information, see “About Simulink Enumerations”.
Data Type
Support
The Enumerated Constant block supports only enumerated data types.
Use the Constant block to output constant data of other types. For more
information, see “Data Types Supported by Simulink”.
2-583
Enumerated Constant
Parameters
and
Dialog
Box
The Enumerated Constant block dialog box initially appears as follows:
Output data type
The Output data type field specifies the enumerated type from which
you want the block to output one or more values. The initial value,
Enum: SlDemoSign, is a dummy enumerated type that prevents a newly
cloned block from causing an error. To specify the desired enumerated
type, select it from the pulldown or enter Enum: ClassName in the
Output data type field, where ClassName is the name of the MATLAB
class that defines the type.
2-584
Enumerated Constant
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Value
The Value field specifies the value(s) that the block outputs. The
output of the block has the same dimensions and elements as the Value
parameter. The initial value, SlDemoSign.Positive, is a dummy
enumerated value that prevents a newly cloned block from causing
an error.
To specify the desired enumerated value(s), select from the pulldown
or enter any MATLAB expression that evaluates to the desired result,
including an expression that uses tunable parameters. All values
specified must be of the type indicated by the Output data type. To
specify an array that includes every value in the enumerated type, use
the enumeration function.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Sample time
Specify the interval between times that the Constant block output can
change during simulation (for example, due to tuning the Constant
value parameter).
Settings
Default: inf
This setting indicates that the block output can never change. This
setting speeds simulation and generated code by avoiding the need
to recompute the block output. See “Specify Sample Time” for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-585
Enumerated Constant
Characteristics Direct Feedthrough
2-586
N/A
Sample Time
Specified in the Sample time parameter
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Environment Controller
Purpose
Create branches of block diagram that apply only to simulation or only
to code generation
Library
Signal Routing
Description
This block outputs the signal at its Sim port only if the model that
contains it is being simulated. It outputs the signal at its Coder port
only if code is being generated from the model. This option enables you
to create branches of a block diagram that apply only to simulation or
code generation. The table below describes various scenarios where
either the Sim or Coder port applies.
Scenario
Output
Normal mode simulation
Sim
Accelerator mode simulation
Sim
Rapid Accelerator mode
simulation
Coder
Simulation of a referenced model
(Normal or Accelerator modes)
Sim
Simulation of a referenced model
(Processor-in-the-loop (PIL)
mode)
Coder
(uses the same code generated for
a referenced model)
External mode simulation
Coder
Standard code generation
Coder
Code generation of a referenced
model
Coder
2-587
Environment Controller
Simulink Coder software does not generate code for blocks connected to
the Sim port if these conditions hold:
• You select the Inline parameters check box on the Optimization
> Signals and Parameters pane of the Configuration Parameters
dialog box.
• The blocks connected to the Sim port do not have external signals.
• The Sim port input path does not contain a MATLAB S-function or
an Interpreted MATLAB Function block.
If you enable block reduction optimization, Simulink eliminates blocks
in the branch connected to the Coder port when compiling the model
for simulation. For information about block reduction, see “Block
reduction” in the online Simulink documentation.
Note Simulink Coder code generation eliminates the blocks connected
to the Sim branch only if the Sim branch has the same signal
dimensions as the Coder branch. Regardless of whether it eliminates
the Sim branch, Simulink Coder uses the sample times on the Sim
branch as well as the Coder branch to determine the fundamental
sample time of the generated code and might, in some cases, generate
sample-time handling code that applies only to sample times specified
on the Sim branch.
Data Type
Support
The Environment Controller block accepts signals of any data type that
Simulink supports. The output uses the same data type as the input.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-588
Environment Controller
Parameters
and
Dialog
Box
Characteristics Multidimensionalized
Yes
2-589
Extract Bits
Purpose
Output selection of contiguous bits from input signal
Library
Logic and Bit Operations
Description
The Extract Bits block allows you to output a contiguous selection of
bits from the stored integer value of the input signal. Use the Bits to
extract parameter to define the method for selecting the output bits.
• Select Upper half to output the half of the input bits that contain
the most significant bit. If there is an odd number of bits in the input
signal, the number of output bits is given by the equation
number of output bits = ceil(number of input bits/2)
• Select Lower half to output the half of the input bits that contain
the least significant bit. If there is an odd number of bits in the input
signal, the number of output bits is given by the equation
number of output bits = ceil(number of input bits/2)
• Select Range starting with most significant bit to output
a certain number of the most significant bits of the input signal.
Specify the number of most significant bits to output in the Number
of bits parameter.
• Select Range ending with least significant bit to output a
certain number of the least significant bits of the input signal.
Specify the number of least significant bits to output in the Number
of bits parameter.
2-590
Extract Bits
• Select Range of bits to indicate a series of contiguous bits of the
input to output in the Bit indices parameter. You indicate the range
in [start end] format, and the indices of the input bits are labeled
contiguously starting at 0 for the least significant bit.
Data Type
Support
The Extract Bits block accepts inputs of any numeric data type that
Simulink supports, including fixed-point data types. Floating-point
inputs are passed through the block unchanged. Boolean inputs are
treated as uint8 signals.
Note Performing bit operations on a signed integer is difficult. You
can avoid difficulty by converting the data type of your input signals
to unsigned integer types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-591
Extract Bits
Parameters
and
Dialog
Box
Bits to extract
Select the method for extracting bits from the input signal.
Number of bits
(Not shown on dialog above.) Select the number of bits to output
from the input signal. Signed integer data types can have no
less then two bits in them. Unsigned data integer types can be
as short as a single bit.
This parameter is only visible if you select Range starting
with most significant bit or Range ending with least
significant bit for the Bits to extract parameter.
Bit indices
(Not shown on dialog above.) Specify a contiguous range of bits
of the input signal to output. Specify the range in [start end]
format. The indices are assigned to the input bits starting with 0
at the least significant bit.
2-592
Extract Bits
This parameter is only visible if you select Range of bits for
the Bits to extract parameter.
Output scaling mode
Select the scaling mode to use on the output bits selection:
• When you select Preserve fixed-point scaling, the fixed-point
scaling of the input is used to determine the output scaling during
the data type conversion.
• When you select Treat bit field as an integer, the fixed-point
scaling of the input is ignored, and only the stored integer is used to
compute the output data type.
Example
Consider an input signal that is represented in binary by 110111001:
• If you select Upper half for the Bits to extract parameter, the
output is 11011 in binary.
• If you select Lower half for the Bits to extract parameter, the
output is 11001 in binary.
• If you select Range starting with most significant bit for the
Bits to extract parameter, and specify 3 for the Number of bits
parameter, the output is 110 in binary.
• If you select Range ending with least significant bit for the
Bits to extract parameter, and specify 8 for the Number of bits
parameter, the output is 10111001 in binary.
• If you select Range of bits for the Bits to extract parameter, and
specify [4 7] for the Bit indices parameter, the output is 1011 in
binary.
Characteristics Direct Feedthrough
Yes
Sample Time
Inherited
Scalar Expansion
N/A
2-593
Extract Bits
2-594
States
None
Dimensionalized
Inherited
Multidimensionalized
Yes
Zero Crossing
No
Fcn
Purpose
Apply specified expression to input
Library
User-Defined Functions
Description
The Fcn block applies the specified mathematical expression to its
input. The expression can include one or more of these components:
• u — The input to the block. If u is a vector, u(i) represents the ith
element of the vector; u(1) or u alone represents the first element.
• Numeric constants
• Arithmetic operators (+ - * / ^)
• Relational operators (== != > < >= <=) — The expression returns 1
if the relation is true; otherwise, it returns 0.
• Logical operators (&& || !) — The expression returns 1 if the
relation is true; otherwise, it returns 0.
• Parentheses
• Mathematical functions — abs, acos, asin, atan, atan2, ceil, cos,
cosh, exp, fabs, floor, hypot, ln, log, log10, pow, power, rem, sgn,
sin, sinh, sqrt, tan, and tanh.
Note The Fcn block does not support round and fix. Use the
Rounding Function block to apply these rounding modes.
• Workspace variables — Variable names that are not recognized in
the preceding list of items are passed to MATLAB for evaluation.
Matrix or vector elements must be specifically referenced (e.g.,
A(1,1) instead of A for the first element in the matrix).
2-595
Fcn
The Fcn block observes the following rules of operator precedence:
1 ( )
2 ^
3 + - (unary)
4 !
5 * /
6 + 7 > < <= >=
8 == !=
9 &&
10 ||
The expression differs from a MATLAB expression in that the
expression cannot perform matrix computations. Also, this block does
not support the colon operator (:).
Block input can be a scalar or vector. The output is always a scalar. For
vector output, consider using the Math Function block. If a block input
is a vector and the function operates on input elements individually
(for example, the sin function), the block operates on only the first
vector element.
Data Type
Support
2-596
The Fcn block accepts and outputs signals of type single or double.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Fcn
Parameters
and
Dialog
Box
Expression
Specify the mathematical expression to apply to the input.
Expression components are listed above. The expression must be
mathematically well-formed (uses matched parentheses, proper
number of function arguments, and so on).
Note You cannot tune this expression during simulation in
Normal or Accelerator mode (see “How Acceleration Modes
Work”), or in generated code.
The Fcn block does not support custom storage classes. See
“Custom Storage Classes” in the Embedded Coder documentation.
2-597
Fcn
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
online documentation for more information.
Examples
The following example models show how to use the Fcn block:
• sldemo_absbrake
• sldemo_enginewc (Throttle & Manifold/Throttle subsystem)
Characteristics Direct Feedthrough
2-598
Yes
Sample Time
Inherited from the driving block
Scalar Expansion
No
Dimensionalized
No
Multidimensionalized
No
Zero-Crossing Detection
No
Find
Purpose
Find nonzero elements in array
Library
Math Operations
Description
The Find block locates all nonzero elements of the input signal
and returns the linear indices of those elements. If the input is a
multidimensional signal, the Find block can also return the subscripts
of the nonzero input elements. In both cases, you can show an output
port with the nonzero input values.
Data Type
Support
The Find block accepts and outputs real values of any numeric data
type that Simulink supports.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-599
Find
Parameters
and
Dialog
Box
The Main pane of the Find block dialog box appears as follows:
The Signal Attributes pane of the Find block dialog appears as follows:
2-600
Find
• “Index output format” on page 2-604
• “Number of input dimensions” on page 2-605
• “Index mode” on page 2-606
• “Show output port for nonzero input values” on page 2-607
• “Sample time (-1 for inherited)” on page 2-608
• “Output data type” on page 2-609
• “Mode” on page 2-611
• “Data type override” on page 2-1892
• “Signedness” on page 2-614
2-601
Find
• “Word length” on page 2-615
• “Scaling” on page 2-616
2-602
Find
2-603
Find
Index output format
Select the output format for the indices of the nonzero input values.
Settings
Default: Linear indices
Linear indices
Provides the element indices of any dimension signal in a vector
form. For one dimension (vector) signals, indices correspond to
the position of nonzero values within the vector. For signals with
more than one dimension, the conversion of subscripts to indices
is along the first dimension. You do not need to know the signal
dimension of the input signal.
Subscripts
Provides the element indices of a two-dimension or larger signal
in a subscript form. Because the block shows an output port for
each dimension, this option requires you to know the number of
dimensions for the input signal.
Dependencies
Selecting Subscripts from the Index output format list enables the
Number of input dimensions parameter.
Command-Line Information
Parameter: IndexOutputFormat
Type: string
Value: Linear indices | Subscripts
Default: Linear indices
2-604
Find
Number of input dimensions
Specify the number of dimensions for the input signal.
Settings
Default: 1
Minimum: 1
Maximum: 32
Dependencies
Selecting Subscripts from the Index output format list enables this
parameter.
Command-Line Information
Parameter: NumberOfInputDimensions
Type: int
Value: positive integer value
Default: 1
2-605
Find
Index mode
Specify the indexing mode.
Settings
Default: Zero-based
Zero-based
An index of 0 specifies the first element of the input vector. An
index of 1 specifies the second element, and so on.
One-based
An index of 1specifies the first element of the input vector. An
index of 2, specifies the second element , and so on.
Command-Line Information
Parameter: IndexMode
Type: string
Value: Zero-based | One-based
Default: Zero-based
2-606
Find
Show output port for nonzero input values
Show or hide the output port for nonzero input values.
Settings
Default: Off
On
Display the output port for nonzero input values. The additional
output port provides the values of the nonzero input elements.
Off
Hide the output port for nonzero input values.
Command-Line Information
Parameter: ShowOutputPortForNonzeroInputValues
Type: string
Value: 'on' | 'off'
Default: 'off'
2-607
Find
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample time,
set this parameter to -1. See “Specify Sample Time” in the “How
Simulink Works” chapter of the Simulink documentation.
Command-Line Information
Parameter: SampleTime
Type: string
Value: -1 (for inherited)| positive number
Default: -1
2-608
Find
Output data type
Specify the output data type.
Settings
Default: Inherit:
Inherit:
Inherit via internal rule
Inherit via internal rule
Output data type is defined by the target.
int8
Output data type is int8.
uint8
Output data type is uint8.
int16
Output data type is int16.
uint16
Output data type is uint16.
int32
Output data type is int32.
uint32
Output data type is unt32.
fixdt(1,16)
Output data type is fixed point, fixdt(1,16).
<data type expression>
Use a data type object, for example, Simulink.NumericType.
Click the Show data type assistant button
to display
additional parameters for the Output data type parameter.
Command-Line Information
Parameter: OutDataTypeStr
Type: string
2-609
Find
Value: 'Inherit: Inherit via internal rule' | 'int8'
| 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32'|
'fixdt(1,16)'| '<data type expression>'
Default: 'Inherit:
Inherit via internal rule'
See Also
“Specify Block Output Data Types”, “Specify Data Types Using Data
Type Assistant”
2-610
Find
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second list of the possible values:
• Inherit via internal rule (Discrete-Time Integrator, Gain,
Product, Sum, Switch block default)
Built in
Built-in data types. Selecting Built in enables a second list of
the possible values:
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Fixed-point data types.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second text box, where you can enter the expression.
Dependencies
Clicking the Show data type assistant button enables this parameter.
Selecting Fixed point from the Mode list enables the following
parameters:
• Signed
2-611
Find
• Scaling
• Word length
See Also
“Specify Data Types Using Data Type Assistant”
2-612
Find
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-613
Find
Signedness
Specify whether the fixed-point data is signed or unsigned.
Settings
Default: Signed
Signed
Specifies the fixed-point data as signed.
Unsigned
Specifies the fixed-point data as unsigned.
Dependency
Selecting Fixed point from the Mode list enables this parameter.
2-614
Find
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Large word sizes represent large values with greater precision than
small word sizes.
Dependency
Selecting Fixed point from the Mode list enables this parameter.
2-615
Find
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Integer
Integer
Specifies a binary point location for fixed-point data and sets the
fraction length to 0.
The Scaling list has only one item for you to select.
Dependency
Selecting Fixed point from the Mode list enables this parameter.
Characteristics Direct Feedthrough
2-616
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
First-Order Hold
Purpose
Implement first-order sample-and-hold
Library
Discrete
Description
The First-Order Hold block implements a first-order sample-and-hold
that operates at the specified sampling interval. This block has little
value in practical applications and is included primarily for academic
purposes.
This figure compares the output from a Sine Wave block and a
First-Order Hold block.
Data Type
Support
The First-Order Hold block accepts and outputs signals of type double.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-617
First-Order Hold
Parameters
and
Dialog
Box
Sample time
The time interval between samples. See “Specify Sample Time” in
the online documentation for more information.
Characteristics Direct Feedthrough
See Also
2-618
No
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
No
States
1 continuous and 1 discrete per input
element
Dimensionalized
Yes
Zero Crossing
No
Zero-Order Hold
Fixed-Point State-Space
Purpose
Implement discrete-time state space
Library
Additional Math & Discrete / Additional Discrete
Description
The Fixed-Point State-Space block implements the system described by
y(n) = Cx(n) + Du(n)
x(n+1) = Ax(n) + Bu(n)
where u is the input, x is the state, and y is the output. Both equations
have the same data type.
The matrices A, B, C and D have the following characteristics:
• A must be an n-by-n matrix, where n is the number of states.
• B must be an n-by-m matrix, where m is the number of inputs.
• C must be an r-by-n matrix, where r is the number of outputs.
• D must be an r-by-m matrix.
In addition:
• The state x must be an n-by-1 vector.
• The input u must be an m-by-1 vector.
• The output y must be an r-by-1 vector.
2-619
Fixed-Point State-Space
The block accepts one input and generates one output. The block
determines the input vector width by the number of columns in the B
and D matrices. Similarly, the block determines the output vector width
by the number of rows in the C and D matrices.
Data Type
Support
The Fixed-Point State-Space block accepts signals of the following
data types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-620
Fixed-Point State-Space
Parameters
and
Dialog
Box
The Main pane of the Fixed-Point State-Space block dialog box appears
as follows:
State Matrix A
Specify the matrix of states.
Input Matrix B
Specify the column vector of inputs.
2-621
Fixed-Point State-Space
Output Matrix C
Specify the column vector of outputs.
Direct Feedthrough Matrix D
Specify the matrix for direct feedthrough.
Initial condition for state
Specify the initial condition for the state.
The Signal Attributes pane of the Fixed-Point State-Space block
dialog box appears as follows:
2-622
Fixed-Point State-Space
Data type for internal calculations
Specify the data type for internal calculations.
Scaling for State Equation AX+BU
Specify the scaling for state equations.
Scaling for Output Equation CX+DU
Specify the scaling for output equations.
2-623
Fixed-Point State-Space
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
Saturate to max or min when overflows occur
Select to have overflows saturate to the maximum or minimum
value that the data type can represent. Otherwise, overflows
wrap.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result. In
general, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
Characteristics Direct Feedthrough
See Also
2-624
Yes
Scalar Expansion
Yes, of initial conditions
Multidimensionalized
No
Zero-Crossing Detection
No
Discrete State-Space
For Each
Purpose
Enable blocks inside For Each Subsystem to process elements or
subarrays of input signal independently
Library
Ports & Subsystems
Description
The For Each block serves as a control block for the For Each Subsystem
block. Specifically, the For Each block enables the blocks inside the
For Each Subsystem to process elements or subarrays of the input
signals independently. Each block inside this subsystem that has states
maintains a separate set of states for each element or subarray it
processes. As the set of blocks in the subsystem process the elements
(or subarrays), the subsystem concatenates the results to form output
signals.
Using the For Each block, you specify how to decompose each input
signal to the subsystem into elements or subarrays by setting the
integer values of the “Partition Dimension” on page 2-632 and the
“Partition Width” on page 2-633. Similarly, you define the dimension
along which to concatenate the results by specifying the “Concatenation
Dimension” on page 2-635.
As an illustration, consider an input signal A of the form:
d2
d1
A11
A12
A13
A21
A22
A23
A31
A32
A33
The labels d1 and d2, respectively define dimension 1 and dimension 2.
If you retain the default setting of 1 for both the partition dimension
and the partition width, then Simulink slices perpendicular to partition
dimension d1 at a width equal to the partition width, one element.
2-625
For Each
Partition
dimension
set to 1
A11
A12
A13
A21
A22
A23
A31
A32
A33
Input signal A decomposes into the following three row vectors:
A11
A12
A13
A21
A22
A23
A31
A32
A33
If instead you specify d2 as the partition dimension by entering the value
2, Simulink slices perpendicular to d2 to form three column vectors:
A11
A12
A13
A21
A22
A23
A31
A32
A33
In either case, the results generated by the block for each subarray
stack along the concatenation dimension, d1 (y-axis). Whereas, if you
specify d2 by setting the concatenation dimension to 2, the results
concatenate along the d2 direction (x-axis). Thus if the process generates
row vectors, then the concatenated result is a row vector.
2-626
For Each
Parameters
and
Dialog
Box
• “Partition Input(s)” on page 2-629
• “Port” on page 2-630
2-627
For Each
• “Partition” on page 2-631
• “Partition Dimension” on page 2-632
• “Partition Width” on page 2-633
• “Concatenate Output(s)” on page 2-634
• “Port” on page 2-634
• “Concatenation Dimension” on page 2-635
2-628
For Each
Partition Input(s)
Use this table to select each input signal that you need to partition and
to specify the corresponding Partition Dimension and Partition
Width parameters.
2-629
For Each
Port
The Port column displays the input index and the name of the input
port connected to the For Each Subsystem block.
Tip
You can have any number of ports.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-630
For Each
Partition
Select the check box beside each input signal that you want to partition
into subarrays or elements.
Settings
Default: Off
On
Enables the partitioning of the input signal.
Off
Disables the partitioning of the input signal.
Dependencies
Selecting this check box enables the Partition Dimension and
Partition Width parameters.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-631
For Each
Partition Dimension
Specify the dimension through which to slice the input signal array.
The resulting slices are perpendicular to the dimension that you
specify. The slices also partition the array into subarrays or elements,
as appropriate.
Settings
Default: 1
Minimum: 1
Tip
Specify the corresponding width of each slice by setting the Partition
Width parameter for a given input port.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-632
For Each
Partition Width
Specify the width of each partition slice of the input signal.
Settings
Default: 1
Minimum: 1
Tips
• The default width of 1 represents a width of one element.
• Specify this parameter with the Partition Dimension parameter to
define fully how to create the partitioned signal.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-633
For Each
Concatenate Output(s)
For each output port, specify the dimension along which to stack
(concatenate) the For Each Subsystem results.
Port
The Port column displays the output index and the name of the output
port connected to the For Each Subsystem block.
Tip
You can have any number of ports.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-634
For Each
Concatenation Dimension
Specify the dimension along which to stack the results of the For Each
Subsystem.
Settings
Default: 1
Minimum: 1
Tips
• If you specify the default, the results stack in the d1 direction. Thus if
the block generates column vectors, the concatenation process results
in a single column vector.
• If you specify 2, the results stack in the d2 direction. Thus if the
block generates row vectors, the concatenation process results in
a single row vector.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-635
For Each
Examples
The following model demonstrates the partitioning of an input signal by
a For Each block. Each row of this 2-by-3 input array contains three
integers that represent the (x, y, z)-coordinates of a point. The goal is to
translate each of these points based on a new origin at (–20, –10, –5)
and to display the results.
By placing the process of summing an input signal and the new
origin inside of a For Each Subsystem, you can operate on each set of
coordinates by partitioning the input signal into two row vectors. To
accomplish such partitioning, use the default settings of 1 for both the
partition dimension and the partition width. If you also use the default
concatenation dimension of 1, each new set of coordinates stacks in the
d1 direction, making your display a 2-by-3 array.
Alternatively, if you specify a concatenation dimension of 2, then you get
a single row vector because each set of results stacks in the d2 direction.
This example shows how to partition an input signal. To learn how the
For Each block and subsystem handle a model with states, see the For
Each Subsystem documentation.
See Also
2-636
For Each Subsystem
For Each Subsystem
Purpose
Repeatedly perform algorithm on each element or subarray of input
signal and concatenate results
Library
Ports & Subsystems
Description
The For Each Subsystem block is useful in modeling scenarios where
you need to repeat the same algorithm for individual elements (or
subarrays) of an input signal. The set of blocks within the subsystem
represents the algorithm applied to a single element (or subarray) of
the original signal. The For Each block inside the subsystem allows you
to configure the decomposition of the subsystem inputs into elements
(or subarrays), and to configure the concatenation of the individual
results into output signals.
Inside this subsystem, each block that has states maintains separate
sets of states for each element or subarray that it processes.
Consequently, the operation of this subsystem is similar in behavior to
copying the contents of the subsystem for each element in the original
input signal and then processing each element using its respective copy
of the subsystem.
An additional benefit of the For Each Subsystem is that, for certain
models, it improves the code reuse in Simulink Coder generated code.
Consider a model containing two reusable Atomic Subsystems with
the same scalar algorithm applied to each element of the signal. If the
input signal dimensions of these subsystems are different, Simulink
Coder generated code includes two distinct functions. You can replace
these two subsystems with two identical For Each Subsystems that
are configured to process each element of their respective inputs using
the same algorithm. For this case, Simulink Coder generated code
2-637
For Each Subsystem
consists of a single function parameterized by the number of input
signal elements. This function is invoked twice — once for each unique
instance of the For Each Subsystem in the model. For each of these
cases, the input signal elements have different values.
Limitations
The For Each Subsystem block has these limitations, which you can
work around.
Limitation
Workaround
You cannot log any signals in the
subsystem.
Pull the signal outside the
subsystem using an output port
for logging.
You cannot log the states of the
blocks in the model in array
format. Also, you cannot log
the states of the blocks in the
subsystem, even if you are using
structure format.
Save and restore the simulation
state (SimState).
Reusable code is generated for
two For Each Subsystems with
identical contents if their input
and output signals are vectors (
1-D or 2-D row or column vector).
For n-D input and output signals,
reusable code is generated only
when the dimension along which
the signal is partitioned is the
highest dimension.
Permute the signal dimensions to
transform the partition dimension
and the concatenation dimension
to the highest nonsingleton
dimension for n-D signals.
The For Each Subsystem block does not support the following features:
• You cannot include the following blocks or S-functions inside a For
Each Subsystem:
2-638
For Each Subsystem
-
Data Store Memory, Data Store Read, or Data Store Write blocks
inside the subsystem
-
The From Workspace block if the input is a Structure with Time
that has an empty time field.
-
The To Workspace and To File data saving blocks
Model Reference block with simulation mode set to ’Normal’
Shadow Inports
ERT S-functions
For a complete list of the blocks that support the For Each Subsystem,
type showblockdatatypetable at the MATLAB command line.
• You cannot use the following kinds of signals:
-
Test-pointed signals or signals with an external storage class
inside the system
-
Frame signals on subsystem input and output boundaries
Variable-size signals
Function-call signals crossing the boundaries of the subsystem
• Creation of a linearization point inside the subsystem
• Setting the initial state of blocks inside the model if the format of the
data is in either of the following formats:
-
Array
Structure that includes data for a block inside of the For Each
subsystem
• Propagating the Jacobian flag for the blocks inside the
subsystem. You can check this condition in MATLAB using
J.Mi.BlockAnalyticFlags.jacobian, where J is the Jacobian object. To
verify the correctness of the Jacobian of the For Each Subsystem,
perform the following steps
2-639
For Each Subsystem
-
Look at the tag of the For Each Subsystem Jacobian. If it is
“not_supported”, then the Jacobian is incorrect.
-
Move each block out of the For Each Subsystem and calculate its
Jacobian. If any block is “not_supported” or has a warning tag, the
For Each Subsystem Jacobian is incorrect.
• You cannot perform the following kinds of code generation:
-
-
Generation of a Simulink Coder S-function target
Simulink Coder code generation under both of the following
conditions:
•
A Stateflow or MATLAB Function block resides in the
subsystem.
•
This block tries to access global data outside the subsystem,
such as Data Store Memory blocks or Simulink.Signal objects
of ExportedGlobal storage class.
HDL code generation
PLC code generation
S-Function Support
The For Each Subsystem block supports both C-MEX S-functions and
Level-2 MATLAB S-functions, provided that the S-function supports
multiple execution instances using one of the following techniques:
• A C-MEX S-function must declare
ssSupportsMultipleExecInstances(S, true) in the mdlSetWorkWidths
method.
• A Level-2 MATLAB S-function must declare
’block.SupportsMultipleExecInstances = true’ in the Setup method.
If you use the above specifications:
• Do not cache run-time data, such as DWork and Block I/O, using
global or persistent variables or within the userdata of the S-function.
2-640
For Each Subsystem
• Every S-function execution method from mdlStart up to
mdlTerminate is called once for each element processed by the
S-function, when it is in a For Each Subsystem. Consequently,
you need to be careful not to free the same memory on repeated
calls to mdlTerminate. For example, consider a C-MEX
S-function that allocates memory for a run-time parameter within
mdlSetWorkWidths. The memory only needs to be freed once in
mdlTerminate. As a solution, set the pointer to be empty after the
first call to mdlTerminate.
Data Type
Support
The For Each Subsystem block accepts real or complex signals of the
following data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Examples
of
Working
with For
Each
Subsystems
Example of Simplifying a Model
The following model uses an FIR filter to independently process each
element of the input sine wave signal, in an identical manner. The
model uses Selector blocks and three identical subsystems: Subsystem,
Subsystem1, and Subsystem2. A Vector Concatenate block concatenates
the resulting vectors. This repetitive process is graphically complex
and difficult to maintain. Also, adding another element to the signal
requires a significant rework of the model.
2-641
For Each Subsystem
Each subsystem contains an identical FIR filter that accepts a different
set of input coefficients. For example, Subsystem2 contains the
following blocks:
2-642
For Each Subsystem
You can simplify this model by replacing the repetitive operations with
a single For Each Subsystem block.
This subsystem contains a For Each block and a model representing the
identical algorithm of the three subsystems that it replaces. The For
Each block specifies how to partition the input signal into individual
elements and how to concatenate the processed signals to form output
signals. Also, every block that has state maintains a separate set of
states for each input element processed during a given execution step.
2-643
For Each Subsystem
For this example, both the input signal and the input coefficients are
selected for partitioning. The partition dimension and the partition
width are both set to 1 for both inputs.
2-644
For Each Subsystem
2-645
For Each Subsystem
Therefore, the For Each block slices the input signals into horizontal
partitions of width 1. The input signal of coefficients transforms from
a single array,
Partition
dimension
set to 1
0.0284 0.2370 0.4692
0.2370
0.0284
-0.0651 0.0000 0.8698
0.0000
-0.0651
0.0284 -0.2370 0.4692
-0.2370
0.0284
into three signals,
0.0284 0.2370 0.4692
0.2370
0.0284
-0.0651 0.0000 0.8698
0.0000
-0.0651
0.0284 -0.2370 0.4692
-0.2370
0.0284
To match the output signal dimension to the input signal dimension,
set the concatenation dimension equal to the partition dimension. (The
output signal dimension and the input signal dimension do not have to
match, but matching them makes it easier to compare the input and
output.)
Example of Improved Code Reuse
The purpose of this example is to show how code reuse can be improved
when you have two or more identical For Each Subsystems. Consider
the following model, rtwdemo_foreachreuse.
2-646
For Each Subsystem
The intent is for the three subsystems — Vector SS1, Vector SS2, and
Vector SS3 — to apply the same processing to each scalar element of the
vector signal at their respective input. Because these three subsystems
perform the same processing, it is desirable for them to produce a single
shared Output (and Update) function for all three subsystems in the
code generated for this model. For example, the Vector SS3 subsystem
contains the following blocks:
To generate a single shared function for the three subsystems, the
configuration of the partitioning they perform on their input signals
2-647
For Each Subsystem
must be identical. For Vector SS1 and Vector SS3, this configuration
is straightforward because you can set the partition dimension and
width to 1. However, in order for Vector SS2 to also partition its input
signal along dimension 1, you must insert a Math Function block to
transpose the 1-by-8 row vector into an 8-by-1 column vector. You can
subsequently convert the output of the subsystem back to a 1-by-8
row vector using a second Math Function block set to the transpose
operator.
If you use the Build button on the Code Generation pane of the
Configuration Parameters dialog to generate code, the resulting code
uses a single Output function. This function is shared by all three For
Each Subsystem instances.
/*
* Output and update for iterator system:
*
'<Root>/Vector SS1'
*
'<Root>/Vector SS2'
*
'<Root>/Vector SS3'
*/
void VectorProcessing(int32_T NumIters, const real_T rtu_In1[],
real_T rty_Out1[],
rtDW_VectorProcessing *localDW)
The functions has an input parameter NumIters that indicates the
number of independent scalars which each For Each Subsystem is
to process. This function is called three times with the parameter
NumIters set to 10, 8, and 7 respectively.
The remaining two subsystems in this model show how reusable code
can also be generated for matrix signals that are processed using the
For Each Subsystem. Once again, a Build provides code reuse of a
single function.
Characteristics Sample Time
Scalar Expansion
2-648
Inherited from the driving block
No
For Each Subsystem
See Also
Dimensionalized
Yes
Multidimensionalized
Yes
For Each
2-649
For Iterator
Purpose
Repeatedly execute contents of subsystem at current time step until
iteration variable exceeds specified iteration limit
Library
Ports & Subsystems
Description
The For Iterator block, when placed in a subsystem, repeatedly executes
the contents of the subsystem at the current time step until an iteration
variable exceeds a specified iteration limit. You can use this block
to implement the block diagram equivalent of a for loop in the C
programming language.
The output of a For Iterator subsystem can not be a function-call signal.
Simulink software will display an error message if the simulation is run
or the diagram updated.
The block’s parameter dialog allows you to specify the maximum value
of the iteration variable or an external source for the maximum value
and an optional external source for the next value of the iteration
variable. If you do not specify an external source for the next value of
the iteration variable, the next value is determined by incrementing the
current value:
in+1 = in +1
Suppose that you have the following model:
2-650
For Iterator
Over 20 iterations, the For Iterator block increments a value by 10 at
each time step:
2-651
For Iterator
The following figure shows the result.
The For Iterator subsystem in this example is equivalent to the
following C code.
sum = 0;
iterations = 20;
sum_increment = 10;
for (i = 0; i < iterations; i++) {
sum = sum + sum_increment;
}
2-652
For Iterator
Note Placing a For Iterator block in a subsystem makes it an atomic
subsystem if it is not already an atomic subsystem.
Data Type
Support
The following rules apply to the data type of the number of iterations
(N) input port:
• The input port accepts data of mixed numeric types.
• If the input port value is noninteger, it is first truncated to an integer.
• Internally, the input value is cast to an integer of the type specified
for the iteration variable output port.
• If no output port is specified, the input port value is cast to type
int32.
• If the input port value exceeds the maximum value of the output
port’s type, it is truncated to that maximum value.
Data output for the iterator value can be selected as double, int32,
int16, or int8 in the block parameters dialog box.
The following rules apply to the iteration variable input port:
• It can appear only if the iteration variable output port is enabled.
• The data type of the iteration variable input port is the same as the
data type of the iteration variable output port.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-653
For Iterator
Parameters
2-654
For Iterator
and
Dialog
Box
States when starting
Set this field to reset if you want the states of the For subsystem
to be reinitialized before the first iteration at each time step.
Otherwise, set this field to held (the default) to make sure that
these subsystem states retain their values from the last iteration
at the previous time step.
Iteration limit source
If you set this field to internal, the value of the Iteration limit
field determines the number of iterations. If you set this field to
external, the signal at the For Iterator block’s N port determines
the number of iterations. The iteration limit source must reside
outside the For Iterator subsystem.
Iteration limit
Set the number of iterations by specifying a number or a named
constant. This field appears only if you selected internal for
the Iteration limit source field. This parameter supports
storage classes. You can define the named constant in the base
workspace of the Model Explorer as a Simulink.Parameter object
of the built-in storage class Define (custom) type. For more
information, see “Apply Custom Storage Classes to Parameters”
in the Embedded Coder documentation.
Set next i (iteration variable) externally
This option can be selected only if you select the Show iteration
variable option. If you select this option, the For Iterator block
displays an additional input for connecting an external iteration
variable source. The value of the input at the current iteration is
used as the value of the iteration variable at the next iteration.
Show iteration variable
If you select this check box, the For Iterator block outputs its
iteration value.
Index mode
If you set this field to Zero-based, the iteration number starts
at zero. If you set this field to One-based, the iteration number
starts at one.
2-655
For Iterator
Iteration variable data type
Set the type for the iteration value output from the iteration
number port to double, int32, int16, or int8.
Characteristics Direct Feedthrough
2-656
No
Sample Time
Inherited from driving blocks
Scalar Expansion
No
Dimensionalized
No
Zero Crossing
No
For Iterator Subsystem
Purpose
Represent subsystem that executes repeatedly during simulation time
step
Library
Ports & Subsystems
Description
The For Iterator Subsystem block is a Subsystem block that is
preconfigured to serve as a starting point for creating a subsystem that
executes repeatedly during a simulation time step.
For more information, see the For Iterator block in the online
Simulink block reference and “Control Flow Logic” in the Simulink
documentation.
When using simplified initialization mode, you cannot place any block
needing elapsed time within an Iterator Subsystem. In simplified
initialization mode, Iterator subsystems do not maintain elapsed
time, so Simulink will report an error if any such block (such as the
Discrete-Time Integrator block) is placed within the subsystem. For
more information on simplified initialization modes, see “Underspecified
initialization detection”.
2-657
From
Purpose
Accept input from Goto block
Library
Signal Routing
Description
The From block accepts a signal from a corresponding Goto block, then
passes it as output. The data type of the output is the same as that of
the input from the Goto block. From and Goto blocks allow you to pass
a signal from one block to another without actually connecting them.
To associate a Goto block with a From block, enter the Goto block’s
tag in the Goto Tag parameter.
A From block can receive its signal from only one Goto block, although a
Goto block can pass its signal to more than one From block.
This figure shows that using a Goto block and a From block is equivalent
to connecting the blocks to which those blocks are connected. In the
model at the left, Block1 passes a signal to Block2. That model is
equivalent to the model at the right, which connects Block1 to the Goto
block, passes that signal to the From block, then on to Block2.
The visibility of a Goto block tag determines the From blocks that
can receive its signal. For more information, see Goto and Goto Tag
Visibility. The block indicates the visibility of the Goto block tag:
• A local tag name is enclosed in brackets ([]).
• A scoped tag name is enclosed in braces ({}).
• A global tag name appears without additional characters.
The From block supports signal label propagation.
2-658
From
Data Type
Support
The From block outputs real or complex signals of any data type that
Simulink supports, including fixed-point and enumerated data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
Goto Tag
The tag of the Goto block that forwards its signal to this From
block. To change the tag, select a new tag from this control’s
drop-down list. The drop-down list displays the Goto tags that the
From block can currently see. An item labeled <More Tags...>
appears at the end of the list the first time you display the list in
a Simulink session. Selecting this item causes the block to update
2-659
From
the tags list to include the tags of Goto blocks residing in library
subsystems referenced by the model containing this From block.
Simulink software displays a progress bar while building the list
of library tags. Simulink software saves the updated tags list for
the duration of the Simulink session or until the next time you
select the adjacent Update Tags button. You need to update
the tags list again in the current session only if the libraries
referenced by the model have changed since the last time you
updated the list.
Update Tags
Updates the list of tags visible to this From block, including tags
residing in libraries referenced by the model containing this From
block.
Goto Source
Path of the Goto block connected to this From block. Clicking the
path displays and highlights the Goto block.
Icon Display
Specifies the text to display on the From block’s icon. The
options are the block’s tag, the name of the signal that the block
represents, or both the tag and the signal name.
Examples
The following models show how to use the From block:
• sldemo_auto_climatecontrol
• sldemo_hardstop
Characteristics Sample Time
2-660
Inherited from the block driving the
Goto block
Dimensionalized
Yes
Multidimensionalized
Yes
From
Virtual
Yes
For more information, see
“Virtual Blocks” in the Simulink
documentation.
Zero-Crossing Detection
See Also
No
Goto
2-661
From File
Purpose
Read data from MAT-file
Library
Sources
Description
The From File block reads data from a MAT-file and outputs the data
as a signal. The data is a sequence of samples. Each sample consists
of a time stamp and an associated data value.
The From File block icon shows the name of the MAT-file that supplies
the data.
You can have multiple From File blocks that read from the same
MAT-file.
During the current simulation, the From File block cannot read data
from a MAT-file that is being written to by a To File block.
Version 7.3 MAT-Files
For a Version 7.3 MAT-file, the From File block incrementally reads
data from the MAT-file during simulation. The Sample time parameter
specifies the sample time that the From File block uses to read data
from a MAT-file. For details, see “Parameters and Dialog Box”.
The time stamps in the file must be monotonically nondecreasing.
For each simulation time hit for which the MAT-file contains no
matching time stamp, Simulink software interpolates or extrapolates to
obtain the needed data using the method that you select. For details,
see “Simulation Time Hits That Have No Corresponding MAT-File
Time Stamps.”
When the From File block reads data from a MAT-file, that data must
be stored in one of two formats:
• MATLAB timeseries object
• Array
2-662
From File
Use array format only for vector, double, noncomplex signals. To load a
bus signal, use a MATLAB structure that matches the bus hierarchy,
where each leaf of the structure is a MATLAB timeseries object.
MATLAB timeseries format data can have:
• Any dimensionality and complexity
• Any built-in data type, including Boolean
• A fixed-point data type with a word length of up to 32 bits
• An enumerated data type
For the array format, the stored data is a matrix containing two or more
rows. The matrix in the MAT-file must have the following form:
t2  t final ⎤
⎡ t1
⎢ u1 u1  u1
⎥
2
final ⎥
⎢ 1
⎢
⎥
⎢
⎥
un
un

un
⎢⎣ 1
2
final ⎥⎦
The first element of each column contains a time stamp. The remainder
of the column contains data for the corresponding output values.
For data stored using the array format, the width of the From File
output depends on the number of rows in the matrix. Given a matrix
containing m rows, the block outputs a vector of length m–1.
Version 7.0 and Earlier Version MAT-Files
For Version 7.0 or an earlier version of a MAT-file, the From File block
reads only array-format data. The complete, uncompressed data from a
MAT-file loads into memory at the start of the simulation.
If you have a Version 7.0 or earlier version MAT-file that you want to
use with the From File block, consider converting the file to a Version
7.3 MAT-file. Use a Version 7.3 MAT-file if you want the From File
block to incrementally read the data during simulation or you want to
use MATLAB timeseries data. For example, to convert a Version 7.0
2-663
From File
file named my_data_file.mat that contains the variable var, at the
MATLAB command line, enter:
load('my_data_file.mat')
save('my_data_file.mat', 'var', '-v7.3')
Simulation Time Hits That Have No Corresponding MAT-File
Time Stamps
If the simulation time hit does not have a corresponding MAT-file time
stamp, then the From File block output depends on:
• The location of the simulation time hit relative to the time stamps
in the MAT-file
• The interpolation or extrapolation methods that you select
• The data type of the MAT-file data
For details about interpolation and extrapolation options, see the
descriptions of the following parameters in “Parameters and Dialog
Box”:
• Data extrapolation before first data point
• Data interpolation within time range
• Data extrapolation after last data point
Sometimes the MAT-file includes duplicate time stamps (two or more
data values that have the same time stamp). In such cases, the From
File block action depends on the location of the simulation time hit,
relative to the duplicate time stamps in the MAT-file.
For example, suppose the MAT-file contains the following data, with
three data points having a time stamp value of 2:
time stamps:
data values:
0 1 2 2 2 3 4
2 3 6 4 9 1 5
The following table describes the From File block output.
2-664
From File
Simulation Time, Relative to
Duplicate Time Stamp Values
in MAT-File
From File Block Action
Before the duplicate time stamps
Performs the same actions
as when the time stamps are
distinct, using the first of the
duplicate time stamp values as
the basis for interpolation. (In
this example, that time stamp
value is 6.)
At or after the duplicate time
stamps
Performs the same actions as
when the times stamps are
distinct, using the last of the
duplicate time stamp values as
the basis for interpolation. (In
this example, that time stamp
value is 9.)
Using Data Saved by a To File Block
The From File block reads data written by a To File block without any
modifications to the data or other special provisions.
Using Bus Data
The From File block supports loading nonvirtual bus signals.
The data must be in a MATLAB structure that matches the bus
hierarchy. Each leaf of the structure must be a MATLAB timeseries
object.
The data can underspecify the bus signal, but cannot overspecify the
bus signal. The structure cannot have any elements that do not have
corresponding signals in the bus.
The structure does not require data for every element in the bus
hierarchy, but the structure must have data for at least one of the
signals in the bus. For signals that do not specify data, the From
File block outputs the ground values. If any data read by the From
2-665
From File
File block has variable dimensions, then you must specify data for all
complex bus signals.
Data Type
Support
The From File block can read real or complex signal data of any data
type that Simulink supports, except that fixed-point data cannot have a
word length that exceeds 32 bits.
The From File block supports reading nonvirtual bus signals.
2-666
From File
Parameters
and
Dialog
Box
File name
The path or file name of the MAT-file that contains the data used
as input. On UNIX® systems, the path name can start with a tilde
2-667
From File
(~) character signifying your home folder. The default file name is
untitled.mat. If you specify a file name without path information,
Simulink reads the file in the MATLAB working folder. (To determine
the working folder, type pwd at the MATLAB command line.) If
Simulink cannot find the specified file name in the working folder, it
displays an error message.
Output data type
The data type for the data that the From File block loads. For non-bus
types, you can use Inherit: auto to skip any data type verification. If
you specify an output data type, then the From File block verifies that
the data in the file matches the data type that you specified. For more
information, see “Specify Block Output Data Types”.
If you set Output data type to be a bus object, the bus object must be
available when you compile the model. For each signal in a bus, the
From File block verifies that the data type, dimension, and complexity
of the data matches the data type, dimension, and complexity that the
bus object defines for the signal.
• Inherit:
auto — Default
• double
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
• boolean
• fixdt(1,16,0) — Data type is fixed-point (1,16,0).
• fixdt(1,16,2^0,0) — Data type is fixed-point (1,16,2^0,0).
2-668
From File
• Enum:
<class_name> — Data type is enumerated.
• Bus: <bus_object> — Data type is a bus object. For details, see
the “Using Bus Data” section.
• <data type expression> — The name of a data type object, for
example Simulink.NumericType. Do not specify a bus object as the
expression.
>> (Show data type assistant)
Displays the Data Type Assistant, to help you to set the Output data
type parameter.
Mode
The category of data to specify. For more information, see “Specify
Block Output Data Types”.
• Inherit — Inheritance rule for data types. Selecting Inherit
enables a second menu/text box to the right. (Default)
• Built in — Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
-
double — Default
single
int8
uint8
int16
uint16
int32
uint32
boolean
Fixed point — Fixed-point data types
2-669
From File
-
Enumerated — Enumerated data types. Selecting Enumerated
-
Bus — Bus object. Selecting Bus enables a Bus object parameter
-
Expression — Expression that evaluates to a data type. Selecting
Expression enables a second menu/text box to the right, where you
enables a second menu/text box to the right, where you can enter
the class name.
to the right, where you enter the name of a bus object that you
want to use to define the structure of the bus. If you need to create
or change a bus object, click Edit to the right of the Bus object
field to open the Simulink Bus Editor. For details, see “Manage
Bus Objects with the Bus Editor”.
enter the expression. Do not specify a bus object as the expression.
Sample time
The sample period and offset of the data read from the file.
The From File block reads data from a MAT-file using a sample time
that:
• You specify for the From File block
• The From File block inherits from the blocks into which the From
File block feeds data
The default is 0, which specifies a continuous sample time, The MAT-file
is read at the base (fastest) rate of the model. For details, see “Specify
Sample Time”.
Data extrapolation before first data point
Extrapolation method that Simulink uses for a simulation time hit
that is before the first time stamp in the MAT-file. Choose one of the
following extrapolation methods.
2-670
From File
Method
Description
Linear
extrapolation
(Default)
If the MAT-file contains only one sample, then
the From File block outputs the corresponding
data value.
If the MAT-file contains more than one sample,
then the From File block linearly extrapolates
using the first two samples:
• For double data, linearly extrapolates the
value using the first two samples
• For Boolean data, outputs the first data
value
• For a built-in data type other than double
or Boolean, upcasts the data to double,
performs linear extrapolation (as described
above for double data), and then downcasts
the extrapolated data value to the original
data type
You cannot use the Linear extrapolation
option with enumerated (enum) data. All signals
in a bus use the same extrapolation setting, so
if any signal in a bus uses enum data, then you
cannot use the Linear extrapolation option.
Hold first value
Uses the first data value in the file
Ground value
Uses a value that depends on the data type of
MAT-file sample data values:
• Fixed-point data types — uses the ground
value
• Numeric types other than fixed–point —
uses 0
2-671
From File
Method
Description
• Boolean — uses false
• Enumerated data types — uses default value
Data interpolation within time range
The interpolation method that Simulink uses for a simulation time hit
between two time stamps in the MAT-file. Choose one of the following
interpolation methods.
Method
Description
Linear
interpolation
(Default)
The From File block interpolates using the two
corresponding MAT-file samples:
• For double data, linearly interpolates the
value using the two corresponding samples
• For a built-in data type other than double
or Boolean, upcasts the data to double,
performs linear interpolation (as described
above for double data), and then downcasts
the interpolated value to the original data
type
You cannot use the Linear interpolation
option with enumerated (enum) data. All signals
in a bus use the same interpolation setting, so
if any signal in a bus uses enum data, then you
cannot use the Linear interpolation option.
Zero order hold
2-672
Uses the data from the first of the two samples
From File
Data extrapolation after last data point
The extrapolation method that Simulink uses for a simulation time hit
that is after the last time stamp in the MAT-file. Choose one of the
following extrapolation methods.
Method
Description
Linear
extrapolation
(Default)
If the MAT-file contains only one sample, then
the From File block outputs the corresponding
data value.
If the MAT-file contains more than one sample,
then the From File block linearly extrapolates
using data values of the last two samples:
• For double data, extrapolates the value
using the last two samples
• For Boolean data, outputs the last data
value
• For a built-in data type other than double
or Boolean, upcasts the data to double,
performs linear extrapolation (as described
above for double data), and then downcasts
the extrapolated value to the original data
type
You cannot use the Linear extrapolation
option with enumerated (enum) data. All signals
in a bus use the same extrapolation setting, so
if any signal in a bus uses enum data, then you
cannot use the Linear extrapolation option.
Hold last value
Uses the last data value in the file
Ground value
Uses a value that depends on the data type of
MAT-file sample data values:
2-673
From File
Description
Method
• Fixed-point data types — uses the ground
value
• Numeric types other than fixed–point —
uses 0
• Boolean — uses false
• Enumerated data types — uses default value
Enable zero-crossing detection
Select to enable zero-crossing detection.
For details, see “Zero-Crossing Detection”, as well as the discussion
below.
Simulink uses a technique known as zero-crossing detection to
accurately locate a discontinuity, without resorting to excessively
small time steps. This section uses “zero-crossing” to represent
discontinuities.
For the From File block, zero-crossing detection can only occur at sample
points in the file. To determine whether zero crossing occurs, the From
File block examines only the time stamps within the sample points.
If the input array contains duplicate time stamps (more than one entry
for the same time stamp), Simulink detects a zero crossing at that time
stamp. For example, suppose the input array has this data:
time:
signal:
0 1 2 2 3
2 3 4 5 6
At time 2, there is a zero crossing from the input signal discontinuity.
For data with nonduplicate time stamps, zero-crossing detection
depends on the settings of the following parameters:
• Data extrapolation before first data point
2-674
From File
• Data interpolation within time range
• Data extrapolation after last data point
The From File block applies the following rules when determining when
zero-crossing occurs for the first time stamp, for time stamps between
the first and last time stamp, and for the last time stamp.
Time Stamp
When Zero-Crossing Detection Occurs
First
Data extrapolation before first data point is set
to Ground value.
Data interpolation within time range is set to
Between first
and last
Zero-order hold.
Last
One or both of these settings occur:
• Data extrapolation after last data point is set
to Ground value.
• Data interpolation within time range is set to
Zero-order hold.
The following figure illustrates zero-crossing detection for data accessed
by a From File block that has the following settings:
• Data extrapolation before first data point — Linear
extrapolation
• Data interpolation within time range (for internal points) —
Zero order hold
• Data extrapolation after last data point — Linear
extrapolation
2-675
From File
The following figure is another illustration of zero-crossing detection
for data accessed by a From File block. The block has the following
settings for the time stamps (points):
• Data extrapolation before first data point — Hold first value
• Data interpolation within time range — Zero order hold
• Data extrapolation after last data point — Hold last value
2-676
From File
Characteristics Sample Time
Specified in the Sample time
parameter
Scalar Expansion
No
Dimensionalized
Yes
Zero Crossing
Yes, if enabled
2-677
From File
See Also
2-678
“Import Data”, From Workspace, To File, To Workspace
From Workspace
Purpose
Read data from workspace
Library
Sources
Description
The From Workspace block reads data from a workspace and outputs
the data as a signal.
The From Workspace icon displays the expression specified in the Data
parameter. For details about how Simulink software evaluates this
expression, see “Symbol Resolution”.
Specifying the Workspace Data
In the Data parameter of the block, enter a MATLAB expression that
specifies the workspace data. The expression must evaluate to one of
the following:
• A MATLAB timeseries object
• A structure of MATLAB timeseries objects
• An array or structure containing an array of simulation times and
corresponding signal values
The format of a MATLAB timeseries object, matrix, or structure
loaded (imported) by a From Workspace block is the same as that used
to load root-level input port data from the workspace.
• To load any non-bus data from the workspace, use a MATLAB
timeseries object or a structure with time. For guidelines on
choosing time vectors for discrete systems, see “Techniques for
Importing Signal Data”.
• To load bus data, use a structure of MATLAB timeseries objects.
For details, see “Import Structures of timeseries Objects for Buses”.
2-679
From Workspace
Using Data Saved by a To File Block
You can use the From Workspace block to load MATLAB timeseries
object data that was saved by a To File block, without making any
changes to the data.
To use the From Workspace block to load Array format data, before
the From Workspace block loads the data that a To File block saved,
transpose the array data. The data saved by the To File block contains
consecutive time stamps at the beginnings of columns, followed by the
corresponding data. The transposed data contains consecutive time
stamps at the beginning of rows, followed by the corresponding data.
To provide the required format, use MATLAB load and transpose
commands with the MAT-file (see “Reshaping a Matrix”). To avoid
having to transpose the data again later, resave the transposed data
for future use.
Using Data Saved by a To Workspace Block
To use the From Workspace block to load data exported by a To
Workspace block in a previous simulation for use in a later simulation,
save the To Workspace block data in either Timeseries or Structure
with Time format. For details, see “Techniques for Importing Signal
Data”.
Loading Variable-Size Signals
You can use a To Workspace block (with Structure or Structure With
Time format) or a root Outport block to log variable-size signals. You can
then use the To Workspace variable with the From Workspace block.
Alternatively, you can create a MATLAB structure to contain
variable-size signal data. For each values field in the structure, include
a valueDimensions field that specifies the run-time dimensions for the
signal. For details, see Simulink Models Using Variable-Size Signals.
Interpolating Missing Data Values
If you select the Interpolate data option, the block uses linear
Lagrangian interpolation to compute data values for time steps that
occur between time steps for which the workspace supplies data.
2-680
From Workspace
For variable-size signals, clear Interpolate data.
Specifying Output After Final Data
Combine the settings of the Form output after final data value by
and Interpolate data parameters to determine the block output after
the last time step for which workspace data is available. For details, see
the Form output after final data value by parameter.
Detecting Zero Crossings
The Enable zero-crossing detection parameter applies only if the
sample time is continuous (0).
If you select the Enable zero-crossing detection parameter, and if
the input array contains more than one entry for the same time step,
Simulink detects a zero crossing at that time step.
For bus signals, Simulink detects zero crossings across all leaf bus
elements.
Data Type
Support
The From Workspace block accepts data from the workspace and
outputs real or complex signals of any type supported by Simulink,
including fixed-point and enumerated data types.
The From Workspace block also accepts a bus object as a data type. To
load bus data, use a structure of MATLAB timeseries objects. For
details, see “Import Structures of timeseries Objects for Buses”.
Real signals of type double can be in any format that the From
Workspace block supports. For complex signals and real signals of a
data type other than double, use any format except Array.
2-681
From Workspace
Parameters
and
Dialog
Box
Data
A MATLAB expression that evaluates to one of the following:
• A MATLAB timeseries object
• A structure of MATLAB timeseries objects
2-682
From Workspace
To load bus data, use a structure of MATLAB timeseries objects. For
details, see “Import Structures of timeseries Objects for Buses”.
• A two-dimensional matrix:
-
The first element of each matrix row is a time stamp.
The rest of each row is a scalar or vector of signal values.
The leftmost element of each row is the time stamp of the value(s) in
the rest of the row.
• A structure, with or without time, which contains:
-
An array or matrix named signals.values, which contains
scalars or vectors of signal values.
-
An array named signals.dimensions, which contains the
dimensions of the signals.
-
Optionally, a vector named time, which contains time stamps.
The n’th time element is the time stamp of the n’th signals.values
element. For details, see “Techniques for Importing Signal Data”.
For example, suppose that the workspace contains a column vector
of times named T and a column vector of corresponding signal values
named U. Entering the expression [T U] for this parameter yields the
required input array. If the required array or structure already exists
in the workspace, enter the name of the structure or matrix in this field.
Output data type
The required data type for the data for the workspace variable that the
From Workspace block loads. For non-bus types, you can use Inherit:
auto to skip any data type verification. For more information, see
“Specify Block Output Data Types”.
To load bus data, use a structure of MATLAB timeseries objects. For
details, see “Import Structures of timeseries Objects for Buses”.
• Inherit:
auto — Default.
2-683
From Workspace
• double
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
• boolean
• fixdt(1,16,0) — Data type is fixed-point (1,16,0).
• fixdt(1,16,2^0,0) — Data type is fixed-point (1,16,2^0,0).
• Enum:
Enum:
• Bus:
<class_name> — Data type is enumerated, for example,
Basic Colors.
<bus_object> — Data type is a bus object.
• <data type expression> — The name of a data type object, for
example Simulink.NumericType. Do not specify a bus object as the
expression.
>> (Show data type assistant)
Displays the Data Type Assistant, to help you to set the Output data
type parameter.
Mode
The category of data to specify. For more information, see “Specify
Block Output Data Types”.
• Inherit — Inheritance rule for data types. Selecting Inherit
enables a second menu/text box to the right. (Default)
• Built in — Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
2-684
From Workspace
-
double — Default
-
Bus — Bus object. Selecting Bus enables a Bus object parameter
-
Expression — Expression that evaluates to a data type. Selecting
Expression enables a second menu/text box to the right, where you
single
int8
uint8
int16
uint16
int32
uint32
boolean
Fixed point — Fixed-point data types
Enumerated — Enumerated data types. Selecting Enumerated
enables a second menu/text box to the right, where you can enter
the class name.
to the right, where you enter the name of a bus object that you
want to use to define the structure of the bus. If you need to create
or change a bus object, click Edit (to the right of the Bus object
field) to open the Simulink Bus Editor. For details, see “Manage
Bus Objects with the Bus Editor”.
enter the expression. Do not specify a bus object as the expression.
Sample time
Sample rate of data from the workspace. For details, see “Specify
Sample Time”.
Interpolate data
Select this option to have the block linearly interpolate at time steps for
which no corresponding workspace data exists. Otherwise, the current
output equals the output at the most recent time for which data exists.
2-685
From Workspace
If you select this option, the block linearly interpolates a missing data
point from the two known data points between which it falls. For
example, suppose the block reads the following time series from the
workspace:
time:
signal:
1
2
253 254
3
?
4
256
The block would output:
time:
signal:
1
2
3
253 254 255
4
256
If you clear the Interpolate data option, the block uses the most recent
data value supplied from the workspace to provide any missing data
values. For example, the result of the incomplete set of signal values
shown above would be:
time:
signal:
1
2
3
253 254 254
4
256
Integer data — If the input data type is an integer type and an
interpolated data point exceeds the data type’s range, the block sets the
missing data point to be the maximum value that the data type can
represent. Similarly, if the interpolated or extrapolated value is less
than the minimum value that the data type can represent, the block
sets the missing data point to the minimum value that the data type
can represent. For example, suppose that the data type is uint8 and
the value interpolated for a missing data point is 256.
time:
signal:
1
2
3
253 254 255
4
?
In this case, the block sets the value of the missing point to 255, the
largest value that can be represented by the uint8 data type:
time:
signal:
2-686
1
2
3
253 254 255
4
255
From Workspace
Boolean data — If the input data is boolean, the block uses the value
of the nearest workspace data point as the value of missing data point
when determining missing data points that fall between the first and
last known points. For example, suppose the workspace supplies values
at time steps 1 and 4 but not at 2 and 3:
time:
signal:
1 2 3 4
1 ? ? 0
In this case, the block would use the value of data point 1 as the value
of data point 2 and the value of data point 4 as the value of data point 3:
time:
signal:
1 2 3 4
1 1 0 0
The block uses the value of the last known data point as the value of
time steps that occur after the last known data point.
Combine the settings of the Interpolate data and Form output after
final data value by parameters to determine the block output after
the last time step for which workspace data is available. For details, see
the Form output after final data value by parameter.
Enable zero-crossing detection
If you select the Enable zero-crossing detection parameter, then
when the input array contains more than one entry for the same time
step, Simulink detects a zero crossing at that time step. For example,
suppose the input array has this data:
time:
signal:
0 1 2 2 3
2 3 4 5 6
At time 2, there is a zero crossing from input signal discontinuity. For
more information, see “Zero-Crossing Detection”.
For bus signals, Simulink detects zero crossings across all leaf bus
elements.
2-687
From Workspace
Form output after final data value by
Combine the settings of the Form output after final data value by
and Interpolate data parameters to determine the block output after
the last time step for which workspace data is available. The following
table describes the block output based on the values of the two options:
Setting for Form
Output After Final
Data Value By
Setting for
Interpolate
Data
Extrapolation
On
Extrapolated from final data
value
Off
Error
On
Zero
Off
Zero
On
Final value from workspace
Off
Final value from workspace
On
Error
Off
Repeated from workspace
if the workspace data is
in structure-without-time
format. Error otherwise.
Setting to zero
Holding final value
Cyclic repetition
Block Output After Final
Data
For example, if Form output after final data value by is
Extrapolation and Interpolate data is selected, the block uses the
last two known data points to extrapolate data points that occur after
the last known point. Consider the following model.
2-688
From Workspace
In this model, the From Workspace block reads data from the
workspace consisting of the output of the Simulink Sine block sampled
at one-second intervals. The workspace contains the first 16 samples
of the output. The top and bottom X-Y plots display the output of the
Sine Wave and From Workspace blocks, respectively, from 0 to 20
seconds. The straight line in the output of the From Workspace block
reflects the block’s linear extrapolation of missing data points at the
end of the simulation.
Examples
The From Workspace block allows you to read 1-D and 2-D signals
into Simulink.
2-689
From Workspace
Reading 1-D Signals in Array Format
Create two signals x and y with a time vector t, and then import the
values into Simulink with an array.
1 In the MATLAB Command Window, enter
t = [0:0.2:10]';
x = sin(t);
y = 10*sin(t);
The time vector must be a column vector.
2 Add a From Workspace block to your model.
3 Double-click the block to open the block parameters dialog. In the
Data field, enter the array [t,x,y],
Reading 1-D Signals in Structure Format
Create two signals x and y with a time vector t, and then import the
values into Simulink with a structure.
1 In the MATLAB Command Window, enter
t = [0:0.2:10]';
x = sin(t);
y = 10*sin(t);
wave.time = t;
wave.signals.values = [x,y];
wave.signals.dimensions =2;
The time vector must be a column vector. The signals.dimensions
field for a 1-D signal is a scalar corresponding to the number of
signals or number of columns in the signals.values field. Each
column in the signals.values field corresponds to a signal
2 Add a From Workspace block to your model.
2-690
From Workspace
3 Double-click the block to open the block parameters dialog. In the
Data field, enter the structure name.
Using
Sample
Time from
Model
If you do not have a time vector, you can define the sample time in
your model.
1 In the MATLAB Command Window, enter
wave.time = [];
2 Double-click the From Workspace block to open the block
parameters dialog. In the Sample time field, enter a time interval.
For example, enter 0.2. Clear the Interpolate data check box.
From the Form output after final data value by, select either
Setting to zero, Holding final value, or Cyclic repetition.
Do not select Extrapolation.
Reading 2-D Signals in Structure Format
To load 2-D signals from the MATLAB workspace into Simulink, you
must have the signals in a structure format. This example creates
a 10–by–10 matrix (2-D signal) using the magic function, and then
creates a 3-D matrix by adding a time vector.
1 In the MATLAB Command Window, enter
t1 = [0:0.2:10]';
m = magic(10);
M = repmat(m,[1 1 length(t1)]);
data.time=t1;
data.signals.values = M;
data.signals.dimensions=[10 10];
2-691
From Workspace
The time vector must be a column vector. The signals.values
field is a 3-D matrix where the third dimension is the signal values
at a specific time. The signals.dimensions field is a two element
vector where the first element is the number of rows and the second
element is the number of columns in the signals.values field.
2 Double-click the From Workspace block to open the block
parameters dialog. In the Data field, enter the name of the structure.
Characteristics Sample Time
See Also
2-692
Specified in the Sample time
parameter
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
Yes, if enabled.
“Import Data”, “Import Data for an Input Test Case”, From File, To
File, To Workspace
Function-Call Feedback Latch
Purpose
Break feedback loop involving data signals between function-call blocks
Library
Ports & Subsystems
Description
Use the Function-Call Feedback Latch block to break a feedback loop
of data signals between one or more function-call blocks. Specifically,
break a loop formed in one of the following ways.
• When function-call blocks connect to branches of the same
function-call signal
Place the Function-Call Feedback Latch block on the feedback
signal between the branched blocks. As a result, the latch block
delays the signal at the input of the destination function-call block,
and the destination function-call block executes prior to the source
function-call block of the latch block.
• When the loop involves parent and child function-call blocks,
where the child initiator is inside the parent
Place the Function-Call Feedback Latch block on the feedback signal
between the child and the parent. This arrangement prevents the
2-693
Function-Call Feedback Latch
signal value, read by the parent (FCSS1), from changing during
execution of the child. In other words, the parent reads the value
from the previous execution of the child (FCSS2).
Using the latch block is equivalent to selecting the Latch input for
function-call feedback signals check box on the Inport block in
the destination function-call subsystem. However, an advantage of
the latch block over the dialog parameter is that one can design the
destination function-call subsystem (or model) in a modular fashion and
then use it either in or out of the context of loops.
The Function-Call Feedback Latch block is better suited than the Unit
Delay or Memory blocks in breaking function-call feedback loops for
the following reasons:
• The latch block delays the feedback signal for exactly one execution of
the source function-call block. This behavior is different from the Unit
Delay or Memory blocks for cases where the function-call subsystem
blocks may execute multiple times in a given simulation step.
2-694
Function-Call Feedback Latch
• Unlike the Unit Delay or Memory blocks, the latch block may be used
to break loops involving asynchronous function-call subsystems.
• The latch block can result in better performance, in terms of memory
optimization, for generated code.
Data Type
Support
The Function-Call Feedback Latch block accepts real or complex signals
of the following data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
In addition, the latch block accepts bus signals provided that they do
not contain any variable-sized signals.
This block does not accept:
• Function-call signals
• Action signals
• Variable-sized signals
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-695
Function-Call Feedback Latch
Parameters
and
Dialog
Box
The Function-Call Feedback Latch block dialog box appears as follows:
Examples
In the following model, a single function-call subsystem output serves
as its own input.
2-696
Function-Call Feedback Latch
A more complex case occurs when a merged signal serves as the input to
a function-call subsystem. Latching is necessary if one of the signals
entering the Merge block forms a feedback loop with the function-call
subsystem. In this example, one of the output signals from FCSS2
combines with the output of an Enabled Subsystem block and then
feeds back into an inport of FCSS2.
2-697
Function-Call Feedback Latch
Characteristics Direct Feedthrough
See Also
2-698
No
Sample Time
Inherited from the driving block
Scalar Expansion
Yes
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Function-Call Subsystem block
Function-Call Generator
Purpose
Execute function-call subsystem specified number of times at specified
rate
Library
Ports & Subsystems
Description
The Function-Call Generator block executes a function-call subsystem
(for example, a Stateflow chart acting as a function-call subsystem)
at the rate that you specify with the Sample time parameter. To
iteratively execute each function-call block connected to this block
multiple times at each time step, use the ‘Number of Iterations’
parameter.
To execute multiple function-call subsystems or models in a prescribed
order, use the Function-Call Generator block in conjunction with a
Function-Call Split block. For an example, see the Function-Call Split
block documentation.
Data Type
Support
The Function-Call Generator block outputs a signal of type fcn_call.
2-699
Function-Call Generator
Parameters
and
Dialog
Box
Sample time
Specify the time interval between samples. See “Specify Sample
Time” in the online documentation for more information.
Number of iterations
Number of times to execute the block per time step. The value of
this parameter can be a vector where each element of the vector
specifies a number of times to execute a function-call subsystem.
The total number of times that a function-call subsystem executes
2-700
Function-Call Generator
per time step equals the sum of the values of the elements of the
generator signal entering its control port.
Suppose that you specify the number of iterations to be [2 2]
and connect the output of this block to the control port of a
function-call subsystem. In this case, the function-call subsystem
executes four times at each time step.
Characteristics Direct Feedthrough
No
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
No
Dimensionalized
Yes
Zero-Crossing Detection
No
2-701
Function-Call Split
Purpose
Provide junction for splitting function-call signal
Library
Ports & Subsystems
Description
The Function-Call Split block allows a function-call signal to be
branched and connected to several function-call subsystems and models.
Several Function-Call Split blocks may be cascaded one after another
to create multiple branches for a function-call signal. An advantage
of the Function-Call Split block is that in some cases, using this
block eliminates the need for the initiator block to create multiple
function-call signals for invoking a set of function-call subsystems or
models.
Function-call subsystems or models connected to the output port of
the Function-Call Split block marked with a dot execute before the
subsystems or models connected to the other output port. If any data
dependencies between these subsystems (or between models) do not
support the specified execution order, then an error occurs. This implies
that an error will always occur when you create a data-dependency loop
involving function-call subsystems or models connected to branches
of the same function-call signal. To eliminate this error, consider
turning on the Latch input for feedback signals of function-call
subsystem outputs on one or more Inport blocks of the function-call
subsystems (or models) involved in the loop. Setting this option to
on has the effect of delaying the corresponding input signal, thereby
eliminating the data-dependency loop.
In order for a model to contain Function-Call Split blocks, you must set
the following diagnostic to error: Model Configuration Parameters
> Diagnostics > Connectivity > Invalid function-call connection.
If you turn on the model option Format > Block Displays > Sorted
Order, then the execution order of function-call subsystems connected
to branches of a given function-call signal displays on the blocks .
Each subsystem has an execution order of the form S:B#{C}. Here, #
is a number that ranges from 0 to one less than the total number of
subsystems (or models) connected to branches of a given signal. The
subsystems execute in ascending order based on this number.
2-702
Function-Call Split
The Function-Call Split block supports signal label propagation.
Limitations
The Function-Call Split block has these limitations:
Limitations
Triggered function-call signals cannot be branched. Only periodic
and asynchronous function-call signals can be connected to the
Function-Call Split block.
All function-call subsystems and models connected to a given
function-call signal must reside within the same nonvirtual layer of
the model hierarchy.
Branched function-call subsystems (or models) and their children
cannot be connected directly back to the initiator.
Function-call subsystems and models connected to branches of a
function-call signal cannot have multiple (muxed) initiators.
Data Type
Support
The Function-Call Split block accepts periodic and asynchronous
function-call signals only.
2-703
Function-Call Split
Parameters
and
Dialog
Box
The Function-Call Split block dialog box appears as follows:
Examples
The following model shows how to apply the Latch input for feedback
signals of function-call subsystem outputs parameter to work
around a data-dependency error caused by using a Function-Call Split
block. By turning this parameter on in the f1 subsystem Inport block,
the Function-Call Split block ignores the data dependency of signal b
and thus breaks the loop of data dependencies between subsystems f1
and g1. The model thus achieves the desired behavior of consistently
calling f1 to execute before g1. For a given execution step, subsystem f1
uses the g1 output computed at the previous execution step.
2-704
Function-Call Split
Characteristics Sample Time
See Also
Inherited from the block driving
the function-call split
Scalar Expansion
No
Dimensionalized
No
Multidimensionalized
No
Virtual
Yes
Function-Call Subsystem | Function-Call Generator
2-705
Function-Call Subsystem
Purpose
Represent subsystem that can be invoked as function by another block
Library
Ports & Subsystems
Description
The Function-Call Subsystem block is a Subsystem block that is
preconfigured to serve as a starting point for creating a function-call
subsystem. For more information, see “Function-Call Subsystems” in
the “Creating a Model” chapter of the Simulink documentation.
2-706
Gain
Purpose
Multiply input by constant
Library
Math Operations
Description
The Gain block multiplies the input by a constant value (gain). The
input and the gain can each be a scalar, vector, or matrix.
You specify the value of the gain in the Gain parameter. The
Multiplication parameter lets you specify element-wise or matrix
multiplication. For matrix multiplication, this parameter also lets you
indicate the order of the multiplicands.
The gain is converted from doubles to the data specified in the block
mask offline using round-to-nearest and saturation. The input and gain
are then multiplied, and the result is converted to the output data type
using the specified rounding and overflow modes.
Data Type
Support
The Gain block accepts a real or complex scalar, vector, or matrix of any
numeric data type that Simulink supports. The Gain block supports
fixed-point data types. If the input of the Gain block is real and the gain
is complex, the output is complex.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-707
Gain
Parameters
and
Dialog
Box
2-708
The Main pane of the Gain block dialog box appears as follows:
Gain
The Signal Attributes pane of the Gain block dialog box appears as
follows:
2-709
Gain
The Parameter Attributes pane of the Gain block dialog box appears
as follows:
2-710
Gain
Gain
Specify the value by which to multiply the input.
Settings
Default: 1
Minimum: value of Parameter minimum parameter
Maximum: value of Parameter maximum parameter
The gain can be a scalar, vector, or matrix.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-711
Gain
Multiplication
Specify the multiplication mode.
Settings
Default: Element-wise(K.*u)
Element-wise(K.*u)
Each element of the input is multiplied by each element of the
gain. The block performs expansions, if necessary, so that the
input and gain have the same dimensions.
Matrix(K*u)
The input and gain are matrix multiplied with the input as the
second operand.
Matrix(u*K)
The input and gain are matrix multiplied with the input as the
first operand.
Matrix(K*u)(u vector)
The input and gain are matrix multiplied with the input as the
second operand. This mode is identical to Matrix(K*u), except for
how dimensions are determined.
Suppose that K is an m-by-n matrix. Matrix(K*u)(u vector)
sets the input to a vector of length n and the output to a vector of
length m. In contrast, Matrix(K*u) uses propagation to determine
dimensions for the input and output. For an m-by-n gain matrix,
the input can propagate to an n-by-q matrix, and the output
becomes an m-by-q matrix.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-712
Gain
Sample time (-1 for inherited)
Specify the time interval between samples.
Settings
Default: -1
To inherit the sample time, set this parameter to -1.
See “Specify Sample Time” in the online documentation for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-713
Gain
Output minimum
Specify the minimum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the minimum value for bus data on the block. Simulink ignores
this setting. Instead, set the minimum values for bus elements of the
bus object specified as the data type. For information on the Minimum
property of a bus element, see Simulink.BusElement.
Simulink uses the minimum to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-714
Gain
Output maximum
Specify the maximum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the maximum value for bus data on the block. Simulink ignores this
setting. Instead, set the maximum values for bus elements of the bus
object specified as the data type. For information on the Maximum
property of a bus element, see Simulink.BusElement.
Simulink uses the maximum value to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-715
Gain
Output data type
Specify the output data type.
Settings
Default: Inherit:
Inherit:
Inherit via internal rule
Inherit via internal rule
Simulink chooses a combination of output scaling and data type
that requires the smallest amount of memory consistent with
accommodating the calculated output range and maintaining
the output precision of the block and with the word size of the
targeted hardware implementation specified for the model. If the
Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic), i.e., a generic 32-bit
microprocessor, is specified as the target hardware, the output
data type is int32. If none of the word lengths provided by
the target microprocessor can accommodate the output range,
Simulink software displays an error message in the Simulation
Diagnostics Viewer.
Inherit:
Inherit via back propagation
Use data type of the driving block.
Inherit:
Same as input
Use data type of input signal.
double
Output data type is double.
single
Output data type is single.
2-716
Gain
int8
Output data type is int8.
uint8
Output data type is uint8.
int16
Output data type is int16.
uint16
Output data type is uint16.
int32
Output data type is int32.
uint32
Output data type is uint32.
fixdt(1,16,0)
Output data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Output data type is fixed point fixdt(1,16,2^0,0).
<data type expression>
Use a data type object, for example, Simulink.NumericType.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Block Output Data Types” for more information.
2-717
Gain
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second menu/text box to the right. Select one of the following
choices:
• Inherit via internal rule (default)
• Inherit via back propagation
• Same as input
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Fixed-point data types.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
2-718
Gain
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-719
Gain
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-720
Gain
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-721
Gain
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-722
Gain
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Binary point
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type”.
2-723
Gain
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-724
Gain
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-725
Gain
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
2-726
Gain
Integer rounding mode
Specify the rounding mode for fixed-point operations.
Settings
Default: Floor
Ceiling
Rounds both positive and negative numbers toward positive
infinity. Equivalent to the MATLAB ceil function.
Convergent
Rounds number to the nearest representable value. If a tie occurs,
rounds to the nearest even integer. Equivalent to the Fixed-Point
Toolbox convergent function.
Floor
Rounds both positive and negative numbers toward negative
infinity. Equivalent to the MATLAB floor function.
Nearest
Rounds number to the nearest representable value. If a tie occurs,
rounds toward positive infinity. Equivalent to the Fixed-Point
Toolbox nearest function.
Round
Rounds number to the nearest representable value. If a tie occurs,
rounds positive numbers toward positive infinity and rounds
negative numbers toward negative infinity. Equivalent to the
Fixed-Point Toolbox round function.
Simplest
Automatically chooses between round toward floor and round
toward zero to generate rounding code that is as efficient as
possible.
Zero
Rounds number toward zero. Equivalent to the MATLAB fix
function.
2-727
Gain
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Rounding” in the Simulink Fixed Point
documentation.
2-728
Gain
Saturate on integer overflow
Specify whether overflows saturate.
Settings
Default: Off
On
Overflows saturate to either the minimum or maximum value
that the data type can represent.
For example, an overflow associated with a signed 8-bit integer
can saturate to -128 or 127.
Off
Overflows wrap to the appropriate value that is representable
by the data type.
For example, the number 130 does not fit in a signed 8-bit integer
and wraps to -126.
Tips
• Consider selecting this check box when your model has possible
overflow and you want explicit saturation protection in the generated
code.
• Consider clearing this check box when you want to optimize efficiency
of your generated code.
Clearing this check box also helps you avoid overspecifying how
a block handles out-of-range signals. For more information, see
“Checking for Signal Range Errors”.
• When you select this check box, saturation applies to every internal
operation on the block, not just the output or result.
• In general, the code generation process can detect when overflow
is not possible. In this case, the code generator does not produce
saturation code.
2-729
Gain
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-730
Gain
Parameter minimum
Specify the minimum value of the gain.
Settings
Default: []
The default value is [] (unspecified). Simulink software uses this value
to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-731
Gain
Parameter maximum
Specify the maximum value of the gain.
Settings
Default: []
The default value is [] (unspecified). Simulink software uses this value
to perform:
• Parameter range checking (see “Check Parameter Values”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-732
Gain
Parameter data type
Specify the data type of the Gain parameter.
Settings
Default: Inherit:
Inherit:
Inherit via internal rule
Inherit via internal rule
Use an internal rule to inherit the data type.
Inherit:
Same as input
Use data type of sole input signal.
Inherit:
Inherit from 'Gain'
Use data type of the Gain value. For example:
If you set Gain to...
The parameter data type inherits...
2
double
single(2)
single
int8(2)
int8
double
Data type is double.
single
Data type is single.
int8
Data type is int8.
uint8
Data type is uint8.
int16
Data type is int16.
uint16
Data type is uint16.
int32
Data type is int32.
2-733
Gain
uint32
Data type is uint32.
fixdt(1,16)
Data type is fixdt(1,16).
fixdt(1,16,0)
Data type is fixdt(1,16,0).
fixdt(1,16,2^0,0)
Data type is fixdt(1,16,2^0,0).
<data type expression>
Use a data type object, for example, Simulink.NumericType.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-734
Gain
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second menu/text box to the right. Select one of the following
choices:
• Inherit via internal rule (default)
• Same as input
• Inherit from 'Gain'
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Fixed-point data types.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
2-735
Gain
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant” in the Simulink
documentation.
2-736
Gain
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-737
Gain
Examples
The following Simulink examples show how to use the Gain block:
• sldemo_bounce
• sldemo_tonegen_fixpt
• sldemo_hardstop
• sldemo_enginewc
Characteristics Direct Feedthrough
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes, of input and Gain parameter for
Element-wise(K.*u) multiplication
Dimensionalized
Yes
Multidimensionalized
Yes, only if the Multiplication
parameter specifies
Element-wise(K.*u)
Zero-Crossing Detection
2-738
No
Goto
Purpose
Pass block input to From blocks
Library
Signal Routing
Description
The Goto block passes its input to its corresponding From blocks. The
input can be a real- or complex-valued signal or vector of any data
type. From and Goto blocks allow you to pass a signal from one block
to another without actually connecting them.
A Goto block can pass its input signal to more than one From block,
although a From block can receive a signal from only one Goto block.
The input to that Goto block is passed to the From blocks associated
with it as though the blocks were physically connected. Goto blocks and
From blocks are matched by the use of Goto tags.
The Tag Visibility parameter determines whether the location of From
blocks that access the signal is limited:
• local, the default, means that From and Goto blocks using the same
tag must be in the same subsystem. A local tag name is enclosed
in brackets ([]).
• scoped means that From and Goto blocks using the same tag must
be in the same subsystem or at any level in the model hierarchy
below the Goto Tag Visibility block that does not entail crossing a
nonvirtual subsystem boundary, i.e., the boundary of an atomic,
conditionally executed, or function-call subsystem or a model
reference. A scoped tag name is enclosed in braces ({}).
• global means that From and Goto blocks using the same tag can
be anywhere in the model except in locations that span nonvirtual
subsystem boundaries.
The rule that From-Goto block connections cannot cross nonvirtual
subsystem boundaries has the following exception. A Goto block
connected to a state port in one conditionally executed subsystem is
visible to a From block inside another conditionally executed subsystem.
For more information about conditionally executed subsystems, see
“Conditional Execution Behavior”.
2-739
Goto
Note A scoped Goto block in a masked system is visible only in that
subsystem and in the nonvirtual subsystems it contains. Simulink
generates an error if you run or update a diagram that has a Goto
Tag Visibility block at a higher level in the block diagram than the
corresponding scoped Goto block in the masked subsystem.
Use local tags when the Goto and From blocks using the same tag name
reside in the same subsystem. You must use global or scoped tags when
the Goto and From blocks using the same tag name reside in different
subsystems. When you define a tag as global, all uses of that tag access
the same signal. A tag defined as scoped can be used in more than one
place in the model.
The Goto block supports signal label propagation.
Data Type
Support
The Goto block accepts real or complex signals of any data type that
Simulink supports, including fixed-point and enumerated data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-740
Goto
Parameters
and
Dialog
Box
Goto Tag
The Goto block identifier. This parameter identifies the Goto
block whose scope is defined in this block.
2-741
Goto
Tag Visibility
The scope of the Goto block tag: local, scoped, or global. The
default is local.
Corresponding From blocks
List of the From blocks connected to this Goto block.
Double-clicking any entry in this list displays and highlights the
corresponding From block.
Icon Display
Specifies the text to display on the block’s icon. The options are
the block’s tag, the name of the signal that the block represents,
or both the tag and the signal name.
Examples
The following models show how to use the Goto block:
• sldemo_auto_climatecontrol
• sldemo_hardstop
Characteristics Sample Time
Inherited from driving block
Dimensionalized
Yes
Multidimensionalized
Yes
Virtual
Yes
For more information, see
“Virtual Blocks” in the Simulink
documentation.
Zero-Crossing Detection
See Also
2-742
From
No
Goto Tag Visibility
Purpose
Define scope of Goto block tag
Library
Signal Routing
Description
The Goto Tag Visibility block defines the accessibility of Goto block
tags that have scoped visibility. The tag specified as the Goto tag
parameter is accessible by From blocks in the same subsystem that
contains the Goto Tag Visibility block and in subsystems below it in
the model hierarchy.
A Goto Tag Visibility block is required for Goto blocks whose Tag
Visibility parameter value is scoped. No Goto Tag Visibility block is
needed if the tag visibility is either local or global. The block shows
the tag name enclosed in braces ({}).
Data Type
Support
Not applicable.
2-743
Goto Tag Visibility
Parameters
and
Dialog
Box
Goto tag
The Goto block tag whose visibility is defined by the location of
this block.
Characteristics Sample Time
N/A
Dimensionalized
N/A
Virtual
Yes
For more information, see
“Virtual Blocks” in the Simulink
documentation.
2-744
Ground
Purpose
Ground unconnected input port
Library
Sources
Description
The Ground block connects to blocks whose input ports do not connect
to other blocks. If you run a simulation with blocks having unconnected
input ports, Simulink issues warnings. Using a Ground block to ground
those unconnected blocks can prevent these warnings.
The Ground block outputs a signal of the same data type as the port to
which it connects. For example, consider the following model:
In this example, the output of the Constant block determines the data
type (int8) of the port to which the Ground block is connected. That
port determines the output data type of the Ground block.
The Ground block outputs a signal with zero value. When the output
data type cannot represent zero exactly, the Ground block outputs a
nonzero value that is the closest possible value to zero. This behavior
applies only to fixed-point data types with nonzero bias. The following
expressions are examples of fixed-point data types that cannot represent
zero:
• fixdt(0, 8, 1, 1) — an unsigned 8-bit type with slope of 1 and
bias of 1
• fixdt(1, 8, 6, 3) — a signed 8-bit type with slope of 6 and bias of 3
If the output is an enumerated data type, the Ground block outputs the
default value of the enumeration. This behavior applies whether or not:
2-745
Ground
• The enumeration can represent zero.
• The default value of the enumeration is zero.
If the enumerated type does not have a default value, the Ground block
outputs the first enumeration value in the type definition.
Data Type
Support
The Ground block supports all data types that Simulink supports,
including fixed-point and enumerated data types. For more
information, see “Data Types Supported by Simulink” in the Simulink
documentation.
Parameters
and
Dialog
Box
Examples
The following Simulink examples show how to use the Ground block:
• sldemo_doublebounce
Characteristics Sample Time
Dimensionalized
2-746
Constant (inf)
Yes
Ground
Multidimensionalized
Yes
Virtual
Yes
For more information, see
“Virtual Blocks” in the Simulink
documentation.
2-747
Hit Crossing
Purpose
Detect crossing point
Library
Discontinuities
Description
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.
The block accepts one input of type double. If you select the Show
output port check box, the block output indicates when the crossing
occurs. If the input signal is exactly the value of the offset value after
the hit crossing is detected, the block continues to output a value of 1. If
the input signals at two adjacent points bracket the offset value (but
neither value is exactly equal to the offset), the block outputs a value
of 1 at the second time step. If the Show output port check box is
not selected, the block ensures that the simulation finds the crossing
point but does not generate output. If the input signal is constant and
equal to the offset value, the block outputs 1 only if the Hit crossing
direction property is set to either.
When the block’s Hit crossing direction property is set to either,
the block serves as an "Almost Equal" block, useful in working around
limitations in finite mathematics and computer precision. Used for
these reasons, this block might be more convenient than adding logic to
your model to detect this condition.
When the block’s Hit crossing direction property is set to either and
the model uses a fixed-step solver, the block has the following behavior.
If the output signal is 1, the block sets the output signal to 0 at the next
time step, unless the input signal equals the offset value.
Data Type
Support
2-748
The Hit Crossing block outputs a signal of type Boolean if Boolean logic
signals are enabled (see “Implement logic signals as Boolean data (vs.
double)”). Otherwise, the block outputs a signal of type double.
Hit Crossing
Parameters
2-749
Hit Crossing
and
Dialog
Box
Hit crossing offset
The value whose crossing is to be detected.
Hit crossing direction
The direction from which the input signal approaches the hit
crossing offset for a crossing to be detected.
Show output port
If selected, draw an output port.
Enable zero-crossing detection
Select to enable zero-crossing detection. For more information,
see “Zero-Crossing Detection” in the Simulink documentation.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
online documentation for more information.
Examples
2-750
The sldemo_hardstop and sldemo_clutch models show how you can
use the Hit Crossing block.
Hit Crossing
In the sldemo_hardstop model, the Hit Crossing block is in the Friction
Model subsystem.
2-751
Hit Crossing
In the sldemo_clutch model, the Hit Crossing block is in the Friction
Mode Logic/Lockup Detection subsystem.
Characteristics Direct Feedthrough
2-752
Yes
Sample Time
Inherited from driving block
Scalar Expansion
Yes
Dimensionalized
Yes
Zero-Crossing Detection
Yes, if enabled.
IC
Purpose
Set initial value of signal
Library
Signal Attributes
Description
The IC block sets the initial condition of the signal at its input port, for
example, the value of the signal at the simulation start time (tstart). The
block does this by outputting the specified initial condition when you
start the simulation, regardless of the actual value of the input signal.
Thereafter, the block outputs the actual value of the input signal.
Note If an IC block inherits or specifies a nonzero sample time offset
(toffset), the IC block outputs its initial value at time t,
t = n * tperiod + toffset
where n is the smallest integer such that t
tstart.
That is, the IC block outputs its initial value the first time blocks with
sample time [tperiod, toffset] execute, which can be after tstart.
The IC block is useful for providing an initial guess for the algebraic
state variables in a loop. For more information, see “Algebraic Loops”.
Data Type
Support
The IC block accepts and outputs signals of any Simulink built-in and
fixed-point data type. The Initial value parameter accepts any built-in
data type that Simulink supports. For more information, see “Data
Types Supported by Simulink” in the Simulink documentation.
2-753
IC
Parameters
and
Dialog
Box
Examples
Initial value
Specify the initial value for the input signal.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
online documentation for more information.
The following examples show how to use the IC block:
• sldemo_bounce
• sldemo_hardstop
• sldemo_enginewc
2-754
IC
Characteristics Direct Feedthrough
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes, of Initial value parameter only
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
2-755
If
Purpose
Model if-else control flow
Library
Ports & Subsystems
Description
The If block, along with If Action subsystems containing Action Port
blocks, implements standard C-like if-else logic.
The following shows a completed if-else control flow statement.
2-756
If
In this example, the inputs to the If block determine the values of
conditions represented as output ports. Each output port is attached to
an If Action subsystem. The conditions are evaluated top down starting
with the if condition. If a condition is true, its If Action subsystem is
executed and the If block does not evaluate any remaining conditions.
The preceding if-else control flow statement can be represented by
the following pseudocode.
if (u1 > 0) {
body_1;
}
else if (u2 > 0){
body_2;
}
else {
body_3;
}
You construct a Simulink if-else control flow statement like the
preceding example as follows:
1 Place an If block in the current system.
2 Open the dialog of the If block and enter as follows:
• Enter the Number of inputs field with the required number of
inputs necessary to define conditions for the if-else control flow
statement.
Elements of vector inputs can be accessed for conditions using
(row, column) arguments. For example, you can specify the
fifth element of the vector u2 in the condition u2(5) > 0 in an If
expression or Elseif expressions field.
• Enter the expression for the if condition of the if-else control
flow statement in the If expression field.
2-757
If
This creates an if output port for the If block with a label of the
form if(condition). This is the only required If Action signal
output for an If block.
• Enter expressions for any elseif conditions of the if-else control
flow statement in the Elseif expressions field.
Use a comma to separate one condition from another. Entering
these conditions creates an output port for the If block for each
condition, with a label of the form elseif(condition). elseif ports
are optional and not required for operation of the If block.
• Check the Show else condition check box to create an else
output port.
The else port is optional and not required for the operation of the
If block.
3 Create If Action subsystems to connect to each of the if, else, and
elseif ports.
These consist of a subsystem with an Action Port block. When you
place an Action Port block inside each subsystem, an input port
named Action is added to the subsystem.
4 Connect each if, else, and elseif port of the If block to the Action port
of an If Action subsystem.
When you make the connection, the icon for the If Action block is
renamed to the type of the condition that it attaches to.
Note During simulation of an if-else control flow statement, the
Action signal lines from the If block to the If Action subsystems turn
from solid to dashed.
5 In each If Action subsystem, enter the Simulink blocks appropriate
to the body to be executed for the condition it handles.
2-758
If
Note All blocks in an If Action Subsystem must run at the same
rate as the driving If block. You can achieve this by setting each
block’s sample time parameter to be either inherited (-1) or the same
value as the If block’s sample time.
In the preceding example, the If Action subsystems are named
body_1, body_2, and body_3.
Data Type
Support
Inputs u1,u2,...,un can be scalars or vectors of any built-in Simulink
data type and must all be of the same data type. The inputs cannot be of
any user-defined type, such as an enumerated type. Outputs from the
if, else, and elseif ports are Action signals to If Action subsystems
that you create by using Action Port blocks and subsystems.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-759
If
Parameters
and
Dialog
Box
2-760
Number of inputs
Specify the number of inputs to the If block. These appear as data
input ports labeled with a 'u' character followed by a number,
1,2,...,n, where n equals the number of inputs that you specify.
If
If expression
Specify the condition for the if output port. This condition
appears on the If block adjacent to the if output port. The if
expression can use any of the following operators: <. <=,
==, ~=, >, >=, &, |, ~, (), unary-minus. The If Action
subsystem attached to the if port executes if its condition is
true. The expression must not contain data type expressions, for
example, int8(6), and must not reference workspace variables
whose data type is other than double or single.
Note You cannot tune this expression during simulation in
Normal or Accelerator mode (see “How Acceleration Modes
Work”), or in generated code.
The If block does not support custom storage classes. See “Custom
Storage Classes” in the Embedded Coder documentation.
Elseif expressions
Specify a string list of elseif conditions delimited by commas.
These conditions appear below the if port and above the else
port when you select the Show else condition check box.
elseif expressions can use any of the following operators: <,
<=, ==, ~=, >, >=, &, |, ~, (), unary-minus. The If Action
subsystem attached to an elseif port executes if its condition
is true and all of the if and elseif conditions are false. The
expression must not contain data type expressions, for example,
int8(6), and must not reference workspace variables whose data
type is other than double or single.
Note You cannot tune these expressions during simulation
in Normal or Accelerator mode (see “How Acceleration Modes
Work”), or in generated code.
2-761
If
Show else condition
If you select this check box, an else port is created. The If Action
subsystem attached to the else port executes if the if port and
all the elseif ports are false.
Enable zero-crossing detection
Select to enable zero-crossing detection. For more information,
see “Zero-Crossing Detection” in the Simulink documentation.
Sample time
Specify the sample time of the input signal. See “Specify Sample
Time” in the online documentation for more information.
Examples
The If block does not directly support fixed-point data types. However,
you can use the Compare To Constant block to work around this
limitation.
For example, consider the following floating-point model:
2-762
If
In this model, the If Action subsystems use their default configurations.
The block and simulation parameters for the model are set to their
default values except as follows:
Block or Dialog
Box
Parameter
Setting
Start time
0.0
Stop time
1.0
Type
Fixed-step
Solver
discrete (no
continuous states)
Fixed-step size
0.1
Repeating Sequence
Stair
Vector of output
values
[-2 -1 1 2].'
Repeating Sequence
Stair1
Vector of output
values
[0 0 0 0 1 1 1
1].'
If
Number of inputs
2
If expression
(u1 > 0) | (u2 >
0.5)
Show else
condition
selected
Constant
Constant value
-4
Constant1
Constant value
4
Scope
Number of axes
3
Time range
1
Configuration
Parameters —
Solver pane
2-763
If
For this model, if input u1 is greater than 0 or input u2 is greater than
0.5, the output is 4. Otherwise, the output is –4. The Scope block shows
the output, u1, and u2:
2-764
If
You can implement this block diagram as a model with fixed-point
data types:
The Repeating Sequence Stair blocks now output fixed-point data types.
The Compare To Constant blocks implement two parts of the If
expression that is used in the If block in the floating-point version of
the model, (u1 > 0) and (u2 > 0.5). The OR operation, (u1|u2), can
still be implemented inside the If block. For a fixed-point model, the
expression must be partially implemented outside of the If block as it
is here.
The block and simulation parameters for the fixed-point model are
the same as for the floating-point model with the following exceptions
and additions:
Block
Parameter
Setting
Compare To
Constant
Operator
>
Constant value
0
2-765
If
Block
Compare To
Constant1
If
Parameter
Setting
Output data type
mode
Boolean
Enable
zero-crossing
detection
off
Operator
>
Constant value
0.5
Output data type
mode
Boolean
Enable
zero-crossing
detection
off
Number of inputs
2
If expression
u1|u2
Characteristics Direct Feedthrough
2-766
Yes
Sample Time
Inherited from driving block
Scalar Expansion
No
Dimensionalized
Yes
Zero-Crossing Detection
Yes, if enabled
If Action Subsystem
Purpose
Represent subsystem whose execution is triggered by If block
Library
Ports & Subsystems
Description
The If Action Subsystem block is a Subsystem block that is
preconfigured to serve as a starting point for creating a subsystem
whose execution is triggered by an If block.
Note All blocks in an If Action Subsystem must run at the same rate
as the driving If block. You can achieve this by setting each block’s
sample time parameter to be either inherited (-1) or the same value as
the If block’s sample time.
For more information, see the If block and Modeling with Control
Flow Blocks in the “Creating a Model” chapter of the Simulink
documentation.
2-767
Increment Real World
Purpose
Increase real world value of signal by one
Library
Additional Math & Discrete / Additional Math: Increment - Decrement
Description
The Increment Real World block increases the real world value of the
signal by one. Overflows always wrap.
Data Type
Support
The Increment Real World block accepts signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
Characteristics Direct Feedthrough
Scalar Expansion
2-768
Yes
No
Increment Real World
See Also
Multidimensionalized
No
Zero-Crossing Detection
No
Decrement Real World, Increment Stored Integer
2-769
Increment Stored Integer
Purpose
Increase stored integer value of signal by one
Library
Additional Math & Discrete / Additional Math: Increment - Decrement
Description
The Increment Stored Integer block increases the stored integer value
of a signal by one.
Floating-point signals also increase by one, and overflows always wrap.
Data Type
Support
The Increment Stored Integer block accepts signals of the following
data types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
2-770
Increment Stored Integer
Characteristics Direct Feedthrough
See Also
Yes
Scalar Expansion
No
Multidimensionalized
No
Zero-Crossing Detection
No
Decrement Stored Integer, Increment Real World
2-771
Index Vector
Purpose
Switch output between different inputs based on value of first input
Library
Signal Routing
Description
The Index Vector block is an implementation of the Multiport Switch
block. See Multiport Switch for more information.
2-772
Inport
Purpose
Create input port for subsystem or external input
Library
Ports & Subsystems, Sources
Description
Inport blocks are the links from outside a system into the system.
Simulink software assigns Inport block port numbers according to
these rules:
• It automatically numbers the Inport blocks within a top-level system
or subsystem sequentially, starting with 1.
• If you add an Inport block, the label is the next available number.
• If you delete an Inport block, other port numbers are automatically
renumbered to ensure that the Inport blocks are in sequence and that
no numbers are omitted.
• If you copy an Inport block into a system, its port number is not
renumbered unless its current number conflicts with an Inport block
already in the system. If the copied Inport block port number is not in
sequence, renumber the block. Otherwise, you get an error message
when you run the simulation or update the block diagram.
You can specify the dimensions of the input to the Inport block using
the Port dimensions parameter. Entering a value of -1 lets Simulink
determine the port dimension.
The Sample time parameter is the rate at which the signal is coming
into the system. A value of -1 causes the block to inherit its sample
time from the block driving it. You might need to set this parameter for:
• Inport blocks in a top-level system.
• Models with blocks where Simulink cannot determine the sample
time, but these blocks drive Inport blocks.
For more information, see “Specify Sample Time”.
2-773
Inport
Inport Blocks in a Top-Level System
Inport blocks in a top-level system have two uses:
• To supply external inputs from the workspace, use the Configuration
Parameters dialog box (see “Techniques for Importing Signal Data”)
or the ut argument of the sim command (see sim) to specify the
inputs. If no external outputs are supplied, then the default output
is the ground value.
• To provide a means for perturbation of the model by the linmod
and trim analysis functions, use Inport blocks to inject inputs into
the system.
Inport Blocks in a Subsystem
Inport blocks in a subsystem represent inputs to the subsystem. A
signal arriving at an input port on a Subsystem block flows out of the
associated Inport block in that subsystem. The Inport block associated
with an input port on a Subsystem block is the block whose Port
number parameter matches the relative position of the input port
on the Subsystem block. For example, the Inport block whose Port
number parameter is 1 gets its signal from the block connected to the
topmost port on the Subsystem block.
If you renumber the Port number of an Inport block, the block becomes
connected to a different input port, although the block continues to
receive its signal from the same block outside the subsystem.
The Inport block name appears in the Subsystem icon as a port label.
To suppress display of the label, select the Inport block and choose
Format > Hide Name.
Inport blocks inside a subsystem support signal label propagation, but
root-level Inport blocks do not.
You can use a subsystem inport to supply fixed-point data in a structure
or any other format.
2-774
Inport
Creating Duplicate Inports
You can create any number of duplicates of an Inport block. The
duplicates are graphical representations of the original intended
to simplify block diagrams by eliminating unnecessary lines. The
duplicate has the same port number, properties, and output as the
original. Changing properties of a duplicate changes properties of the
original and vice versa.
To create a duplicate of an Inport block:
1 In the block diagram, select the block that you want to duplicate.
2 In the Model Editor menu bar, select Edit > Copy.
3 In the block diagram, place your cursor where you want to place
the duplicate.
4 Select Edit > Paste Duplicate Inport.
Connecting Buses to Root Level Inports
If you want a root level Inport of a model to produce a bus signal, you
must set the Data type parameter to the name of a bus object that
defines the bus that the Inport produces. For more information, see
“Bus Objects”.
Data Type
Support
The Inport block accepts complex or real signals of any data type that
Simulink supports, including fixed-point and enumerated data types.
The Inport block also accepts a bus object as a data type.
2-775
Inport
Note If you specify a bus object as the data type for this block,
do not set the minimum and maximum values for bus data on the
block. Simulink ignores these settings. Instead, set the minimum and
maximum values for bus elements of the bus object specified as the data
type. The values should be finite real double scalar.
For information on the Minimum and Maximum properties of a bus
element, see Simulink.BusElement.
For more information, see “Data Types Supported by Simulink”.
The numeric and data types of the block output are the same as those of
its input. You can specify the signal type, data type, and sampling mode
of an external input to a root-level Inport block using the Signal type,
Data type, and Sampling mode parameters.
The elements of a signal array connected to a root-level Inport block
must be of the same numeric and data types. Signal elements connected
to a subsystem input port can be of differing numeric and data types,
except in the following circumstance: If the subsystem contains an
Enable, Trigger, or Atomic Subsystem block and the input port, or an
element of the input port, connects directly to an output port, the input
elements must be of the same type. For example, consider the following
enabled subsystem:
2-776
Inport
In this example, the elements of a signal vector connected to In1 must
be of the same type. The elements connected to In2, however, can be of
differing types.
2-777
Inport
Parameters
and
Dialog
Box
2-778
The Main pane of the Inport block dialog box appears as follows:
Inport
The Signal Attributes pane of the Inport block dialog box appears
as follows:
2-779
Inport
2-780
Inport
• “Package” on page 2-1941
• “Icon display” on page 2-1081
• “Latch input by delaying outside signal” on page 2-785
• “Latch input for feedback signals of function-call subsystem outputs”
on page 2-786
• “Interpolate data” on page 2-788
• “Output function call” on page 2-789
• “Minimum” on page 2-1886
• “Maximum” on page 2-1887
• “Data type” on page 2-792
• “Show data type assistant” on page 2-1665
• “Mode” on page 2-795
• “Data type override” on page 2-1892
• “Signedness” on page 2-1893
• “Word length” on page 2-1896
• “Scaling” on page 2-1728
• “Fraction length” on page 2-1897
• “Slope” on page 2-1898
• “Bias” on page 2-1898
• “Output as nonvirtual bus” on page 2-803
• “Port dimensions (-1 for inherited)” on page 2-804
• “Variable-size signal” on page 2-805
• “Sample time (-1 for inherited)” on page 2-1938
• “Lock output data type setting against changes by the fixed-point
tools” on page 2-1713
2-781
Inport
• “Signal type” on page 2-808
• “Sampling mode” on page 2-809
2-782
Inport
Port number
Specify the port number of the block.
Settings
Default: 1
This parameter controls the order in which the port that corresponds to
the block appears on the parent subsystem or model block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-783
Inport
Icon display
Specify the information to be displayed on the icon of this input port.
Settings
Default: Port number
Signal name
Display the name of the signal connected to this port (or signals if
the input is a bus).
Port number
Display port number of this port.
Port number and signal name
Display both the port number and the names of the signals
connected to this port.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-784
Inport
Latch input by delaying outside signal
Output the value of the input signal at the previous time step.
Settings
Default: Off
On
Output the value of the input signal at the previous time step.
Off
Do not output the value of the input signal at the previous time
step.
Tips
• This option applies only to triggered subsystems and is enabled only
if the Inport block resides in a triggered subsystem.
• Selecting this check box enables Simulink to resolve data
dependencies among triggered subsystems that are part of a loop.
• Type sl_subsys_semantics at the MATLAB prompt for examples
using latched inputs with triggered subsystems.
• The Inport block indicates that this option is selected by displaying
<Lo>.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-785
Inport
Latch input for feedback signals of function-call subsystem
outputs
Latch the value of the input to this subsystem and prevent this
value from changing during the execution of the subsystem. For a
single function call that is branched to invoke multiple function-call
subsystems, this option allows you to break a loop formed by a signal fed
back from one of these function-call subsystems into the other. A second
functionality of this option is to prevent any change to the values of a
feedback signal from a function-call subsystem that is invoked during
the execution of this subsystem.
Settings
Default: Off
On
Latch the input value.
Off
Do not latch the input value.
Tips
• This parameter applies only to function-call subsystems and is
enabled only if the Inport block resides in a function-call subsystem.
• This parameter ensures that the subsystem inputs, including those
generated within the subsystem’s context, do not change during
execution of the subsystem.
• The Inport block indicates that this option is selected by displaying
<Li>.
2-786
Inport
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-787
Inport
Interpolate data
Cause the block to interpolate or extrapolate output at time steps for
which no corresponding workspace data exists when loading data from
the workspace.
Settings
Default: On
On
Cause the block to interpolate or extrapolate output at time steps
for which no corresponding workspace data exists when loading
data from the workspace.
Off
Do not cause the block to interpolate or extrapolate output at time
steps for which no corresponding workspace data exists when
loading data from the workspace.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-788
Inport
Output function call
Specify that the input signal is outputting a function-call trigger signal.
Settings
Default: Off
On
Input signal is the output of a function-call subsystem.
Off
Input signal is not the output of a function-call subsystem.
Tips
• Select this option if it is necessary for a current model to accept a
function-call trigger signal when referenced in the top model.
• This feature is limited to an asynchronous function call.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-789
Inport
Minimum
Specify the minimum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the minimum value for bus data on the block. Simulink ignores
this setting. Instead, set the minimum values for bus elements of the
bus object specified as the data type. For information on the Minimum
property of a bus element, see Simulink.BusElement.
Simulink software uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-790
Inport
Maximum
Specify the maximum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the maximum value for bus data on the block. Simulink ignores this
setting. Instead, set the maximum values for bus elements of the bus
object specified as the data type. For information on the Maximum
property of a bus element, see Simulink.BusElement.
Simulink software uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-791
Inport
Data type
Specify the output data type of the external input.
Settings
Default: Inherit:
Inherit:
auto
auto
A rule that inherits a data type
double
Data type is double.
single
Data type is single.
int8
Data type is int8.
uint8
Data type is uint8.
int16
Data type is int16.
uint16
Data type is uint16.
int32
Data type is int32.
uint32
Data type is uint32.
boolean
Data type is boolean.
fixdt(1,16,0)
Data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Data type is fixed point fixdt(1,16,2^0,0).
2-792
Inport
Enum:
<class name>
Data type is enumerated, for example, Enum:
Bus:
Basic Colors.
<object name>
Data type is a bus object.
<data type expression>
The name of a data type object, for example
Simulink.NumericType
Do not specify a bus object as the expression.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-793
Inport
Show data type assistant
Display the Data Type Assistant.
Settings
The Data Type Assistant helps you set the Output data type
parameter.
For more information, see “Specify Block Output Data Types”.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-794
Inport
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rule for data types. Selecting Inherit enables a
second menu/text box to the right.
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
• boolean
Fixed point
Fixed-point data types.
Enumerated
Enumerated data types. Selecting Enumerated enables a second
menu/text box to the right, where you can enter the class name.
Bus
Bus object. Selecting Bus enables a Bus object parameter to the
right, where you enter the name of a bus object that you want to
use to define the structure of the bus. If you need to create or
2-795
Inport
change a bus object, click Edit to the right of the Bus object
field to open the Simulink Bus Editor. For details about the Bus
Editor, see “Manage Bus Objects with the Bus Editor”.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
Do not specify a bus object as the expression.
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-796
Inport
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-797
Inport
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-798
Inport
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-799
Inport
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-800
Inport
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-801
Inport
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-802
Inport
Output as nonvirtual bus
Output a nonvirtual bus.
Settings
Default: Off
On
Output a nonvirtual bus.
Off
Output a virtual bus.
Tips
• Select this option if you want code generated from this model to use
a C structure to define the structure of the bus signal output by
this block.
• All signals in a nonvirtual bus must have the same sample time, even
if the elements of the associated bus object specify inherited sample
times. Any bus operation that would result in a nonvirtual bus that
violates this requirement generates an error. Therefore, if you select
this option all signals in the bus must have the same sample time.
You can use a Rate Transition block to change the sample time of an
individual signal, or of all signals in a bus, to allow the signal or bus
to be included in a nonvirtual bus.
Dependency
Specify properties via bus object enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-803
Inport
Port dimensions (-1 for inherited)
Specify the dimensions of the input signal to the block.
Settings
Default: -1
Valid values are:
-1
Dimensions are inherited from input signal
n
Vector signal of width n accepted
[m n]
Matrix signal having m rows and n columns accepted
Dependency
Clearing Specify properties via bus object enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-804
Inport
Variable-size signal
Specify the type of signals allowed into this port.
Settings
Default: Inherit
Inherit
Allow variable-size and fixed-size signals.
No
Do not allow variable-size signals.
Yes
Allow only variable-size signals.
Dependencies
When the signal at this port is a variable-size signal, the Port
dimensions parameter specifies the maximum dimensions of the
signal.
Command-Line Information
Parameter: VarSizeSig
Type: string
Value: 'Inherit’| 'No' | 'Yes'
Default: 'Inherit'
2-805
Inport
Sample time (-1 for inherited)
Specify the time interval between samples.
Settings
Default: -1
To inherit the sample time, set this parameter to -1.
See “Specify Sample Time” in the online documentation for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-806
Inport
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
2-807
Inport
Signal type
Specify the numeric type of the external input.
Settings
Default: auto
auto
Accept either real or complex as the numeric type.
real
Specify the numeric type as a real number.
complex
Specify the numeric type as a complex number.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-808
Inport
Sampling mode
Specify whether the output signal is Sample based or Frame based.
Settings
Default: auto
auto
Accept any sampling mode.
Sample based
The output signal is sample-based.
Frame based
The output signal is frame-based.
Dependency
Frame-based processing requires a DSP System Toolbox license.
For more information, see “Sample- and Frame-Based Concepts” in the
DSP System Toolbox documentation.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Characteristics Sample Time
Specified in the Sample time
parameter
Dimensionalized
Yes
Multidimensionalized
Yes
2-809
Inport
Virtual
Yes, if the block does not reside
in a conditionally-executed or
atomic subsystem and does not
connect directly to an Outport
block
For more information, see
“Virtual Blocks” in the Simulink
documentation.
Zero-Crossing Detection
See Also
Outport
Asynchronous Task Specification
2-810
No
Integrator, Integrator Limited
Purpose
Integrate signal
Library
Continuous
Description
The Integrator block outputs the integral of its input at the current
time step.
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. See “Limiting the Integral” on page 2-813
for details.
The following equation represents the output of the block y as a function
of its input u and an initial condition yo, where y and u are vector
functions of the current simulation time t.
y(t) 
t
t u( d  y
0
0
Simulink software can use a number of different numerical integration
methods to compute the Integrator block’s output, each with advantages
in particular applications. Use the Solver pane of the Configuration
Parameters dialog box (see “Solver Pane”) to select the technique best
suited to your application.
Simulink treats the Integrator block as a dynamic system with one
state, its output. The Integrator block’s input is the state’s time
derivative.
x = y(t)
xo = yo
x = u(t)
The selected solver computes the output of the Integrator block at the
current time step, using the current input value and the value of the
state at the previous time step. To support this computational model,
the Integrator block saves its output at the current time step for use by
the solver to compute its output at the next time step. The block also
2-811
Integrator, Integrator Limited
provides the solver with an initial condition for use in computing the
block’s initial state at the beginning of a simulation run. The default
value of the initial condition is 0. The block’s parameter dialog box
allows you to specify another value for the initial condition or create an
initial value input port on the block.
Use the parameter dialog box to:
• Define upper and lower limits on the integral
• Create an input that resets the block’s output (state) to its initial
value, depending on how the input changes
• Create an optional state output so that the value of the block’s output
can trigger a block reset
Use the Discrete-Time Integrator block to create a purely discrete
system.
Defining Initial Conditions
You can define the initial conditions as a parameter on the block dialog
box or input them from an external signal:
• To define the initial conditions as a block parameter, specify the
Initial condition source parameter as internal and enter the
value in the Initial condition field.
• To provide the initial conditions from an external source, specify the
Initial condition source parameter as external. An additional
input port appears under the block input.
2-812
Integrator, Integrator Limited
Note If the integrator limits its output (see “Limiting the Integral”
on page 2-813), the initial condition must fall inside the integrator’s
saturation limits. If the initial condition is outside the block
saturation limits, the block displays an error message.
Limiting the Integral
To prevent the output from exceeding specifiable levels, select the Limit
output check box and enter the limits in the appropriate parameter
fields. This action causes the block to function as a limited integrator.
When the output reaches the limits, the integral action is turned off to
prevent integral wind up. During a simulation, you can change the
limits but you cannot change whether the output is limited. The block
determines output as follows:
• When the integral is less than or equal to the Lower saturation
limit, the output is held at the Lower saturation limit.
• When the integral is between the Lower saturation limit and the
Upper saturation limit, the output is the integral.
• When the integral is greater than or equal to the Upper saturation
limit, the output is held at the Upper saturation limit.
To generate a signal that indicates when the state is being limited,
select the Show saturation port check box. A saturation port appears
below the block output port.
The signal has one of three values:
• 1 indicates that the upper limit is being applied.
• 0 indicates that the integral is not limited.
2-813
Integrator, Integrator Limited
• –1 indicates that the lower limit is being applied.
When you select this check box, the block has three zero crossings: one
to detect when it enters the upper saturation limit, one to detect when
it enters the lower saturation limit, and one to detect when it leaves
saturation.
Note For the Integrator Limited block, by default, Limit output is
selected, Upper saturation limit is set to 1, and Lower saturation
limit is set to 0.
Resetting the State
The block can reset its state to the specified initial condition based on
an external signal. To cause the block to reset its state, select one of the
External reset choices. A trigger port appears below the block’s input
port and indicates the trigger type.
• Select rising to reset the state when the reset signal rises from a
zero to a positive value or from a negative to a positive value.
• Select falling to reset the state when the reset signal falls from a
positive value to zero or from a positive to a negative value.
• Select either to reset the state when the reset signal changes from a
zero to a nonzero value or changes sign.
• Select level to reset the state when the reset signal is nonzero at the
current time step or changes from nonzero at the previous time step
to zero at the current time step.
• Select level hold to reset the state when the reset signal is nonzero
at the current time step.
2-814
Integrator, Integrator Limited
The reset port has direct feedthrough. If the block output feeds back
into this port, either directly or through a series of blocks with direct
feedthrough, an algebraic loop results (see “Algebraic Loops”). Use the
Integrator block’s state port to feed back the block’s output without
creating an algebraic loop.
Note To be compliant with the Motor Industry Software Reliability
Association (MISRA®) software standard, your model must use Boolean
signals to drive the external reset ports of Integrator blocks.
About the State Port
Selecting the Show state port check box on the Integrator block’s
parameter dialog box causes an additional output port, the state port, to
appear at the top of the Integrator block.
The output of the state port is the same as the output of the block’s
standard output port except for the following case. If the block is reset
in the current time step, the output of the state port is the value that
would have appeared at the block’s standard output if the block had not
been reset. The state port’s output appears earlier in the time step than
the output of the Integrator block’s output port. Use the state port to
avoid creating algebraic loops in these modeling scenarios:
• Self-resetting integrators (see “Creating Self-Resetting Integrators”
on page 2-816)
• Handing off a state from one enabled subsystem to another (see
“Handing Off States Between Enabled Subsystems” on page 2-818)
2-815
Integrator, Integrator Limited
Note When updating a model, Simulink checks that the state port
applies to one of these two scenarios. If not, an error message
appears. Also, you cannot log the output of this port in a referenced
model that executes in Accelerator mode. If logging is enabled for
the port, Simulink generates a "signal not found" warning during
execution of the referenced model.
Creating Self-Resetting Integrators
The Integrator block’s state port helps you avoid an algebraic loop when
creating an integrator that resets itself based on the value of its output.
Consider, for example, the following model.
This model tries to create a self-resetting integrator by feeding the
integrator’s output, subtracted from 1, back into the integrator’s reset
port. However, the model creates an algebraic loop. To compute the
integrator block’s output, Simulink software needs to know the value
of the block’s reset signal, and vice versa. Because the two values
are mutually dependent, Simulink software cannot determine either.
Therefore, an error message appears if you try to simulate or update
this model.
2-816
Integrator, Integrator Limited
The following model uses the integrator’s state port to avoid the
algebraic loop.
In this version, the value of the reset signal depends on the value of the
state port. The value of the state port is available earlier in the current
time step than the value of the integrator block’s output port. Therefore,
Simulink can determine whether the block needs to be reset before
computing the block’s output, thereby avoiding the algebraic loop.
2-817
Integrator, Integrator Limited
Handing Off States Between Enabled Subsystems
The state port helps you avoid an algebraic loop when passing a state
between two enabled subsystems. Consider, for example, the following
model.
The enabled subsystems, A and B, contain the following blocks:
Subsystem A
2-818
Subsystem B
Integrator, Integrator Limited
In this model, a constant input signal drives two enabled subsystems
that integrate the signal. A pulse generator generates an enabling
signal that causes execution to alternate between the two subsystems.
The enable port of each subsystem is set to reset, which causes the
subsystem to reset its integrator when it becomes active. Resetting the
integrator causes the integrator to read the value of its initial condition
port. The initial condition port of the integrator in each subsystem is
connected to the output port of the integrator in the other subsystem.
This connection is intended to enable continuous integration of the
input signal as execution alternates between two subsystems. However,
the connection creates an algebraic loop. To compute the output of A,
Simulink needs to know the output of B, and vice versa. Because the
outputs are mutually dependent, Simulink cannot compute the output
values. Therefore, an error message appears if you try to simulate or
update this model.
The following version of the same model uses the integrator state port
to avoid creating an algebraic loop when handing off the state.
2-819
Integrator, Integrator Limited
The enabled subsystems, A and B, contain the following blocks:
Subsystem A
Subsystem B
In this model, the initial condition of the integrator in A depends on
the value of the state port of the integrator in B, and vice versa. The
values of the state ports are updated earlier in the simulation time step
than the values of the integrator output ports. Therefore, Simulink
can compute the initial condition of either integrator without knowing
the final output value of the other integrator. For another example of
using the state port to hand off states between conditionally executed
subsystems, see the sldemo_clutch model.
Note Simulink does not permit three or more enabled subsystems to
hand off a model state. If Simulink detects that a model is handing off a
state among more than two enabled subsystems, it generates an error.
Specifying the Absolute Tolerance for the Block Outputs
By default Simulink software uses the absolute tolerance value
specified in the Configuration Parameters dialog box (see “Specifying
Error Tolerances for Variable-Step Solvers”) to compute the output
of the Integrator block. If this value does not provide sufficient error
control, specify a more appropriate value in the Absolute tolerance
2-820
Integrator, Integrator Limited
field of the Integrator block dialog box. The value that you specify is
used to compute all the block outputs.
Selecting All Options
When you select all options, the block icon looks like this.
Data Type
Support
The Integrator block accepts and outputs signals of type double on
its data ports. The external reset port accepts signals of type double
or Boolean.
2-821
Integrator, Integrator Limited
Parameters
and
2-822Dialog
Box
Integrator, Integrator Limited
External reset
Reset the states to their initial conditions when a trigger event occurs
in the reset signal.
Settings
Default: none
none
Do not reset the state to initial conditions.
rising
Reset the state when the reset signal rises from a zero to a positive
value or from a negative to a positive value.
falling
Reset the state when the reset signal falls from a positive value to
zero or from a positive to a negative value.
either
Reset the state when the reset signal changes from a zero to a
nonzero value or changes sign.
level
Reset the state when the reset signal is nonzero at the current
time step or changes from nonzero at the previous time step to
zero at the current time step.
level hold
Reset the state when the reset signal is nonzero at the current
time step.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-823
Integrator, Integrator Limited
Initial condition source
Get the initial conditions of the states.
Settings
Default: internal
internal
Get the initial conditions of the states from the Initial condition
parameter.
external
Get the initial conditions of the states from an external block.
Tips
Simulink software does not allow the initial condition of this block to
be inf or NaN.
Dependencies
Selecting internal enables the Initial condition parameter.
Selecting external disables the Initial condition parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-824
Integrator, Integrator Limited
Initial condition
Specify the states’ initial conditions.
Settings
Default: 0
Tips
Simulink software does not allow the initial condition of this block to
be inf or NaN.
Dependencies
Setting Initial condition source to internal enables this parameter.
Setting Initial condition source to external disables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-825
Integrator, Integrator Limited
Limit output
Limit the block’s output to a value between the Lower saturation
limit and Upper saturation limit parameters.
Settings
Default: Off
On
Limit the block’s output to a value between the Lower
saturation limit and Upper saturation limit parameters.
Off
Do not limit the block’s output to a value between the Lower
saturation limit and Upper saturation limit parameters.
Dependencies
This parameter enables Upper saturation limit.
This parameter enables Lower saturation limit.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-826
Integrator, Integrator Limited
Upper saturation limit
Specify the upper limit for the integral.
Settings
Default: inf
Minimum: value of Output minimum parameter
Maximum: value of Output maximum parameter
Dependencies
Limit output enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-827
Integrator, Integrator Limited
Lower saturation limit
Specify the lower limit for the integral.
Settings
Default: -inf
Minimum: value of Output minimum parameter
Maximum: value of Output maximum parameter
Dependencies
Limit output enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-828
Integrator, Integrator Limited
Show saturation port
Add a saturation output port to the block.
Settings
Default: Off
On
Add a saturation output port to the block.
Off
Do not add a saturation output port to the block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-829
Integrator, Integrator Limited
Show state port
Add an output port to the block for the block’s state.
Settings
Default: Off
On
Add an output port to the block for the block’s state.
Off
Do not add an output port to the block for the block’s state.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-830
Integrator, Integrator Limited
Absolute tolerance
Specify the absolute tolerance for computing block states.
Settings
Default: auto
• You can enter auto, 1, a real scalar, or a real vector.
• If you enter auto or 1, then Simulink uses the absolute tolerance
value in the Configuration Parameters dialog box (see “Solver Pane”)
to compute block states.
• If you enter a real scalar, then that value overrides the absolute
tolerance in the Configuration Parameters dialog box for computing
all block states.
• If you enter a real vector, then the dimension of that vector
must match the dimension of the continuous states in the block.
These values override the absolute tolerance in the Configuration
Parameters dialog box.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-831
Integrator, Integrator Limited
Ignore limit and reset when linearizing
Cause Simulink linearization commands to treat this block as
unresettable and as having no limits on its output, regardless of the
settings of the block’s reset and output limitation options.
Settings
Default: Off
On
Cause Simulink linearization commands to treat this block as
unresettable and as having no limits on its output, regardless of
the settings of the block’s reset and output limitation options.
Off
Do not cause Simulink linearization commands to treat this block
as unresettable and as having no limits on its output, regardless
of the settings of the block’s reset and output limitation options.
Tip
Use this check box to linearize a model around an operating point that
causes the integrator to reset or saturate.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-832
Integrator, Integrator Limited
Enable zero-crossing detection
Select to enable zero-crossing detection. For more information, see
“Zero-Crossing Detection” in the Simulink documentation.
Settings
Default: On
On
Use zero crossings to detect and take a time step at any of the
following events: reset, entering or leaving an upper saturation
state, entering or leaving a lower saturation state.
Off
Do not use zero crossings to detect and take a time step at any
of the following events: reset, entering or leaving an upper
saturation state, entering or leaving a lower saturation state.
If you select this check box, Limit output, and zero-crossing detection
for the model as a whole, the Integrator block uses zero crossings as
described.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-833
Integrator, Integrator Limited
2-834
Integrator, Integrator Limited
State Name (e.g., ’position’)
Assign a unique name to each state.
Settings
Default: '
'
If this field is blank, no name assignment occurs.
Tips
• To assign a name to a single state, enter the name between quotes,
for example, 'velocity'.
• To assign names to multiple states, enter a comma-delimited list
surrounded by braces, for example, {'a', 'b', 'c'}. Each name
must be unique.
• The state names apply only to the selected block.
• The number of states must divide evenly among the number of state
names.
• You can specify fewer names than states, but you cannot specify
more names than states.
For example, you can specify two names in a system with four states.
The first name applies to the first two states and the second name to
the last two states.
• To assign state names with a variable in the MATLAB workspace,
enter the variable without quotes. A variable can be a string, cell
array, or structure.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Examples
The following example models show how to use the Integrator block:
• sldemo_hardstop
• sldemo_suspn
2-835
Integrator, Integrator Limited
• sldemo_wheelspeed_absbrake
Characteristics Direct Feedthrough
See Also
2-836
Yes, of the reset and external initial
condition source ports
Sample Time
Continuous
Scalar Expansion
Yes, of parameters
States
Inherited from driving block or
parameter
Dimensionalized
Yes
Multidimensionalized
No
Zero-Crossing Detection
Yes, if enabled and you select the
Limit output check box, one for
detecting reset, one each to detect
upper and lower saturation limits,
and one when leaving saturation
Discrete-Time Integrator
Interpolation Using Prelookup
Purpose
Use precalculated index and fraction values to accelerate approximation
of N-dimensional function
Library
Lookup Tables
Description
How This Block Works with a Prelookup Block
The Interpolation Using Prelookup block works best with the Prelookup
block. The Prelookup block calculates the index and interval fraction
that specify how its input value u relates to the breakpoint data set.
You feed the resulting index and fraction values into an Interpolation
Using Prelookup block to interpolate an n-dimensional table. This
combination of blocks performs the same operation that a single
instance of the n-D Lookup Table block performs. However, the
Prelookup and Interpolation Using Prelookup blocks offer greater
flexibility that can provide more efficient simulation and code
generation. For more information, see “Efficiency of Performance” in
the Simulink documentation.
Supported Block Operations
To use the Interpolation Using Prelookup block, you specify a set of
table data values directly on the dialog box or feed values into the T
input port. Typically, these table values correspond to the breakpoint
data sets specified in Prelookup blocks. The Interpolation Using
Prelookup block generates output by looking up or estimating table
values based on index and interval fraction values fed from Prelookup
blocks. Labels for the index and interval fraction appear as k and f on
the Interpolation Using Prelookup block icon.
2-837
Interpolation Using Prelookup
When inputs for index and
interval fraction...
The Interpolation Using
Prelookup block...
Map to values in breakpoint data
sets
Outputs the table value at
the intersection of the row,
column, and higher dimension
breakpoints
Do not map to values in
breakpoint data sets, but
are within range
Interpolates appropriate table
values, using the Interpolation
method you select
Do not map to values in
breakpoint data sets, and
are out of range
Extrapolates the output value,
using the Extrapolation
method you select
How The Block Interpolates a Subset of Table Data
You can use the Number of sub-table selection dimensions
parameter to specify that interpolation occur only on a subset of the
table data. To activate this interpolation mode, set this parameter to a
positive integer. This value defines the number of dimensions to select,
starting from the highest dimension of table data. Therefore, the value
must be less than or equal to the Number of table dimensions.
Suppose that you have 3-D table data in your Interpolation Using
Prelookup block. The following behavior applies.
2-838
Number of
Selection
Dimensions
Action by the Block
Block Appearance
0
Interpolates the entire
table and does not
activate subtable
selection
Does not change
1
Interpolates the first
two dimensions and
Displays an input port
with the label sel1 that
Interpolation Using Prelookup
Number of
Selection
Dimensions
2
Action by the Block
Block Appearance
selects the third
dimension
you use to select and
interpolate 2-D tables
Interpolates the first
dimension and selects
the second and third
dimensions
Displays two input
ports with the labels
sel1 and sel2 that
you use to select and
interpolate 1-D tables
Subtable selection uses zero-based indexing. For an example of
interpolating a subset of table data, type sldemo_bpcheck at the
MATLAB command prompt.
Data Type
Support
The Interpolation Using Prelookup block accepts real signals of any
numeric data type supported by Simulink software, except Boolean.
The Interpolation Using Prelookup block supports fixed-point data
types for signals, table data, and intermediate results.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-839
Interpolation Using Prelookup
Parameters
and
Dialog
Box
The Main pane of the Interpolation Using Prelookup block dialog box
appears as follows:
Number of table dimensions
Specify the number of dimensions that the table data must have.
This value defines the number of independent variables for the
table. Enter an integer between 1 and 30 into this field.
2-840
Interpolation Using Prelookup
Table data
Specify whether to enter table data directly on the dialog box or to
inherit the data from an input port.
• If you set Source to Dialog, enter table data in the edit
field under Value. The size of the table data must match the
Number of table dimensions. For this option, you specify
table attributes on the Data Types pane.
• If you set Source to Input port, verify that an upstream
signal supplies table data to the T input port. The size of the
table data must match the Number of table dimensions.
For this option, your block inherits table attributes from the
T input port.
During block diagram editing, you can enter an empty matrix
(specified as []) or an undefined workspace variable in the edit
field under Value. Use this behavior to postpone specifying a
correctly dimensioned matrix for the table data and continue
editing the block diagram. For information about how to construct
multidimensional arrays in MATLAB, see “Multidimensional
Arrays” in the MATLAB documentation.
Click the Edit button to open the Lookup Table Editor (see “Edit
Existing LookupTables” in the Simulink documentation).
Interpolation method
Select Flat or Linear. See “Interpolation Methods” in the
Simulink documentation for more information.
Extrapolation method
Select Clip or Linear. See “Extrapolation Methods” in
the Simulink documentation for more information. The
Extrapolation method parameter is visible only when you
select Linear as the Interpolation method parameter.
The Interpolation Using Prelookup block does not support Linear
extrapolation when the input or output signals specify integer or
fixed-point data types.
2-841
Interpolation Using Prelookup
Valid index input may reach last index
Specify how block inputs for index (k) and interval fraction (f)
access the last elements of n-dimensional table data. Index values
are zero-based.
Check Box
Block Behavior
Selected
Returns the value of the last element in a
dimension of its table when:
• k indexes the last table element in the
corresponding dimension
• f is 0
Cleared
Returns the value of the last element in a
dimension of its table when:
• k indexes the next-to-last table element in
the corresponding dimension
• f is 1
This check box is visible only when:
• Interpolation method is Linear.
• Extrapolation method is Clip.
Tip When you select Valid index input may reach last index
for an Interpolation Using Prelookup block, you must also select
Use last breakpoint for input at or above upper limit for all
Prelookup blocks that feed it. This action allows the blocks to use
the same indexing convention when accessing the last elements of
their breakpoint and table data sets.
2-842
Interpolation Using Prelookup
Diagnostic for out-of-range input
Specify whether to produce a warning or error when the input k
or f is out of range. Options include:
• None — no warning or error
• Warning — display a warning in the MATLAB Command
Window and continue the simulation
• Error — halt the simulation and display an error in the
Simulation Diagnostics Viewer
Remove protection against out-of-range index in generated code
Specify whether or not to include code that checks for out-of-range
index inputs.
Check Box
Result
When to Use
Selected
Generated code
does not include
conditional
statements to check
for out-of-range
index inputs.
For code efficiency
Cleared
Generated code
includes conditional
statements to check
for out-of-range
index inputs.
For safety-critical
applications
Depending on your application, you can run the following Model
Advisor checks to verify the usage of this check box:
• By Product > Embedded Coder > Identify lookup table
blocks that generate expensive out-of-range checking
code
2-843
Interpolation Using Prelookup
• By Product > Simulink Verification and
Validation > Modeling Standards > DO-178C/DO-331
Checks > Check usage of lookup table blocks
For more information about the Model Advisor, see “Consult the
Model Advisor” in the Simulink documentation.
This check box has no effect on generated code when one of the
following is true:
• The Prelookup block feeds index values to the Interpolation
Using Prelookup block.
Because index values from the Prelookup block are always
valid, no check code is necessary.
• The data type of the input k restricts the data to valid index
values.
For example, unsigned integer data types guarantee
nonnegative index values. Therefore, unsigned input values of
k do not require check code for negative values.
Number of sub-table selection dimensions
Specify the number of dimensions of the subtable that the block
uses to compute the output. Follow these rules:
• To enable subtable selection, enter a positive integer.
This integer must be less than or equal to the Number of
table dimensions.
• To disable subtable selection, enter 0 to interpolate the entire
table.
For more information, see “How The Block Interpolates a Subset
of Table Data” on page 2-838.
2-844
Interpolation Using Prelookup
Sample time
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink documentation for more information.
The Data Types pane of the Interpolation Using Prelookup block dialog
box appears as follows:
2-845
Interpolation Using Prelookup
Note The parameters for table attributes (data type, minimum, and
maximum) are not available when you set Source to Input port. In
this case, the block inherits all table attributes from the T input port.
Table data > Data Type
Specify the table data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Same
as output
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the table
data type.
Tip Specify a table data type different from the output data type
for these cases:
• Lower memory requirement for storing table data that uses a
smaller type than the output signal
• Sharing of prescaled table data between two Interpolation
Using Prelookup blocks with different output data types
• Sharing of custom storage table data in Simulink Coder
generated code for blocks with different output data types
2-846
Interpolation Using Prelookup
Table data > Minimum
Specify the minimum value for table data. The default value is []
(unspecified).
Table data > Maximum
Specify the maximum value for table data. The default value is []
(unspecified).
Intermediate results > Data Type
Specify the intermediate results data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Same
as output
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
intermediate results data type.
Tip Use this parameter to specify higher precision for internal
computations than for table data or output data.
Output > Data Type
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
2-847
Interpolation Using Prelookup
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the output
data type.
See “Specify Block Output Data Types” in the Simulink User’s
Guide for more information.
Output > Minimum
Specify the minimum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output > Maximum
Specify the maximum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Parameter range checking (see “Check Parameter Values”)
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Lock data type settings against changes by the fixed-point tools
Select to lock all data type settings of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor. For more
information, see “Locking the Output Data Type Setting”in the
Simulink Fixed Point documentation.
2-848
Interpolation Using Prelookup
Integer rounding mode
Specify the rounding mode for fixed-point operations. For
more information, see “Rounding” in the Simulink Fixed Point
documentation.
Block parameters always round to the nearest representable
value. To control the rounding of a block parameter, enter an
expression using a MATLAB rounding function in the mask field.
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow,
and you want explicit
saturation protection
in the generated code.
Overflows saturate to
either the minimum
or maximum value
that the data type can
represent.
An overflow associated
with a signed 8-bit
integer can saturate to
–128 or 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
–126.
You want to avoid
overspecifying how
a block handles
out-of-range signals.
For more information,
see “Checking for
Signal Range Errors”.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result.
Usually, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
2-849
Interpolation Using Prelookup
Examples
In the following model, a Constant block feeds the table data values to
the T input port of the Interpolation Using Prelookup block.
The Interpolation Using Prelookup block inherits the following table
attributes from the T input port:
Table Attribute
Value
Minimum
–Inf
Maximum
Inf
Data type
single
Similarly, a Constant block feeds the breakpoint data set to the bp input
port of the Prelookup block, which inherits the following breakpoint
attributes:
Breakpoint Attribute
Value
Minimum
–Inf
Maximum
Inf
Data type
single
Simulink uses double-precision, floating-point data to perform the
computations in this model. However, the model stores the breakpoint
and table data as single-precision, floating-point data. Using a
2-850
Interpolation Using Prelookup
lower-precision data type to store breakpoint and table data reduces
the memory requirement.
For other examples, see “Prelookup and Interpolation Blocks” in the
Simulink documentation.
Characteristics Direct Feedthrough
See Also
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes
Dimensionalized
Yes
Zero-Crossing Detection
No
Prelookup
2-851
Interpreted MATLAB Function
Purpose
Apply MATLAB function or expression to input
Library
User-Defined Functions
Description
The Interpreted MATLAB Function block applies the specified
MATLAB function or expression to the input. The output of the function
must match the output dimensions of the block or an error occurs.
Some valid expressions for this block are:
sin
atan2(u(1), u(2))
u(1)^u(2)
Note This block is slower than the Fcn block because it calls the
MATLAB parser during each integration step. Consider using built-in
blocks (such as the Fcn block or the Math Function block) instead.
Alternatively, you can write the function as a MATLAB S-function or
MEX-file S-function, then access it using the S-Function block.
Data Type
Support
2-852
The Interpreted MATLAB Function block accepts one real or complex
input of type double and generates real or complex output of type
double, depending on the setting of the Output signal type parameter.
Interpreted MATLAB Function
Parameters
and
Dialog
Box
MATLAB function
Specify the function or expression. If you specify a function only,
it is not necessary to include the input argument in parentheses.
2-853
Interpreted MATLAB Function
Output dimensions
Specify the dimensions of the signal output by this block. If the
output dimensions are to be the same as the dimensions of the
input signal, specify –1. Otherwise, enter the dimensions of the
output signal, for example, 2 for a two-element vector. In either
case, the output dimensions must match the dimensions of the
value returned by the function or expression in the MATLAB
function field.
Output signal type
Specify the output signal type of the block as real, complex, or
auto. A value of auto sets the output type to be the same as the
type of the input signal.
Collapse 2-D results to 1-D
Select this check box to output a 2-D array as a 1-D array
containing the 2-D array’s elements in column-major order.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
online documentation for more information.
Characteristics Direct Feedthrough
2-854
Yes
Sample Time
Inherited from the driving block
Scalar Expansion
N/A
Dimensionalized
Yes
Zero-Crossing Detection
No
Interval Test
Purpose
Determine if signal is in specified interval
Library
Logic and Bit Operations
Description
The Interval Test 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.
Data Type
Support
The Interval Test block accepts signals of the following data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
In this case, the Upper limit and Lower limit values must be of
the same enumerated type.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-855
Interval Test
Parameters
and
Dialog
Box
Interval closed on right
When you select this check box, the Upper limit is included in
the interval for which the block outputs TRUE.
Upper limit
The upper limit of the interval for which the block outputs TRUE.
Interval closed on left
When you select this check box, the Lower limit is included in
the interval for which the block outputs TRUE.
2-856
Interval Test
Lower limit
The lower limit of the interval for which the block outputs TRUE.
Output data type
Select the output data type: boolean or uint8.
Characteristics Direct Feedthrough
See Also
Yes
Scalar Expansion
Yes
Zero-Crossing Detection
No
Interval Test Dynamic
2-857
Interval Test Dynamic
Purpose
Determine if signal is in specified interval
Library
Logic and Bit Operations
Description
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.
Data Type
Support
The Interval Test Dynamic block accepts signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated
In this case, all inputs must be of the same enumerated type.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-858
Interval Test Dynamic
Parameters
and
Dialog
Box
Interval closed on right
When you select this check box, the value of the signal connected
to the block’s “up” input port is included in the interval for which
the block outputs TRUE.
Interval closed on left
When you select this check box, the value of the signal connected
to the block’s “lo” input port is included in the interval for which
the block outputs TRUE.
Output data type
Select the output data type: boolean or uint8.
Characteristics Direct Feedthrough
Yes
Scalar Expansion
Yes
Zero-Crossing Detection
No
2-859
Interval Test Dynamic
See Also
2-860
Interval Test
Level-2 MATLAB S-Function
Purpose
Use Level-2 MATLAB S-function in model
Library
User-Defined Functions
Description
This block allows you to use a Level-2 MATLAB S-function (see “Write
Level-2 MATLAB S-Functions”) in a model. To do this, create an
instance of this block in the model. Then enter the name of the Level-2
MATLAB S-function in the S-function name field of the block’s
parameter dialog box.
Note Use the S-Function block to include a Level-1 MATLAB
S-function in a block.
If the Level-2 MATLAB S-function defines any additional parameters,
you can enter them in the Parameters field of the block’s parameter
dialog box. Enter the parameters as MATLAB expressions that evaluate
to their values in the order defined by the MATLAB S-function. Use
commas to separate each expression.
If a model includes a Level-2 MATLAB S-Function block, and an
error occurs in the S-function, the Level-2 MATLAB S-Function block
displays MATLAB stack trace information for the error in a dialog box.
Click OK to close the dialog box.
Data Type
Support
Depends on the MATLAB file that defines the behavior of a particular
instance of this block.
2-861
Level-2 MATLAB S-Function
Parameters
and
Dialog
Box
S-function name
Specify the name of a MATLAB function that defines the behavior
of this block. The MATLAB function must follow the Level-2
standard for writing MATLAB S-functions (see “Write Level-2
MATLAB S-Functions” for details).
Parameters
Specify values of the parameters of this block.
Characteristics Direct Feedthrough
2-862
Depends on the MATLAB S-function
Sample Time
Depends on the MATLAB S-function
Scalar Expansion
Depends on the MATLAB S-function
Dimensionalized
Depends on the MATLAB S-function
Multidimensionalized
Yes
Zero Crossing
No
Logical Operator
Purpose
Perform specified logical operation on input
Library
Logic and Bit Operations
Description
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.
You select the Boolean operation connecting the inputs with the
Operator parameter list. If you select rectangular as the Icon shape
property, the block updates to display the name of the selected operator.
The supported operations are given below.
Operation
Description
AND
TRUE if all inputs are TRUE
OR
TRUE if at least one input is TRUE
NAND
TRUE if at least one input is FALSE
NOR
TRUE when no inputs are TRUE
XOR
TRUE if an odd number of inputs are TRUE
NXOR
TRUE if an even number of inputs are TRUE
NOT
TRUE if the input is FALSE
If you select distinctive as the Icon shape, the block’s appearance
indicates its function. Simulink software displays a distinctive shape
for the selected operator, conforming to the IEEE Standard Graphic
Symbols for Logic Functions:
2-863
Logical Operator
The number of input ports is specified with the Number of input
ports parameter. The output type is specified with the Output data
type parameter. An output value is 1 if TRUE and 0 if FALSE.
Note The output data type should represent zero exactly. Data types
that satisfy this condition include signed and unsigned integers, and
any floating-point data type.
The size of the output depends on input vector size and the selected
operator:
• If the block has more than one input, any nonscalar inputs must have
the same dimensions. For example, if any input is a 2-by-2 array, all
other nonscalar inputs must also be 2-by-2 arrays.
Scalar inputs are expanded to have the same dimensions as the
nonscalar inputs.
If the block has more than one input, the output has the same
dimensions as the inputs (after scalar expansion) and each output
element is the result of applying the specified logical operation to the
corresponding input elements. For example, if the specified operation
is AND and the inputs are 2-by-2 arrays, the output is a 2-by-2 array
whose top left element is the result of applying AND to the top left
elements of the inputs, etc.
2-864
Logical Operator
• For a single vector input, the block applies the operation (except the
NOT operator) to all elements of the vector. The output is always a
scalar.
• The NOT operator accepts only one input, which can be a scalar or a
vector. If the input is a vector, the output is a vector of the same size
containing the logical complements of the input vector elements.
When configured as a multi-input XOR gate, this block performs an
addition- modulo-two operation as mandated by the IEEE Standard
for Logic Elements.
Data Type
Support
The Logical Operator block accepts real signals of any numeric data
type that Simulink supports, including fixed-point data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
The Main pane of the Logical Operator block dialog box appears as
follows:
2-865
Logical Operator
The Data Type pane of the Logical Operator block dialog box appears
as follows:
2-866
Logical Operator
Show data type assistant
Display the Data Type Assistant.
Settings
The Data Type Assistant helps you set the Output data type
parameter.
For more information, see “Specify Block Output Data Types”.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-867
Logical Operator
Operator
Select logical operator to apply to block inputs.
Settings
Default: AND
AND
TRUE if all inputs are TRUE
OR
TRUE if at least one input is TRUE
NAND
TRUE if at least one input is FALSE
NOR
TRUE when no inputs are TRUE
XOR
TRUE if an odd number of inputs are TRUE
NXOR
TRUE if an even number of inputs are TRUE
NOT
TRUE if the input is FALSE
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-868
Logical Operator
Number of input ports
Specify number of block inputs.
Settings
Default: 2
• The value must be appropriate for the selected operator.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-869
Logical Operator
Icon shape
Specify shape of the block icon.
Settings
Default: rectangular
rectangular
Result in a rectangular block that displays the name of the
selected operator.
distinctive
Use the graphic symbol for the selected operator as specified by
the IEEE standard.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-870
Logical Operator
Sample time (-1 for inherited)
Enter the discrete interval between sample time hits or specify another
appropriate sample time such as continuous or inherited.
Settings
Default: -1
By default, the block inherits its sample time based upon the context of
the block within the model. To set a different sample time, enter a valid
sample time based upon the table in “Types of Sample Time”.
See also “Specify Sample Time” in the online documentation for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-871
Logical Operator
Require all inputs and output to have the same data type
Require all inputs and the output to have the same data type.
Settings
Default: Off
On
Require all inputs and the output to have the same data type.
Off
Do not require all inputs and the output to have the same data
type.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-872
Logical Operator
Output data type
Specify the output data type.
Settings
Default: boolean
Inherit: Logical (see Configuration Parameters:
Optimization)
Uses the Implement logic signals as Boolean data
configuration parameter (see “Implement logic signals as Boolean
data (vs. double)”) to specify the output data type.
Note This option supports models created before the boolean
option was available. Use one of the other options, preferably
boolean, for new models.
boolean
Specifies output data type is boolean.
fixdt(1,16)
Specifies output data type is fixdt(1,16).
<data type expression>
Uses the name of a data type object, for example,
Simulink.NumericType.
Tip To enter a built-in data type (double, single, int8, uint8,
int16, uint16, int32, or uint32), enclose the expression in single
quotes. For example, enter 'double' instead of double.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-873
Logical Operator
Mode
Select the category of data to specify.
Settings
Default: Built in
Inherit
Specifies inheritance rules for data types. Selecting Inherit
enables Logical (see Configuration Parameters:
Optimization).
Built in
Specifies built-in data types. Selecting Built in enables boolean.
Fixed point
Specifies fixed-point data types.
Expression
Specifies expressions that evaluate to data types.
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-874
Logical Operator
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-875
Logical Operator
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-876
Logical Operator
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-877
Logical Operator
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Integer
Integer
Specify integer. This setting has the same result as specifying a
binary point location and setting fraction length to 0.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type”.
2-878
Logical Operator
Examples
Logical Operator Block: AND Operator
In the sldemo_fuelsys model, the fuel_rate_control/airflow_calc
subsystem uses a Logical Operator block as an AND operator:
The output of the Logical Operator block (the enable_integration
signal) feeds into the control port of a Switch block that activates
feedback control.
When the Logical Operator
block output is...
Feedback control...
1
Occurs
0
Does not occur
2-879
Logical Operator
Logical Operator Block: OR Operator
In the sldemo_hardstop model, the Logical Operator block appears
as an OR operator:
2-880
Logical Operator
The output of the Logical Operator block feeds into the trigger port
of an Integrator block to control whether velocity resets to the initial
condition.
When the Logical Operator
block output changes...
The Integrator block...
From 0 to 1
Resets the velocity
From 1 to 0
Does not reset velocity
2-881
Logical Operator
Logical Operator Block: NOT Operator
In the sldemo_clutch model, the Logical Operator block appears as a
NOT operator:
2-882
Logical Operator
The output of the Logical Operator block (the clutch slipping signal)
feeds into the trigger port of an enabled subsystem.
When the Logical Operator
block outputs...
The Unlocked subsystem is...
1
Enabled
0
Disabled
Characteristics Direct Feedthrough
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes, of inputs
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
2-883
1-D Lookup Table
Purpose
Approximate one-dimensional function
Library
Lookup Tables
Description
The 1-D Lookup Table block is a one-dimensional version of the n-D
Lookup Table block.
2-884
2-D Lookup Table
Purpose
Approximate two-dimensional function
Library
Lookup Tables
Description
The 2-D Lookup Table block is a two-dimensional version of the n-D
Lookup Table block.
2-885
n-D Lookup Table
Purpose
Approximate N-dimensional function
Library
Lookup Tables
Description
Supported Block Operations
The n-D Lookup Table block evaluates a sampled representation of
a function in N variables
y = F ( x1 , x2 , x3 ,..., x N )
where the function F can be empirical. The block maps inputs to an
output value by looking up or interpolating a table of values you define
with block parameters. The block supports flat (constant), linear, and
cubic-spline interpolation methods. You can apply these methods to a
table of any dimension from 1 through 30.
In the following block, the first input identifies the first dimension (row)
breakpoints, the second input identifies the second dimension (column)
breakpoints, and so on.
See “How to Rotate a Block” in the Simulink documentation for a
description of the port order for various block orientations.
Specification of Breakpoint and Table Data
The following block parameters define the breakpoint and table data.
2-886
n-D Lookup Table
Block Parameter
Purpose
Number of table dimensions
Specifies the number of
dimensions of your lookup
table.
Breakpoints
Specifies a breakpoint vector that
corresponds to each dimension of
your lookup table.
Table data
Defines the associated set of
output values.
Tip Evenly spaced breakpoints can make the generated code
division-free. For more information, see fixpt_evenspace_cleanup in
the Simulink documentation and “Identify questionable fixed-point
operations” in the Simulink Coder documentation.
How the Block Generates Output
The n-D Lookup Table block generates output by looking up or
estimating table values based on the input values:
When block inputs...
The n-D Lookup Table block...
Match the values of indices in
breakpoint data sets
Outputs the table value at
the intersection of the row,
column, and higher dimension
breakpoints
Do not match the values of indices
in breakpoint data sets, but are
within range
Interpolates appropriate table
values, using the Interpolation
method you select
Do not match the values of indices
in breakpoint data sets, and are
out of range
Extrapolates the output value,
using the Extrapolation
method you select
2-887
n-D Lookup Table
Other Blocks That Perform Equivalent Operations
You can use the Interpolation Using Prelookup block with the Prelookup
block to perform the equivalent operation of one n-D Lookup Table
block. This combination of blocks offers greater flexibility that can
result in more efficient simulation performance for linear interpolations.
When the lookup operation is an array access that does not require
interpolation, use the Direct Lookup Table (n-D) block. For example, if
you have an integer value k and you want the kth element of a table,
y = table(k), interpolation is unnecessary.
Data Type
Support
The n-D Lookup Table block supports all numeric data types that
Simulink supports, including fixed-point data types. For more
information, see “Data Types Supported by Simulink” in the Simulink
documentation.
For cubic spline interpolation and linear extrapolation modes, the
following parameters must use the same floating-point type:
• Table data
• Breakpoints
• Fraction
• Intermediate results
• Output
Inputs for indexing must be real, but table data can be complex.
2-888
n-D Lookup Table
Parameters
and
Dialog
Box
The Table and Breakpoints pane of the n-D Lookup Table block
dialog box appears as follows:
Number of table dimensions
Enter the number of dimensions of the lookup table by specifying
an integer from 1 to 30. This parameter determines:
2-889
n-D Lookup Table
• The number of independent variables for the table and the
number of block inputs
• The number of breakpoint sets to specify
Table data
Enter the table of output values.
During simulation, the matrix size must match the dimensions
defined by the Number of table dimensions parameter.
However, during block diagram editing, you can enter an empty
matrix (specified as []) or an undefined workspace variable. This
technique lets you postpone specifying a correctly dimensioned
matrix for the table data and continue editing the block diagram.
For information about how to construct multidimensional arrays
in MATLAB, see “Multidimensional Arrays” in the MATLAB
online documentation.
Breakpoints
In each Breakpoints row, enter the breakpoint set that
corresponds to each dimension of table data. For each dimension,
specify breakpoints as a 1-by-n or n-by-1 vector whose values
are strictly monotonically increasing.
Edit table and breakpoints
Click this button to open the Lookup Table Editor. For more
information, see “Edit Existing LookupTables” in the Simulink
documentation.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink documentation.
2-890
n-D Lookup Table
The Algorithm pane of the n-D Lookup Table block dialog box appears
as follows:
Interpolation method
Select Flat, Linear, or Cubic spline. See “Interpolation
Methods” in the Simulink documentation for more information.
If you select Cubic spline, the block supports only scalar signals.
The other interpolation methods support nonscalar signals.
2-891
n-D Lookup Table
Extrapolation method
Select Clip, Linear, or Cubic spline. See “Extrapolation
Methods” in the Simulink documentation for more information.
To select Cubic spline for Extrapolation method, you must
also select Cubic spline for Interpolation method.
Use last table value for inputs at or above last breakpoint
Specify the indexing convention that the block uses to address the
last element of a breakpoint set and its corresponding table value.
Check Box
Index That the
Block Uses
Interval Fraction
Selected
Last element of a
breakpoint set
0
Cleared
Next-to-last
element of a
breakpoint set
1
This parameter is visible only when:
• Interpolation method is Linear.
• Extrapolation method is Clip.
Diagnostic for out-of-range input
Specify whether to produce a warning or error when the input is
out of range. Options include:
• None — no warning or error
• Warning — display a warning in the MATLAB Command
Window and continue the simulation
• Error — halt the simulation and display an error in the
Simulation Diagnostics Viewer
2-892
n-D Lookup Table
Remove protection against out-of-range input in generated code
Specify whether or not to include code that checks for out-of-range
breakpoint input values.
Check Box
Result
When to Use
Selected
Generated code
does not include
conditional
statements to check
for out-of-range
breakpoint inputs.
For code efficiency
Cleared
Generated code
includes conditional
statements to check
for out-of-range
breakpoint inputs.
For safety-critical
applications
Depending on your application, you can run the following Model
Advisor checks to verify the usage of this check box:
• By Product > Embedded Coder > Identify lookup table
blocks that generate expensive out-of-range checking
code
• By Product > Simulink Verification and
Validation > Modeling Standards > DO-178C/DO-331
Checks > Check usage of lookup table blocks
For more information about the Model Advisor, see “Consult the
Model Advisor” in the Simulink documentation.
Index search method
Select Evenly spaced points, Linear search, or Binary
search. Each search method has speed advantages in different
circumstances:
2-893
n-D Lookup Table
• For evenly spaced breakpoint sets (for example, 10, 20, 30, and
so on), you achieve optimal speed by selecting Evenly spaced
points to calculate table indices.
This algorithm uses only the first two breakpoints of a set to
determine the offset and spacing of the remaining points.
• For unevenly spaced breakpoint sets, follow these guidelines:
— If input signals do not vary much between time steps,
selecting Linear search with Begin index search using
previous index result produces the best performance.
— If input signals jump more than one or two table intervals
per time step, selecting Binary search produces the best
performance.
A suboptimal choice of index search method can lead to slow
performance of models that rely heavily on lookup tables.
Note The generated code stores only the first breakpoint, the
spacing, and the number of breakpoints when:
• The breakpoint data is not tunable.
• The index search method is Evenly spaced points.
Begin index search using previous index result
Select this check box when you want the block to start its search
using the index found at the previous time step. For inputs that
change slowly with respect to the interval size, enabling this
option can improve performance. Otherwise, the linear search
and binary search methods can take longer, especially for large
breakpoint sets.
Use one input port for all input data
Select this check box to use only one input port that expects a
signal that is N elements wide for an N-dimensional table. This
2-894
n-D Lookup Table
option is useful for removing line clutter on a block diagram with
many lookup tables.
Note When you select this check box, one input port with the
label u appears on the block.
Support tunable table size in code generation
Select this check box to enable tunable table size in the generated
code. This option enables you to change the size and values of
the lookup table and breakpoint data without regenerating or
recompiling the code.
If you set Interpolation method to Cubic spline, this check
box is not available.
Maximum indices for each dimension
Specify the maximum index values for each table dimension using
zero-based indexing. You can specify a scalar or vector of positive
integer values using the following data types:
• Built-in floating-point types: double and single
• Built-in integer types: int8, int16, int32, uint8, uint16, and
uint32
Here are some examples of valid specifications:
• [4 6] for a 5-by-7 table
• [int8(2) int16(5) int32(9)] for a 3-by-6-by-10 table
This parameter is available when you select Support tunable
table size in code generation.
2-895
n-D Lookup Table
The Data Types pane of the n-D Lookup Table block dialog box appears
as follows:
Note The dialog box can expand to show additional data type options.
Up to 30 breakpoint data type specifications can appear.
2-896
n-D Lookup Table
Table data > Data Type
Specify the table data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Same
as output
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the table
data type.
Tip Specify a table data type different from the output data type
for these cases:
• Lower memory requirement for storing table data that uses a
smaller type than the output signal
• Sharing of prescaled table data between two n-D Lookup Table
blocks with different output data types
• Sharing of custom storage table data in the generated code for
blocks with different output data types
Table data > Minimum
Specify the minimum value for table data. The default value is []
(unspecified).
Table data > Maximum
Specify the maximum value for table data. The default value is []
(unspecified).
2-897
n-D Lookup Table
Breakpoints > Data Type
Specify the data type for a set of breakpoint data. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Same
as corresponding input
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
breakpoint data type.
See “Specify Data Types Using Data Type Assistant” in the
Simulink documentation for more information.
Tip Specify a breakpoint data type different from the
corresponding input data type for these cases:
• Lower memory requirement for storing breakpoint data that
uses a smaller type than the input signal
• Sharing of prescaled breakpoint data between two n-D Lookup
Table blocks with different input data types
• Sharing of custom storage breakpoint data in the generated
code for blocks with different input data types
Breakpoints > Minimum
Specify the minimum value that a set of breakpoint data can
have. The default value is [] (unspecified).
2-898
n-D Lookup Table
Breakpoints > Maximum
Specify the maximum value that a set of breakpoint data can
have. The default value is [] (unspecified).
Fraction > Data Type
Specify the fraction data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
fraction data type.
See “Specify Data Types Using Data Type Assistant” in the
Simulink documentation for more information.
Intermediate results > Data Type
Specify the intermediate results data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Same
as output
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
2-899
n-D Lookup Table
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
intermediate results data type.
Tip Use this parameter to specify higher (or lower) precision for
internal computations than for table data or output data.
Output > Data Type
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the output
data type.
See “Specify Block Output Data Types” for more information.
Output > Minimum
Specify the minimum value that the block outputs. The default
value is [] (unspecified). Simulink software uses this value to
perform:
• Parameter range checking (see “Check Parameter Values”)
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
2-900
n-D Lookup Table
Output > Maximum
Specify the maximum value that the block outputs. The default
value is [] (unspecified). Simulink software uses this value to
perform:
• Parameter range checking (see “Check Parameter Values”)
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Require all inputs to have the same data type
Select to require all inputs to have the same data type.
Lock data type settings against changes by the fixed-point tools
Select to lock all data type settings of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Overview of the Fixed-Point Tool” and
“Preparation for Fixed-Point Conversion” in the Simulink Fixed
Point documentation.
Integer rounding mode
Specify the rounding mode for fixed-point lookup table calculations
that occur during simulation or execution of code generated from
the model. For more information, see “Rounding” in the Simulink®
Fixed Point™ documentation.
This option does not affect rounding of values of block parameters.
Simulink rounds such values to the nearest representable integer
value. To control the rounding of a block parameter, enter an
expression using a MATLAB rounding function into the edit field
on the block dialog box.
2-901
n-D Lookup Table
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow and
you want explicit
saturation protection
in the generated code.
Overflows saturate to
either the minimum
or maximum value
that the data type can
represent.
An overflow associated
with a signed 8-bit
integer can saturate to
-128 or 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
-126.
You want to avoid
overspecifying how
a block handles
out-of-range signals.
For more information,
see “Checking for
Signal Range Errors”.
Tip If you save your model as version R2009a or earlier, this
check box setting has no effect and no saturation code appears.
This behavior preserves backward compatibility.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result. In
general, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
2-902
n-D Lookup Table
Examples
Interpolation and Extrapolation Behavior
For an example that illustrates linear interpolation and extrapolation
methods of this block, see “Create a Logarithm Lookup Table” in the
Simulink documentation.
For an example of entering breakpoint and table data, see “Entering
Data in a Block Parameter Dialog Box” in the Simulink documentation.
Tunable Table Size in the Generated Code
Suppose that you have a lookup table and want to make the size tunable
in the generated code. Assume that:
• You define a Simulink.Parameter structure in the preload function
of your model:
p = Simulink.Parameter;
p.Value.MaxIdx = [2 2];
p.Value.BP1 = [1 2 3];
p.Value.BP2 = [1 4 16];
p.Value.Table = [4 5 6; 16 19 20; 10 18 23];
p.DataType = 'Bus: slLookupTable';
p.CoderInfo.StorageClass = 'ExportedGlobal';
% Create bus object slBus1 from MATLAB structure
Simulink.Bus.createObject(p.Value);
slLookupTable = slBus1;
slLookupTable.Elements(1).DataType = 'uint32';
• The following block parameters apply in the n-D Lookup Table block
dialog box:
Parameter
Value
Number of table dimensions
2
Table data
p.Table
Breakpoints 1
p.BP1
2-903
n-D Lookup Table
Parameter
Value
Breakpoints 2
p.BP2
Support tunable table size in
code generation
on
Maximum indices for each
dimension
p.MaxIdx
The generated model_types.h header file contains a type definition
that looks something like this:
typedef struct {
uint32_T MaxIdx[2];
real_T BP1[3];
real_T BP2[3];
real_T Table[9];
} slLookupTable;
The generated model.c file contains code that looks something like this:
/* Exported block parameters */
slLookupTable p = {
{ 2U, 2U },
{ 1.0, 2.0, 3.0 },
{ 1.0, 4.0, 16.0 },
{ 4.0, 16.0, 10.0, 5.0, 19.0, 18.0, 6.0, 20.0, 23.0 }
} ;
/* More code */
/* Model output function */
static void ex_lut_nd_tunable_table_output(int_T tid)
{
2-904
n-D Lookup Table
/* Lookup_n-D: '<Root>/n-D Lookup Table' incorporates:
* Inport: '<Root>/In1'
* Inport: '<Root>/In2'
*/
Y = look2_binlcpw(U1, U2, p.BP1, p.BP2, p.Table, ...
p.MaxIdx, p.MaxIdx[0] + 1U);
/* Outport: '<Root>/Out1' */
ex_lut_nd_tunable_table_Y.Out1 = Y;
/* tid is required for a uniform function interface.
* Argument tid is not used in the function. */
UNUSED_PARAMETER(tid);
}
The highlighted line of code specifies a tunable table size for the lookup
table. You can change the size and values of the lookup table and
breakpoint data without regenerating or recompiling the code.
Characteristics Direct Feedthrough
See Also
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes
Dimensionalized
Yes, if you do not select Cubic
spline for Interpolation method
Zero-Crossing Detection
No
Prelookup, Interpolation Using Prelookup
2-905
Lookup Table Dynamic
Purpose
Approximate one-dimensional function using dynamic table
Library
Lookup Tables
Description
How This Block Differs from Other Lookup Table Blocks
The Lookup Table Dynamic block computes an approximation of a
function y = f(x) using xdat and ydat vectors. The lookup method can
use interpolation, extrapolation, or the original values of the input.
Using the Lookup Table Dynamic block, you can change the table data
without stopping the simulation. For example, you can incorporate new
table data if the physical system you are simulating changes.
Inputs for Breakpoint and Table Data
The xdat vector is the breakpoint data, which must be strictly
monotonically increasing. The value of the next element in the
vector must be greater than the value of the preceding element after
conversion to a fixed-point data type. Due to quantization, xdat can be
strictly monotonic for a floating-point data type, but not after conversion
to a fixed-point data type.
The ydat vector is the table data, which is an evaluation of the function
at the breakpoint values.
Note The inputs to xdat and ydat cannot be scalar (one-element
array) values. If you provide a scalar value to either of these inputs,
you see an error upon simulation. Provide a 1-by-n vector to both the
xdat and ydat inputs.
Lookup Table Definition
You define the lookup table by feeding xdat and ydat as 1-by-n vectors
to the block. To reduce ROM usage in the generated code for this block,
you can use different data types for xdat and ydat. However, these
restrictions apply:
2-906
Lookup Table Dynamic
• The xdat breakpoint data and the x input vector must have the same
sign, bias, and fractional slope. Also, the precision and range for x
must be greater than or equal to the precision and range for xdat.
• The ydat table data and the y output vector must have the same
sign, bias, and fractional slope.
Tip Breakpoints with even spacing can make Simulink Coder
generated code division-free. For more information, see
fixpt_evenspace_cleanup in the Simulink documentation and
“Identify questionable fixed-point operations” in the Simulink Coder
documentation.
How the Block Generates Output
The block uses the input values to generate output using the method
you select for Lookup Method:
Lookup Method
Block Action
Interpolation-Extrapolation
Performs linear interpolation and extrapolation of
the inputs.
• If the input matches a breakpoint, the output is
the corresponding element in the table data.
• If the input does not match a breakpoint, the
block performs linear interpolation between two
elements of the table to determine the output. If
the input falls outside the range of breakpoint
values, the block extrapolates using the first two
or last two points.
2-907
Lookup Table Dynamic
Lookup Method
Block Action
Note If you select this lookup method, Simulink
Coder software cannot generate code for this block.
Interpolation-Use End Values
(default)
Performs linear interpolation but does not
extrapolate outside the end points of the breakpoint
data. Instead, the block uses the end values.
Use Input Nearest
Finds the element in xdat nearest the current
input. The corresponding element in ydat is the
output.
Use Input Below
Finds the element in xdat nearest and below the
current input. The corresponding element in ydat
is the output. If there is no element in xdat below
the current input, the block finds the nearest
element.
Use Input Above
Finds the element in xdat nearest and above the
current input. The corresponding element in ydat
is the output. If there is no element in xdat above
the current input, the block finds the nearest
element.
Note The Use Input Nearest, Use Input Below, and Use Input
Above methods perform the same action when the input x matches a
breakpoint value.
Some continuous solvers subdivide the simulation time span into major
and minor time steps. A minor time step is a subdivision of the major
time step. The solver produces a result at each major time step and uses
results at minor time steps to improve the accuracy of the result at the
major time step. For continuous solvers, the output of the Lookup Table
2-908
Lookup Table Dynamic
Dynamic block can appear like a stair step because the signal is fixed
in minor time step to avoid incorrect results. For more information
about the effect of solvers on block output, see “Solvers” in the Simulink
documentation.
Data Type
Support
The Lookup Table Dynamic block accepts signals of the following data
types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-909
Lookup Table Dynamic
Parameters
and
Dialog
Box
The Main pane of the Lookup Table Dynamic block dialog box appears
as follows:
Lookup Method
Specify the lookup method. For details, see “How the Block
Generates Output” on page 2-907.
2-910
Lookup Table Dynamic
The Signal Attributes pane of the Lookup Table Dynamic block dialog
box appears as follows:
Output data type
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
2-911
Lookup Table Dynamic
• An expression that evaluates to a data type, for example,
fixdt('double')
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output data type parameter.
See “Specify Block Output Data Types” for more information.
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
Saturate to max or min when overflows occur
Select to have overflows saturate to the maximum or minimum
value that the data type can represent. Otherwise, overflows
wrap.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result. In
general, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
Examples
2-912
For an example of...
See...
Breakpoint and table data entry
“Entering Data Using Inports of
the Lookup Table Dynamic Block”
Block output for different lookup
methods
“Example Output for Lookup
Methods”
Lookup Table Dynamic
Characteristics Direct Feedthrough
See Also
Yes
Scalar Expansion
No
Zero-Crossing Detection
No
n-D Lookup Table
2-913
Magnitude-Angle to Complex
Purpose
Convert magnitude and/or a phase angle signal to complex signal
Library
Math Operations
Description
Supported Operations
The Magnitude-Angle to Complex block converts magnitude and phase
angle inputs to a complex output. The angle input must be in radians.
The block supports the following combinations of input dimensions
when there are two block inputs:
• Two inputs of equal dimensions
• One scalar input and the other an n-dimensional array
If the block input is an array, the output is an array of complex signals.
The elements of a magnitude input vector map to the magnitudes of the
corresponding complex output elements. Similarly, the elements of
an angle input vector map to the angles of the corresponding complex
output elements. If one input is a scalar, it maps to the corresponding
component (magnitude or angle) of all the complex output signals.
Effect of Out-of-Range Input on CORDIC Approximations
If you use the CORDIC approximation method (see “Definitions” on page
2-915), the block input for phase angle has the following restrictions:
• For signed fixed-point types, the input angle must fall within the
range [–2π, 2π) radians.
• For unsigned fixed-point types, the input angle must fall within the
range [0, 2π) radians.
2-914
Magnitude-Angle to Complex
The following table summarizes what happens for an out-of-range input:
Block Usage
Effect of Out-of-Range Input
Simulation
An error appears.
Generated code
Undefined behavior occurs.
Accelerator modes
Ensure that you use an in-range input for the Magnitude-Angle to
Complex block when you use the CORDIC approximation. Avoid relying
on undefined behavior for generated code or Accelerator modes.
Definitions
CORDIC
CORDIC is an acronym for COordinate Rotation DIgital Computer.
The Givens rotation-based CORDIC algorithm is among one of the
most hardware-efficient algorithms available because it requires only
iterative shift-add operations (see [1], [2]) The CORDIC algorithm
eliminates the need for explicit multipliers. Using CORDIC, you can
calculate various functions, such as sine, cosine, arc sine, arc cosine, arc
tangent, and vector magnitude. You can also use this algorithm for
divide, square root, and hyperbolic, and logarithmic functions.
Increasing the number of CORDIC iterations can produce more accurate
results, but doing so also increases the expense of the computation and
adds latency.
Data Type
Support
The block accepts real input signals of the following data types:
• Floating point
• Fixed point (only when Approximation method is CORDIC)
The following restrictions also apply:
• If one input uses a floating-point type, the other input must use the
same data type. For example, both signals must be double or single.
2-915
Magnitude-Angle to Complex
• If one input uses a fixed-point type, the other input must also use
a fixed-point type.
Parameters
and
Dialog
Box
The dialog box for this block appears as follows:
Input
Specify the kind of input: a magnitude input, an angle input, or
both.
2-916
Magnitude-Angle to Complex
Angle (Magnitude)
Input
What to Specify
Magnitude
The constant phase angle of
the output signal in radians
Angle
The constant magnitude of the
output signal
This parameter is not available when Input is Magnitude and
angle.
Approximation method
Specify the type of approximation for computing output.
Approximation
Method
Data Types
Supported
When to Use This
Method
None (default)
Floating point
You want to use
the default Taylor
series algorithm.
CORDIC
Floating point and
fixed point
You want a fast,
approximate
calculation.
When you use the CORDIC approximation, follow these
guidelines:
• For signed fixed-point types, the input angle must fall within
the range [–2π, 2π) radians.
• For unsigned fixed-point types, the input angle must fall within
the range [0, 2π) radians.
2-917
Magnitude-Angle to Complex
The block uses the following data type propagation rules:
Data Type of
Magnitude
Input
Approximation
Method
Data Type of Complex
Output
Floating point
None or CORDIC
Same as input
Signed, fixed
point
CORDIC
fixdt(1, WL + 2, FL)
Unsigned,
fixed point
CORDIC
where WL and FL are the
word length and fraction
length of the magnitude
fixdt(1, WL + 3, FL)
where WL and FL are the
word length and fraction
length of the magnitude
Number of iterations
Specify the number of iterations to perform the CORDIC
algorithm. The default value is 11.
Data Type of Block Inputs
Value You Can Specify
Floating point
A positive integer
Fixed point
A positive integer that does
not exceed the word length
of the magnitude input or
the word length of the phase
angle input, whichever value
is smaller
Entering a value that is not a positive integer causes an error.
This parameter is available when you set Approximation
method to CORDIC.
2-918
Magnitude-Angle to Complex
Scale output by reciprocal of gain factor
Select this check box to scale the real and imaginary parts of
the complex output by a factor of (1/CORDIC gain). This value
depends on the number of iterations you specify. As the number
of iterations goes up, the value approaches 1.647.
This check box is selected by default, which leads to a more
numerically accurate result for the complex output, X + iY.
However, scaling the output adds two extra multiplication
operations, one for X and one for Y.
This parameter is available when you set Approximation
method to CORDIC.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
online documentation for more information.
Characteristics Direct Feedthrough
References
Yes
Sample Time
Specified by the Sample time
parameter
Scalar Expansion
Yes, of the input when the function
requires two inputs
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
[1] Volder, J.E. “The CORDIC Trigonometric Computing Technique,”
IRE Transactions on Electronic Computers. Vol. EC-8, September
1959, pp. 330–334.
[2] Andraka, R. “A survey of CORDIC algorithm for FPGA based
computers.” Proceedings of the 1998 ACM/SIGDA sixth international
2-919
Magnitude-Angle to Complex
symposium on Field programmable gate arrays. Feb. 22–24, 1998, pp.
191–200.
See Also
2-920
Complex to Magnitude-Angle
Manual Switch
Purpose
Switch between two inputs
Library
Signal Routing
Description
The Manual Switch block is a toggle switch that selects one of its
two inputs to pass through to the output. To toggle between inputs,
double-click the block. The block propagates the selected input to
the output, while the block discards the unselected input. You can
interactively control the signal flow by setting the switch before you
start the simulation or by changing the switch while the simulation is
executing. The Manual Switch block retains its current state when
you save the model.
Data Type
Support
The Manual Switch block accepts real or complex signals of any data
type that Simulink supports, including fixed-point and enumerated data
types. For more information, see “Data Types Supported by Simulink”
in the Simulink documentation.
Parameters
and
Dialog
Box
Double-clicking the Manual Switch block toggles the input. To open the
block dialog box, right-click the block and select Block Parameters.
• “Allow the two inputs to differ in size” on page 2-923
2-921
Manual Switch
• “Sample time (-1 for inherited)” on page 2-1938
2-922
Manual Switch
Allow the two inputs to differ in size
Select this check box to allow input signals with different sizes.
Settings
Default: Off
On
Allows input signals with different sizes, and propagate the input
signal size to the output signal.
Off
Requires that all input signals be the same size.
Command-Line Information
Parameter: varsize
Type: string
Value: 'on' | 'off'
Default: 'off'
Sample time (-1 for inherited)
Enter the discrete interval between sample time hits or specify another
appropriate sample time such as continuous or inherited.
Settings
Default: -1
By default, the block inherits its sample time based upon the context of
the block within the model. To set a different sample time, enter a valid
sample time based upon the table in “Types of Sample Time”.
See also “Specify Sample Time” in the online documentation for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Examples
The following models show how to use the Manual Switch block:
• sldemo_auto_climatecontrol
2-923
Manual Switch
• sldemo_fuelsys
• sldemo_doublebounce
Characteristics Direct Feedthrough
Sample Time
2-924
Yes
Scalar Expansion
Specified in the Sample time
parameter
Yes
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Math Function
Purpose
Perform mathematical function
Library
Math Operations
Description
The Math Function block performs numerous common mathematical
functions.
Tip To perform square root calculations, use the Sqrt block.
You can select one of the following functions from the Function
parameter list.
Function
Description
Mathematical
Expression
MATLAB
Equivalent
exp
Exponential
eu
exp
log
Natural logarithm
ln u
log
10^u
Power of base 10
10u
10.^u
(see power)
log10
Common (base 10)
logarithm
log u
log10
magnitude^2
Complex modulus
|u|2
(abs(u)).^2
(see abs and power)
square
Power 2
u2
u.^2
(see power)
pow
Power
uv
power
conj
Complex conjugate
reciprocal
Reciprocal
1/u
1./u
(see rdivide)
hypot
Square root of sum
squares
(u2+v2)0.5
hypot
conj
2-925
Math Function
Function
Description
Mathematical
Expression
MATLAB
Equivalent
rem
Remainder after
division
—
rem
mod
Modulus after
division
—
mod
transpose
Transpose
uT
u.'
Complex conjugate
transpose
uH
hermitian
(see arithmetic
operators)
u'
(see arithmetic
operators)
The block output is the result of the operation of the function on the
input or inputs. The functions support the following types of operations.
2-926
Function
Scalar Operations
Element-Wise
Vector and Matrix
Operations
Vector and Matrix
Operations
exp
yes
yes
—
log
yes
yes
—
10^u
yes
yes
—
log10
yes
yes
—
magnitude^2
yes
yes
—
square
yes
yes
—
pow
yes
yes
—
conj
yes
yes
—
reciprocal
yes
yes
—
Math Function
Function
Scalar Operations
Element-Wise
Vector and Matrix
Operations
Vector and Matrix
Operations
hypot
yes, on two inputs
yes, on two inputs
(two vectors or two
matrices of the same
size, a scalar and a
vector, or a scalar
and a matrix)
—
rem
yes, on two inputs
yes, on two inputs
(two vectors or two
matrices of the same
size, a scalar and a
vector, or a scalar
and a matrix)
—
mod
yes, on two inputs
yes, on two inputs
(two vectors or two
matrices of the same
size, a scalar and a
vector, or a scalar
and a matrix)
—
transpose
yes
—
yes
hermitian
yes
—
yes
The name of the function appears on the block. The appropriate number
of input ports appears automatically.
Tip Use the Math Function block instead of the Fcn block when you
want vector or matrix output, because the Fcn block produces only
scalar output.
2-927
Math Function
Data Type
Support
The following table shows the input data types that each function of
the block can support.
Function
single
double
boolean
built-in
integer
fixed
point
exp
yes
yes
—
—
—
log
yes
yes
—
—
—
10^u
yes
yes
—
—
—
log10
yes
yes
—
—
—
magnitude^2
yes
yes
—
yes
yes
square
yes
yes
—
yes
yes
pow
yes
yes
—
—
—
conj
yes
yes
—
yes
yes
reciprocal
yes
yes
—
yes
yes
hypot
yes
yes
—
—
—
rem
yes
yes
—
yes
—
mod
yes
yes
—
yes
—
transpose
yes
yes
yes
yes
yes
hermitian
yes
yes
—
yes
yes
All supported modes accept both real and complex inputs, except for
reciprocal, which does not accept complex fixed-point inputs.
The block output is real or complex, depending on what you select for
Output signal type.
2-928
Math Function
Parameters
and
Dialog
Box
The Main pane of the Math Function block dialog box appears as
follows:
Function
Specify the mathematical function. See Description for more
information about the options for this parameter.
Output signal type
Specify the output signal type of the Math Function block as auto,
real, or complex.
2-929
Math Function
Function
Input Signal
Type
Output Signal Type
Auto
Real
Complex
exp, log, 10u,
log10, square,
pow, reciprocal,
conjugate,
transpose,
hermitian
real
real
real
complex
complex
complex
error
complex
magnitude
squared
real
real
real
complex
complex
real
real
complex
hypot, rem, mod
real
real
real
complex
complex
error
error
error
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
online documentation for more information.
The Signal Attributes pane of the Math Function block dialog box
appears as follows:
2-930
Math Function
Note Some parameters on this pane are available only when the
function you select in the Function parameter supports fixed-point
data types.
2-931
Math Function
Output minimum
Specify the minimum value that the block can output. The default
value is [] (unspecified). Simulink software uses this value to
perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output maximum
Specify the maximum value that the block can output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output data type
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output data type parameter.
See “Specify Block Output Data Types” in Simulink User’s Guide
for more information.
2-932
Math Function
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow,
and you want explicit
saturation protection
in the generated code.
Overflows saturate to
either the minimum
or maximum value
that the data type can
represent.
An overflow associated
with a signed 8-bit
integer can saturate to
–128 or 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
–126.
You want to avoid
overspecifying how
a block handles
out-of-range signals.
For more information,
see “Checking for
Signal Range Errors”.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result.
Usually, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
2-933
Math Function
Characteristics Direct Feedthrough
See Also
2-934
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes, of the input when the function
requires two inputs
Dimensionalized
Yes
Multidimensionalized
Yes, for all functions except
hermitian and transpose
Zero-Crossing Detection
No
Sqrt, Trigonometric Function
MATLAB Function
Purpose
Include MATLAB code in models that generate embeddable C code
Library
User-Defined Functions
Description
With a MATLAB Function block, you can write a MATLAB function for
use in a Simulink model. The MATLAB function you create executes for
simulation and generates code for a Simulink Coder target. If you are
new to the Simulink and MATLAB products, see “What Is a MATLAB
Function Block?” and “Create Model That Uses MATLAB Function
Block” for an overview.
Double-clicking the MATLAB Function block opens its editor, where
you write the MATLAB function, as in this example:
To learn more about this editor, see “MATLAB Function Block Editor”.
You specify input and output data to the MATLAB Function block in
the function header as arguments and return values. The argument
and return values of the preceding example function correspond to the
inputs and outputs of the block in the model:
2-935
MATLAB Function
You can also define data, input triggers, and function call outputs using
the Ports and Data Manager, which you access from the MATLAB
Function Block Editor by selecting Edit Data. See “Ports and Data
Manager”.
The MATLAB Function block generates efficient embeddable code
based on an analysis that determines the size, class, and complexity of
each variable. This analysis imposes the following restrictions:
• The first assignment to a variable defines its, size, class, and
complexity.
See “Best Practices for Defining Variables for C/C++ Code
Generation”.
• You cannot reassign variable properties after the initial assignment
except when using variable-size data or reusing variables in the code
for different purposes.
See “Reassignment of Variable Properties”.
In addition to language restrictions, the MATLAB Function block
supports a subset of the functions available in MATLAB. A list
of supported functions is given in “Functions Supported for Code
Generation — Alphabetical List”. These functions include functions in
common categories, such as:
• Arithmetic Operators like plus, minus, and power
2-936
MATLAB Function
• Matrix operations like size, and length
• Advanced matrix operations like lu, inv, svd, and chol
• Trigonometric functions like sin, cos, sinh, and cosh
See “Functions Supported for Code Generation — Categorical List” for a
complete list of function categories.
Note Although the code for this block attempts to produce exactly the
same results as MATLAB, differences might occur due to rounding
errors. These numerical differences, which might be a few eps initially,
can magnify after repeated operations. Reliance on the behavior of nan
is not recommended. Different C compilers can yield different results
for the same computation.
To support visualization of data, the MATLAB Function block supports
calls to MATLAB functions for simulation only. See “Call MATLAB
Functions” to understand some of the limitations of this capability, and
how it integrates with code analysis for this block. If these function
calls do not directly affect any of the Simulink inputs or outputs, the
calls do not appear in Simulink Coder generated code.
In the Ports and Data Manager, you can declare a block input to be a
Simulink parameter instead of a port. The MATLAB Function block
also supports inheritance of types and size for inputs, outputs, and
parameters. You can also specify these properties explicitly. See “Type
Function Arguments”, “Size Function Arguments”, and “Add Parameter
Arguments” for descriptions of variables that you use in MATLAB
Function blocks.
Recursive calls are not allowed in MATLAB Function blocks.
Data Type
Support
The MATLAB Function block accepts inputs of any type that Simulink
supports, including fixed-point and enumerated types. For more
information, see “Data Types Supported by Simulink”.
2-937
MATLAB Function
For more information on fixed-point support for this block, refer to
“Fixed-Point Data Types with MATLAB Function Block”.
The MATLAB Function block supports Simulink frames. For more
information, see “Sample- and Frame-Based Concepts”.
Parameters
and
Dialog
Box
The block dialog box for a MATLAB Function block is identical to
the dialog box for a Subsystem block. See the reference page for the
Subsystem, Atomic Subsystem, Nonvirtual Subsystem, CodeReuse
Subsystem blocks for information about each block parameter.
Examples
The following models shows how to use the MATLAB Function block:
• sldemo_radar_eml
• sldemo_eml_galaxy
Characteristics Direct Feedthrough
2-938
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Memory
Purpose
Output input from previous time step
Library
Discrete
Description
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. If the input is a vector, the block holds and delays all elements
of the vector by the same time step.
You specify the block output for the first time step with the Initial
condition parameter. Careful selection of this parameter can minimize
unwanted output behavior. However, you cannot specify the sample
time. This block can only inherit the sample time from the driving block
or the solver used for the entire model. For more information, see the
description for the Inherit sample time parameter.
Tip Avoid using the Memory block when:
• Your model uses the variable-step solver ode15s or ode113.
• The input to the block changes during simulation.
When the Memory block inherits a discrete sample time, the block is
analogous to the Unit Delay block. However, the Memory block does
not support state logging. If logging the final state is necessary, use a
Unit Delay block instead.
Comparison
with
Similar
Blocks
Blocks with Similar Functionality
The Unit Delay, Memory, and Zero-Order Hold blocks provide similar
functionality but have different capabilities. Also, the purpose of each
block is different. The sections that follow highlight some of these
differences.
2-939
Memory
Recommended Usage for Each Block
Block
Purpose of the Block
Reference Examples
Unit Delay
Implement a delay using
a discrete sample time
that you specify. Ideally,
the block accepts and
outputs signals with a
discrete sample time.
• sldemo_enginewc
(Compression
subsystem)
Memory
Implement a delay by
one integration time step.
Ideally, the block accepts
and outputs signals
where the sample time
is continuous or fixed in
minor time step. For more
information, see “Types
of Sample Time” in the
Simulink documentation.
• sldemo_bounce
Zero-Order
Hold
2-940
Convert an input signal
with a continuous sample
time to an output signal
with a discrete sample
time.
• sldemo_clutch
(Friction Mode
Logic/Lockup FSM
subsystem)
• sldemo_radar_eml
• aero_dap3dof
Memory
Overview of Block Capabilities
Capability
Block
Unit Delay
Memory
Zero-Order
Hold
Specification
of initial
condition
Yes
Yes
No, because the
block output at
time t = 0 must
match the input
value.
Specification
of sample
time
Yes
No, because the
block can only
inherit sample
time (from the
driving block or
the solver used
for the entire
model).
Yes
Support for
frame-based
signals
Yes
No
Yes
Support for
state logging
Yes
No
No
Effect of Solver Specification on Block Output
When you specify a discrete sample time in the dialog box for a Unit
Delay or Zero-Order Hold block, the block output can differ depending
on the solver specification for the model.
2-941
Memory
Suppose that you have a model with Unit Delay and Zero-Order Hold
blocks, which both use a discrete sample time of 1:
The Repeating Sequence Stair block uses a continuous sample time of 0
to provide input signals to the Unit Delay and Zero-Order Hold blocks.
2-942
Memory
If the model uses a fixed-step solver with a step size of 1, the scope
shows the following simulation results:
2-943
Memory
If the model uses a variable-step solver, the scope shows the following
simulation results:
The Zero-Order Hold block takes the input value of the Repeating
Sequence Stair block at t = 0, 1, 2, ... , 9 and holds each input value for
a sample period (1 second). The Unit Delay block applies the same
1-second hold to each input value of the Repeating Sequence Stair block,
but also delays each value by a sample period. The Initial conditions
2-944
Memory
parameter specifies the output for the Unit Delay block during the first
sample period. For more information about sample time, see “What Is
Sample Time?” and “Specify Sample Time”.
Solver specification for a model also affects the behavior of the Memory
block. For details, see “Examples of Memory Block Usage” on page
2-949.
Data Type
Support
The Memory block accepts real or complex signals of any data type that
Simulink supports, including fixed-point and enumerated data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Parameters
and
Dialog
Box
The Main pane of the Memory block dialog box appears as follows:
2-945
Memory
Initial condition
Specify the output at the initial integration step. This value must
be 0 when you do not use a built-in input data type. Simulink does
not allow the initial output of this block to be inf or NaN.
Inherit sample time
Select to inherit the sample time from the driving block. If you do
not select this check box, the block sample time depends on the
type of solver for simulating the model.
• If the solver is a variable-step solver, the sample time is
continuous but fixed in minor time step: [0, 1].
• If the solver is a fixed-step solver, this [0, 1] sample time
converts to the solver step size after sample-time propagation.
Direct feedthrough of input during linearization
Select to output the input during linearization and trim. This
selection sets the block mode to direct feedthrough.
Selecting this check box can cause a change in the ordering of
states in the model when using the functions linmod, dlinmod,
or trim. To extract this new state ordering, use the following
commands.
First compile the model using the following command, where
model is the name of the Simulink model.
[sizes, x0, x_str] = model([],[],[],'lincompile');
Next, terminate the compilation with the following command.
model([],[],[],'term');
The output argument, x_str, which is a cell array of the states
in the Simulink model, contains the new state ordering. When
passing a vector of states as input to the linmod, dlinmod, or trim
functions, the state vector must use this new state ordering.
2-946
Memory
Treat as a unit delay when linearizing with discrete sample time
Select to linearize the Memory block to a unit delay when the
Memory block is driven by a signal with a discrete sample time.
The State Attributes pane of the Memory block dialog box appears
as follows:
State name
Use this parameter to assign a unique name to the block state.
The default is ' '. When this field is blank, no name is assigned.
When using this parameter, remember these considerations:
• A valid identifier starts with an alphabetic or underscore
character, followed by alphanumeric or underscore characters.
• The state name applies only to the selected block.
2-947
Memory
This parameter enables State name must resolve to Simulink
signal object when you click Apply.
For more information, see “States” in the Simulink Coder
documentation.
State name must resolve to Simulink signal object
Select this check box to require that the state name resolve to a
Simulink signal object. This check box is cleared by default.
State name enables this parameter.
Selecting this check box disables Code generation storage
class.
Package
Select a package that defines the custom storage class you want
to apply. If you have defined any packages of your own, click
Refresh. This action adds all user-defined packages on your
search path to the package list.
Code generation storage class
From the list, select a state storage class.
Auto
Auto is the storage class to use for states that do not need
to interface to external code.
ExportedGlobal
The state is stored in a global variable.
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
State name enables this parameter.
2-948
Memory
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage
type qualifier.
Code generation storage type qualifier
Specify a Simulink Coder storage type qualifier. The default is '
'. When this field is blank, no qualifier is assigned.
The Simulink Coder product does not check this string for errors.
Thus, whatever value you enter appears automatically in the
variable declaration.
Setting Code generation storage class to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables this
parameter.
During simulation, the block uses the following values:
• The initial value of the signal object to which the state name is
resolved
• Min and Max values of the signal object
See “States” in the Simulink Coder documentation for more information.
Examples
of
Memory
Block
Usage
Usage with the Clock Block
The following model shows how to display the step size in a simulation.
The Sum block subtracts the time at the previous step, which the
Memory block generates, from the current time, which the Clock block
generates.
2-949
Memory
Because Inherit sample time is not selected for the Memory block,
the block sample time depends on the type of solver for simulating the
model. In this case, the model uses a fixed-step solver. Therefore, the
sample time of the Memory block is the solver step size, or 1.
If you replace the Memory block with a Unit Delay block, you get the
same results. The Unit Delay block inherits a discrete sample time of 1.
Usage with the Second-Order Integrator Block
The sldemo_bounce model shows how a bouncing ball reacts after being
tossed into the air. The dx port of the Second-Order Integrator block
and the Memory block capture the velocity of the ball just before it
hits the ground.
2-950
Memory
Because Inherit sample time is not selected for the Memory block,
the block sample time depends on the type of solver for simulating the
model. In this case, the model uses a variable-step (ode23) solver.
Therefore, the sample time of the Memory block is continuous but
fixed in minor time step: [0, 1]. When you run the model, you get
the following results:
If you replace the Memory block with a Unit Delay block, you get the
same results. However, a warning also appears due to the discrete Unit
Delay block inheriting a continuous sample time.
2-951
Memory
Usage with the Combinatorial Logic Block
The sldemo_clutch model shows how you can use the Memory block
with the Combinatorial Logic block to implement a finite-state machine.
This construct appears in the Friction Mode Logic/Lockup FSM
subsystem.
Because Inherit sample time is not selected for the Memory block,
the block sample time depends on the type of solver for simulating the
model. In this case, the model uses a variable-step (ode23) solver.
Therefore, the sample time of the Memory block is continuous but fixed
in minor time step: [0, 1].
Bus
Support
The Memory block is a bus-capable block. The input can be a virtual or
nonvirtual bus signal subject to the following restrictions:
• Initial condition must be zero, a nonzero scalar, or a finite numeric
structure.
• If Initial condition is zero or a structure, and you specify a State
name, the input cannot be a virtual bus.
• If Initial condition is a nonzero scalar, you cannot specify a State
name.
For information about specifying an initial condition structure, see
“Specify Initial Conditions for Bus Signals”.
2-952
Memory
All signals in a nonvirtual bus input to a Memory block must have the
same sample time, even if the elements of the associated bus object
specify inherited sample times. You can use a Rate Transition block
to change the sample time of an individual signal, or of all signals in
a bus. See “Nonvirtual Bus Sample Times” and Bus-Capable Blocks
for more information.
You can use an array of buses as an input signal to a Memory block.
Only the Initial condition parameter (which may be, but does not
have to be, a structure) is scalar-expanded to match the dimensions of
the array of buses. For details about defining and using an array of
buses, see “Combine Buses into an Array of Buses”.
Characteristics Bus-capable
See Also
Yes, with restrictions as noted above
Direct Feedthrough
No, except when you select Direct
feedthrough of input during
linearization
Sample Time
Continuous, but inherited from the
driving block when you select the
Inherit sample time check box
Scalar Expansion
Yes, of the Initial condition
parameter
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Unit Delay, Zero-Order Hold
2-953
Merge
Purpose
Combine multiple signals into single signal
Library
Signal Routing
Description
The Merge block combines its inputs into a single output line whose
value at any time is equal to the most recently computed output of its
driving blocks. You can specify any number of inputs by setting the
block’s Number of inputs parameter.
Use Merge blocks only to interleave input signals that update at
different times into a combined signal in which the interleaved
values retain their separate identities and times. To combine signals
that update at the same time into an array or matrix signal, use a
Concatenate block.
Merge blocks assume that all driving signals share the same signal
memory. The shared signal memory should be accessed only in
mutually exclusive fashion. Therefore, always use alternately executing
subsystems to drive Merge blocks. See “Creating Alternately Executing
Subsystems” for an example.
All signals that connect to a Merge block, or exist anywhere in a network
of Merge blocks, are functionally the same signal, and are therefore
subject to the restriction that a given signal can have at most one
associated signal object. See Simulink.Signal for more information.
Guidelines for Using the Merge Block
When you use the Merge block, follow these guidelines:
• Always use conditionally-executed subsystems to drive Merge blocks.
• Write your control logic to ensure that at most one of the driving
conditionally-executed subsystems executes at any time step.
• Do not connect more than one input of a Merge block to the same
conditionally-executed subsystem.
• Always connect a Merge block to at least two input signals.
• Ensure that all input signals have the same sample time.
2-954
Merge
• Always set the Initial output parameter of the Merge block, unless
the output port of the Merge block connects to another Merge block.
• Do not branch a signal that inputs to a Merge block, if you use
the default setting of Classic for the Model Configuration
Parameters > Diagnostics > Underspecified initialization
detection parameter. See the last example in “Proper Merge Block
Usage” on page 2-955 for additional usage guidelines relating to
branched signals.
• For all conditionally-executed subsystem Outport blocks that drive
Merge blocks, set the Output when disabled parameter to held.
Proper Merge Block Usage
For each input of a Merge block, the topmost non-atomic and nonvirtual
source must be a conditionally-executed subsystem that is not an
Iterator Subsystem.
You can use the Model Advisor to check for proper Merge block usage in
your model. For more information, see “Check for proper Merge block
usage” on page 10-36.
The following schematic shows proper Merge block usage, merging
signals from two conditionally-executed subsystems.
2-955
Merge
The following example is also a valid Merge block usage, where the
topmost nonatomic, nonvirtual source is a conditionally executed
subsystem.
Each Atomic Subsystem block contains an enabled subsystem.
2-956
Merge
You can also use multiple Merge blocks at different levels of the model
hierarchy. The following example contains a Merge block at the model
root.
A Merge block is also located inside the Enabled Subsystem block, one
level down.
2-957
Merge
A Merge block cannot connect to a Sine Wave block because that source
block is not a conditionally-executed subsystem.
A Merge block cannot connect to a For Iterator Subsystem.
A Merge block cannot connect to a branched signal.
2-958
Merge
X
In the following model, the referenced model has a signal that branches.
It inputs to a block in the referenced model and also inputs to the Merge
block that is outside of the referenced model.
2-959
Merge
Although the top-level model appears that it would work, the Subsys1
subsystem includes a Model block that references referenced_model.
The referenced model includes a signal that incorrectly branches to a
Gain block and to the Out2 Outport block, which connects to the Merge
block that is outside of the referenced model.
2-960
Merge
X
The following example also shows a branched signal in a subsystem that
connects to a Merge block, which is not allowed if you use the default
setting of Classic for the Model Configuration Parameters >
Diagnostics > Underspecified initialization detection parameter.
If you set the Underspecified initialization detection parameter to
Simplified, then the following example does not generate an error. For
more information on simplified initialization mode, see “Underspecified
initialization detection”.
2-961
Merge
X
2-962
Merge
Initial Output Value
You can specify an initial output value for the Merge block by setting
the Initial output parameter. If you do not specify an initial output
value and one or more of the driving blocks do, the initial output of
the Merge block equals the most recently evaluated initial output of
the driving blocks.
When two or more sources initialize the same Merge block, the
initialization ordering for these sources may vary. If you leave the
initial output unspecified, initialization may be inconsistent for the
simulation and the code generation of a model. For example, the
following model can produce inconsistent initialization:
• The model contains a Merge block with two inputs: one driven by
a Stateflow chart and the other driven by a conditionally executed
subsystem (such as an Enabled Subsystem).
• The Merge block Initial output parameter is unspecified (that is,
specified as empty matrix ([])).
• The Stateflow chart initializes the output being merged to val1.
• The conditionally executed subsystem initializes the output being
merged to different value val2.
• Both the Stateflow chart and the conditionally executed susystem do
not execute at the first time step.
Because the initialization ordering may vary, the output of the Merge
block at the first time step is val1 if the Stateflow chart initializes last
and val2 if the conditionally executed subsystem initializes last. The
initialization ordering is different for simulation and code generation.
To address this issue, use one of the following approaches:
• Set the Initial output parameter of the Merge block, unless the
output port of the Merge block connects to another Merge block.
2-963
Merge
• Turn on simplified initialization mode: set the Model Configuration
Parameters > Diagnostics > Data Validity > Underspecified
initialization detection parameter to Simplified.
To use the Simplified initialization setting, specify the Initial
output value for all root Merge blocks. A root Merge block is any
Merge block with an output port that does not connect to another
Merge block.
To upgrade your model to simplified initialization mode, use the
Model Advisor Check consistency of initialization parameters
for Outport and Merge blocks check.
For more information on simplified initialization mode, see
“Underspecified initialization detection”.
Single-Input Merge
Single-input merge is not supported. Each Merge block must have at
least two inputs.
Use Merge blocks only for signals that require merging. If you were
previously connecting a Merge block input to a Mux block, use a
multi-input Merge block instead.
Input Dimensions and Merge Offsets
The Merge block accepts only inputs of equal dimensions and outputs
a signal of the same dimensions as the inputs, unless you select the
Allow unequal port widths parameter.
If you select Allow unequal port widths, the block accepts scalars
and vectors (but not matrices) having differing numbers of elements.
Further, the block allows you to specify an offset for each input signal
relative to the beginning of the output signal. The width of the output
signal is
2-964
Merge
max(w1+o1, w2+o2, ... wn+on)
where w1, ... wn are the widths of the input signals and o1, ...
are the offsets for the input signals.
on
Suppose that you have the following block diagram:
The Merge block has the following output width:
max(2+0,2+1)=3
2-965
Merge
In this example, the offset of v1 is 0 and the offset of v2 is 1. The Merge
block maps the elements of v1 to the first two elements of v3 and the
elements of v2 to the last two elements of v3. Only the second element
of v3 is effectively merged, as shown in the scope output:
2-966
Merge
If you use Simplified Initialization Mode, you must clear the Allow
unequal port widths check box. The input port offsets for all input
signals must be zero.
Consider using Merge blocks only for signal elements that require true
merging. Other elements can be combined with merged elements using
the Concatenate block, as shown in the following example.
For more information on simplified initialization mode, see
“Underspecified initialization detection”.
2-967
Merge
Combining or Reordering of Input Signals
A Merge block does not accept input signals whose elements have been
reordered or partially selected. In addition, you should not connect
input signals to the Merge block that have been combined outside of a
conditionally-executed subsystem.
For example, in the following block diagram, the Merge block does not
accept the output of the first Selector block because the Selector block
interchanges the first and last elements of the vector signal. Similarly,
the Merge block does not accept the output of the second Selector block
because the Selector block selects only the first three elements.
2-968
Merge
If you use simplified initialization mode, the following arrangement
is not allowed because two signals are being combined outside of a
conditionally-executed subsystem.
2-969
Merge
You can, however, combine or reorder Merge block input signals within
a conditionally-executed subsystem. For example, the following model
is valid.
Each Enabled Subsystem contains the following blocks.
2-970
Merge
Conditionally-Executed Subsystem Outport Reset
The Outports of conditionally-executed subsystems being merged should
not reset when disabled. This action can cause multiple subsystems to
update the Merge block at the same time. Specifically, the disabled
subsystem updates the Merge block by resetting its output, while the
enabled subsystem updates the Merge block by computing its output.
To prevent this behavior, set the Outport block parameter Output
when disabled to held for each conditionally-executed subsystem
being merged.
Note If you are using Simplified Initialization Mode, you must set the
Outport block parameter Output when disabled to held.
2-971
Merge
Instead of resetting the subsystem output when it is disabled, add an
additional subsystem for the default case, and use control logic to run
this subsystem if nothing else runs. For example, see the following
block layout:
For more information on simplified initialization mode, see
“Underspecified initialization detection”.
Merging S-Function Outputs
The Merge block can merge a signal from an S-Function block only if
the memory used to store the S-Function block’s output is reusable.
Simulink software displays an error message if you attempt to update
or simulate a model that connects a nonreusable port of an S-Function
2-972
Merge
block to a Merge block. See ssSetOutputPortOptimOpts for more
information.
Data Type
Support
The Merge block accepts real or complex signals of any data type that
Simulink supports, including fixed-point and enumerated data types.
All inputs must be of the same data type and numeric type.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-973
Merge
Parameters
and
Dialog
Box
2-974
Number of inputs
Specify the number of input ports to merge.
Initial output
Specify the initial value of output. If unspecified, the initial output
equals the initial output, if any, of one of the driving blocks. You
cannot set the initial output of this block to inf or NaN.
Merge
Allow unequal port widths
Select this check box to allow the block to accept inputs having
different numbers of elements.
Input port offsets
Enter a vector to specify the offset of each input signal relative to
the beginning of the output signal.
Bus
Support
The Merge block is a bus-capable block. The inputs can be virtual or
nonvirtual bus signals subject to the following restrictions:
• The number of inputs must be greater than one.
• Initial output must be zero, a nonzero scalar, or a finite numeric
structure.
• Allow unequal port widths must be disabled.
• All inputs to the merge must be buses and must be equivalent (same
hierarchy with identical names and attributes for all elements).
For information about specifying an initial condition structure, see
“Specify Initial Conditions for Bus Signals”.
All signals in a nonvirtual bus input to a Merge block must have the
same sample time, even if the elements of the associated bus object
specify inherited sample times. You can use a Rate Transition block to
change the sample time of an individual signal, or of all signals in a bus.
See “Composite Signals” and Bus-Capable Blocks for more information.
You can use an array of buses as an input signal to a Merge block. For
details about defining and using an array of buses, see “Combine Buses
into an Array of Buses”. Using an array of buses with a Merge block
involves these limitations:
• Allow unequal port widths — Clear this parameter.
• Number of inputs — Set to a value of 2 or greater.
2-975
Merge
• Initial condition — Only this parameter (which might be, but
does not have to be, a structure) is scalar-expanded to match the
dimensions of the array of buses.
Characteristics Bus-capable
2-976
Yes, with restrictions as noted
above
Direct Feedthrough
Yes
Sample Time
Inherited from the driving block
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
MinMax
Purpose
Output minimum or maximum input value
Library
Math Operations
Description
The MinMax block outputs either the minimum or the maximum
element or elements of the inputs. You can choose the function to apply
by selecting one of the choices from the Function parameter list.
If the block has one input port, the input must be a scalar or a vector.
The block outputs a scalar equal to the minimum or maximum element
of the input vector.
If the block has multiple input ports, all nonscalar inputs must have
the same dimensions. The block expands any scalar inputs to have the
same dimensions as the nonscalar inputs. The block outputs a signal
having the same dimensions as the input. Each output element equals
the minimum or maximum of the corresponding input elements.
The MinMax block ignores any input value that is NaN, except when
every input value is NaN. When all input values are NaN, the output is
NaN, either as a scalar or the value of each output vector element.
Data Type
Support
The MinMax block accepts and outputs real signals of the following
data types:
• Floating point
• Built-in integer
• Fixed point
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-977
MinMax
Parameters
and
Dialog
Box
The Main pane of the MinMax block dialog box appears as follows:
Function
Specify whether to apply the function min or max to the input.
Number of input ports
Specify the number of inputs to the block.
2-978
MinMax
Enable zero-crossing detection
Select to enable zero-crossing detection. For more information,
see “Zero-Crossing Detection” in the Simulink documentation.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
online documentation for more information.
The Signal Attributes pane of the MinMax block dialog box appears
as follows:
2-979
MinMax
Require all inputs to have the same data type
Select this check box to require that all inputs have the same
data type.
2-980
MinMax
Output minimum
Specify the minimum value that the block should output. The
default value is [] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output maximum
Specify the maximum value that the block should output. The
default value is[] (unspecified). Simulink software uses this
value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Output data type
Specify the output data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
Output data type parameter.
See “Specify Block Output Data Types” in the Simulink User’s
Guide for more information.
2-981
MinMax
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Integer rounding mode
Specify the rounding mode for fixed-point operations. For more
information, see “Rounding”. in the Simulink Fixed Point
documentation.
Saturate on integer overflow
Action
Reasons for Taking
This Action
What Happens for
Overflows
Example
Select this
check box.
Your model has
possible overflow,
and you want explicit
saturation protection
in the generated code.
Overflows saturate to
either the minimum
or maximum value
that the data type can
represent.
An overflow associated
with a signed 8-bit
integer can saturate to
–128 or 127.
Do not select
this check
box.
You want to optimize
efficiency of your
generated code.
Overflows wrap to the
appropriate value that
is representable by the
data type.
The number 130 does
not fit in a signed 8-bit
integer and wraps to
–126.
You want to avoid
overspecifying how
a block handles
out-of-range signals.
For more information,
see “Checking for
Signal Range Errors”.
When you select this check box, saturation applies to every
internal operation on the block, not just the output or result.
Usually, the code generation process can detect when overflow is
not possible. In this case, the code generator does not produce
saturation code.
2-982
MinMax
Examples
The sldemo_fuelsys model shows how to use the MinMax block.
In the Engine Gas Dynamics/Throttle & Manifold/Throttle
subsystem, the MinMax block uses the min operator:
In the Engine Gas Dynamics/Mixing & Combustion subsystem, the
MinMax block uses the max operator:
2-983
MinMax
Characteristics Direct Feedthrough
See Also
2-984
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes, of the inputs
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
Yes, if enabled
MinMax Running Resettable
MinMax Running Resettable
Purpose
Determine minimum or maximum of signal over time
Library
Math Operations
Description
The MinMax Running Resettable block outputs the minimum or
maximum of all past inputs u. You specify whether the block outputs
the minimum or the maximum with the Function parameter.
The block can reset its state based on an external reset signal R. When
the reset signal R is TRUE, the block resets the output to the value of
the Initial condition parameter.
The input can be a scalar, vector, or matrix signal. If you specify a
scalar Initial condition parameter, the block expands the parameter
to have the same dimensions as a nonscalar input. The block outputs a
signal having the same dimensions as the input. Each output element
equals the running minimum or maximum of the corresponding input
elements.
Data Type
Support
The MinMax Running Resettable block accepts and outputs real signals
of any numeric data type that Simulink supports, except Boolean. The
MinMax Running Resettable block supports fixed-point data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-985
MinMax Running Resettable
Parameters
and
Dialog
Box
Function
Specify whether the block outputs the minimum or the maximum.
Initial condition
Specify initial condition.
Characteristics Direct Feedthrough
Scalar Expansion
See Also
2-986
MinMax
Yes
Yes
Model, Model Variants
Purpose
Include model as block in another model
Library
Ports & Subsystems
Description
The Model block allows you to include a model as a block in another
model. The included model is called a referenced model, and the model
containing it (via the Model block) is called the parent model.
The Model block displays input ports and output ports corresponding to
the top-level input and output ports of the referenced model. Use these
ports allow you to connect the referenced model to other blocks in the
parent model. See “Model Reference” for more information.
A Model block can specify the referenced model:
• Statically, as a Model block parameter value, which must name the
model literally
• Dynamically, depending on base workspace values
A Model Variants block is a Model block with variants enabled. The
Model block parameter dialog box contains the Enable Variants
button by default. If you click the Enable Variants button, the Model
Variants block parameter dialog opens. The Model Variants block
parameter dialog contains the Disable Variants button by default.
Therefore, you can use either the Model block or Model Variants block
for implementing model variants. For more information about how
to specify a referenced model for multiple specifications, see “Set Up
Model Variants”.
2-987
Model, Model Variants
By default, the contents of a referenced model are user-visible, but you
can hide the contents as described in “Protected Model”.
A signal that connects to a Model block is functionally the same signal
outside and inside the block. A given signal can have at most one
associated signal object, so the signal connected to the Model block
cannot have a signal object in both the parent and the referenced
models. For more information, see Simulink.Signal.
The Model block supports signal label propagation. For details specific
to model referencing and model variants, see:
• “Processing for Referenced Models”
• “Processing for Variants and Configurable Subsystems”
Data Type
Support
2-988
Determined by the root-level inputs and outputs of the model referenced
by the Model block.
Model, Model Variants
Parameters
and
Dialog
Box
• “Model name” on page 2-991
• “Model arguments” on page 2-992
• “Model argument values (for this instance)” on page 2-993
2-989
Model, Model Variants
• “Simulation mode” on page 2-994
• “Enable variants” on page 2-996
• “Variant choices” on page 2-998
• “Variant object” on page 2-1000
• “Condition” on page 2-1001
• “Model name” on page 2-1002
• “Model name” on page 2-1003
• “Model arguments” on page 2-1004
• “Model argument values (for this instance)” on page 2-1005
• “Simulation mode” on page 2-1006
• “Override variant conditions and use following variant” on page
2-1008
• “Variant” on page 2-1009
• “Generate preprocessor conditionals” on page 2-1010
• “Disable variants” on page 2-1010
2-990
Model, Model Variants
Model name
Name of the model this block references.
Settings
Default: <Enter Model Name>
The value must be a valid MATLAB identifier.
The extension, for example, .SLX, is optional.
Tips
• To navigate to the model that you want to reference from this block,
use the Browse button to the right of the Model name parameter.
• To confirm that the model you specify is the one you intended, you
can use the Open Model button to the right of the Model name
parameter.
Command-Line Information
Parameter: ModelNameDialog
Type: string
Value: Any valid value
Default: The name of the referenced model exactly as you typed
it in, with any surrounding whitespace removed. When you set
ModelNameDialog programmatically or with the GUI, Simulink
automatically sets the values of ModelName and ModelFile based on
the value of ModelNameDialog.
2-991
Model, Model Variants
Model arguments
Display model arguments accepted by the model referenced by this
block.
Declaring a variable to be a model argument allows each instance of the
model to use a different value for that variable.
Settings
Default: ''
This is a read-only parameter that displays model arguments for the
model referenced by this block. To create model arguments, refer to
“Using Model Arguments”.
2-992
Model, Model Variants
Model argument values (for this instance)
Specify values to be passed as model arguments to the model referenced
by this block each time the simulation invokes the model.
Settings
Enter the values in this parameter as a comma-separated list in the
same order as the corresponding argument names appear in the Model
arguments field.
Command-Line Information
Parameter: ParameterArgumentValues
Type: string
Value: Any valid value
Default: ''
2-993
Model, Model Variants
Simulation mode
Set the simulation mode for the model referenced by this block. This
setting specifies whether to simulate the model by generating and
executing code or by interpreting the model in Simulink.
Settings
Default: Accelerator
Accelerator
Creates a MEX-file for the submodel, then executes the submodel
by running the S-function.
Normal
Executes the submodel interpretively, as if the submodel were an
atomic subsystem implemented directly within the parent model.
Software-in-the-loop (SIL)
This option requires Embedded Coder software. Generates
production code using model reference target for the submodel.
This code is compiled for, and executed on, the host platform.
Processor-in-the-loop (PIL)
This option requires Embedded Coder software. Generates
production code using model reference target for the submodel.
This code is compiled for, and executed on, the target platform.
A documented target connectivity API supports exchange of data
between the host and target at each time step during the PIL
simulation.
Command-Line Information
Parameter: SimulationMode
Type: string
Value: 'Accelerator' | 'Normal' | 'Software-in-the-loop
(SIL)' | 'Processor-in-the-loop (PIL)'
Default: 'Accelerator'
See Also
• “Using Model Arguments”
• “Choosing a Simulation Mode”
2-994
Model, Model Variants
• “Overview of the Target Connectivity API”
• “Numerical Equivalence Testing”
2-995
Model, Model Variants
Enable variants
Enables variants and opens the Model Variants block parameter dialog
box, which is hidden by default. The Model Variants block parameter
dialog box is the default block parameter dialog box for the Model
Variants block.
Settings
Default: Disabled
Dependencies
This button enables the Model Variants Sections, which include:
Variant choices table, Model parameters for the chosen variant
in table section, parameters to override variants, and a Code
generation section.
The following example shows the Model variants options from the
example model sldemo_mdlref_variants.
2-996
Model, Model Variants
See Also
“Set Up Model Variants”
“Set Up Model Variants”
2-997
Model, Model Variants
Variant choices
Displays a table of Simulink.Variant objects, associated model names,
and conditions, which are Boolean expressions that determine which is
the active variant.
Settings
Default: The table has a row for each variant object in the base
workspace. The Variant choices table includes the name of each
Variant object, its associated Condition, and the corresponding
Model name.
Use the Add a new variant object button to add a new row to the
table. See the description of the Variant object, Condition and
Model name table columns for information about how to set values
for table rows.
Tips
You can use buttons to the left of the Variant choices table to modify
the table.
Function
Add a new variant: Add a new, empty row below
the currently selected row
Delete selected variant: Delete the currently
selected row. (Models and objects are not affected.)
Create/Edit selected variant object: Creates a
Simulink.Variant object in the base workspace and
opens the Simulink.Variant object parameter dialog
in order to specify the variant Condition.
Move variant up: Move the currently selected row
up one slot in the table
Move variant down: Move the currently selected
row up one slot in the table
2-998
Button
Model, Model Variants
Dependency
Enable variants enables this parameter.
Command-Line Information
Parameter: Variants
Type: array
Value: array of variant structures where each element specifies one
variant. The structure fields are:
• variant.Name (string) — The name of the Simulink.Variant object
that represents the variant to which this element applies.
• variant.ModelName (string) — The name of the referenced model
associated with the specified variant object in this Model block.
• variant.ParameterArgumentNames (string) — Read-only string
containing the names of the model arguments for which the Model
block must supply values.
• variant.ParameterArgumentValues (string) — The values to supply
for the model arguments when this variant is the active variant.
• variant.SimulationMode (string) — The execution mode to use
when this variant is the active variant.
-
Possible values are 'Accelerator' | 'Normal' |
'Software-in-the-loop (SIL)' | 'Processor-in-the-loop
(PIL)'
See Also
“Configuring the Model Variants Block”
2-999
Model, Model Variants
Variant object
Display the Simulink.Variant objects in the base workspace or enter a
variant object name in a new row.
Settings
Default: Variant1
To enter a variant object name, double-click a Variant object cell in a
new row and type in the variant object name.
Dependency
Enable variants enables this parameter.
Command-Line Information
Structure field: Represented by the variant.Name field in the
Variants parameter structure
Type: string
Value: name of the Simulink.Variant object that represents the
variant to which this element applies.
Default: ''
See Also
• “About Variant Objects”
• Simulink.Variant
2-1000
Model, Model Variants
Condition
Display the condition for the Simulink.Variant object.
Settings
This read-only field displays the condition for the associated model
variant in the base workspace. Click the Edit selected variant object
button to specify the condition for the selected variant object.
Tips
The variant condition must be a Boolean expression that references at
least one base workspace variable or parameter. For example, FUEL==2
&& EMIS==1. Do not surround the condition with parentheses or single
quotes. The expression can include:
• MATLAB variables defined in the base workspace
• Simulink parameter objects defined in the base workspace
• Scalar variables
• Enumerated values
• Operators ==, !=, &&, ||, ~
• Parentheses for grouping
Note To control variants using meaningful readable names, use a
Simulink.Parameter object of enumerated type to define the variant
condition.
Dependency
Enable variants enables this parameter.
See Also
“Configuring the Model Variants Block”
2-1001
Model, Model Variants
Model name
Display or enter the name of the model associated with the variant
object in the Variant choices table.
Settings
Default: ''
Double-click the table cell to enter a model name. The name must be a
valid MATLAB identifier.
The extension, for example, .SLX, is optional.
Tips
You can type the model name into the table, or you can use the Model
parameters for chosen variant in table controls to find and open
models:
• To navigate to the model that you want to reference for the selected
variant in the table, click the Browse button to the right of the
Model name edit box.
• To confirm that the model you specify is the one you intended, click
the Open Model button to the right of the Model name edit box.
Dependency
Enable variants enables this parameter.
Command-Line Information
Structure field: represented by the variant.ModelName field in the
Variants parameter structure
Type: string
Value: any valid value
Default: name of the referenced model exactly as you typed it, with
any surrounding white space removed. When you set the model
name programmatically or with the GUI, Simulink automatically
sets the values of ModelName and ModelFile based on the value of
ModelNameDialog.
See Also
“Set Up Model Variants”
2-1002
Model, Model Variants
Model name
Display or enter the name of the model associated with the selected
variant object in the Variant choices table.
Settings
Default: ''
Must be a valid MATLAB identifier.
The extension, for example, .SLX, is optional.
Tips
You can type the model name in either the table cell or the Model
name edit box for the selected variant in the table. Use the controls to
find and open models as follows:
• To navigate to the model that you want to reference from this block,
use the Browse button to the right of the Model name parameter.
• To confirm that the model you specify is the one you intended, you
can use the Open Model button to the right of the Model name
parameter.
Dependency
Enable variants enables this parameter.
Command-Line Information
Structure field: represented by the variant.ModelName field in the
Variants parameter structure
Type: string
Value: any valid value
Default: name of the referenced model exactly as you typed it, with
any surrounding white space removed. When you set the model
name programmatically or with the GUI, Simulink automatically
sets the values of ModelName and ModelFile based on the value of
ModelNameDialog.
See Also
“Set Up Model Variants”
2-1003
Model, Model Variants
Model arguments
Display model arguments for the model variant object highlighted in
the Variant choices table.
Declaring a variable to be a model argument allows each instance of the
model to use a different value for that variable.
Settings
Default: ''
This is a read-only parameter that displays model arguments for the
variant object highlighted in the Variant choices table. To create
model arguments, refer to “Using Model Arguments”.
Dependency
Enable variants enables this parameter.
Command-Line Information
Structure field: Represented by the
variant.ParameterArgumentNames field in the Variants parameter
structureOneArgName
Type: string
Value: Enter model arguments as a comma separated list
Default: ''
See Also
• “Using Model Arguments”
• “Set Up Model Variants”
2-1004
Model, Model Variants
Model argument values (for this instance)
Specify values to be passed as model arguments to for the model
variant object highlighted in the Variant choices table, each time
the simulation invokes the model.
Settings
Enter the values in this parameter as a comma-separated list in the
same order as the corresponding argument names appear in the Model
arguments field.
Dependency
Enable variants enables this parameter.
Command-Line Information
Structure field: Represented by the
variant.ParameterArgumentValues field in the Variants
parameter structureOneArgName
Type: string
Value: Any valid value
Default: ''
See Also
• “Using Model Arguments”
• “Set Up Model Variants”
2-1005
Model, Model Variants
Simulation mode
Set the simulation mode for the model variant object highlighted in the
Variant choices table. This setting specifies whether to simulate the
model by generating and executing code or by interpreting the model
in Simulink.
Settings
Default: Accelerator
Accelerator
Creates a MEX-file for the submodel, then executes the submodel
by running the S-function.
Normal
Executes the submodel interpretively, as if the submodel were an
atomic subsystem implemented directly within the parent model.
Software-in-the-loop (SIL)
This option requires Embedded Coder software. Generates
production code using model reference target for the submodel.
This code is compiled for, and executed on, the host platform.
Processor-in-the-loop (PIL)
This option requires Embedded Coder software. Generates
production code using model reference target for the submodel.
This code is compiled for, and executed on, the target platform.
A documented target connectivity API supports exchange of data
between the host and target at each time step during the PIL
simulation.
Dependency
Enable variants enables this parameter.
Command-Line Information
Structure field: Represented by the variant.SimulationMode
field in the Variants parameter structure
Type: string
Value: 'Accelerator' | 'Normal'| 'Software-in-the-loop
(SIL)' | 'Processor-in-the-loop (PIL)'
2-1006
Model, Model Variants
Default: 'Accelerator'
See Also
• “Using Model Arguments”
• “Choosing a Simulation Mode”
• “Numerical Equivalence Testing”
• “Set Up Model Variants”
2-1007
Model, Model Variants
Override variant conditions and use following variant
Specify whether to override the variant conditions and make the
specified Variant parameter the active variant.
Settings
Default: Off
On
Override the variant conditions and set the active variant to the
value of the Variant parameter
Off
Determine the active variant by the value of the variant conditions
Tip
Both this GUI parameter and the Variant GUI parameter (following)
use the same API parameter, OverrideUsingVariant.
Dependencies
Enable variants enables this parameter.
This parameter enables Variant.
Command-Line Information
Parameter: OverrideUsingVariant
Type: string
Value: '' if no overriding variant object is specified, or the name
of the overriding variant object
Default: ''
See Also
“Overriding Variant Conditions”
2-1008
Model, Model Variants
Variant
Specify the variant object name associated with the model to use if you
select Override variant conditions and use the following variant.
Settings
Default: ''
Must be a valid MATLAB identifier.
Tips
• You can use the Variant edit box pulldown list to scroll a list of all
variant objects currently in the base workspace, and their associated
models.
• Both this GUI parameter and the Override variant conditions
and use following variant GUI parameter (above) use the same
API parameter, OverrideUsingVariant.
Dependencies
Enable variants and Override variant conditions and use the
following variant enable this parameter.
Command-Line Information
Parameter: OverrideUsingVariant
Type: string (read-only)
Value: Name of the Simulink.Variant object
See Also
• “Overriding Variant Conditions”
• Simulink.Variant
2-1009
Model, Model Variants
Generate preprocessor conditionals
Control whether generated code contains preprocessor conditionals.
This check box is relevant only to code generation, and has no effect
on the behavior of a model in Simulink. See “Generate Preprocessor
Conditionals for Variant Systems” for more information.
Settings
Default: Disabled
Dependencies
• The check box is available for generating only ERT targets.
• Override variant conditions and use following variant is
cleared ('off')
• Model Configuration Parameters > Optimization > Inline
parameters is selected ('on')
• Model Configuration Parameters > Code Generation >
Interface > Generate preprocessor conditionals is set to Use
local settings.
Command-Line Information
Parameter: GeneratePreprocessorConditionals
Type: string
Value: 'off' | 'on'
Default: 'off'
See Also
“Variant Systems”
Disable variants
Disable model reference variants and hide the Model Variants Section.
The block retains any information you have entered and approved
by clicking Apply or OK. For more information, see “Disabling and
Enabling Model Variants”.
Command-Line Information
Parameter: Variant
Type: string
2-1010
Model, Model Variants
Value: 'off' | 'on'
Default: 'off'
Navigating
a Model
Block
When you double-click a Model block, the block behaves differently
compared to other blocks. This customized behavior depends on the
current status of the Model block:
• Double-clicking the prototype Model block in the Ports & Subsystems
library opens its Block Parameters dialog box for inspection, but does
not allow you to specify parameter values.
• Double-clicking an unresolved Model block opens its Block
Parameters dialog box. You can then resolve the block by specifying
a Model name.
• Double-clicking a resolved Model block opens the model that the
block references. You can also open the model by choosing Open
Model from the Context or Edit menu.
To display the Block Parameters dialog box for a resolved Model block,
choose Model Reference Parameters from the Context or Edit
menu.
Model
Blocks
and Direct
Feedthrough
When a Model block is part of a cycle, and the block is a direct
feedthrough block, an algebraic loop can result. An algebraic loop in
a model is not necessarily an error, but it may not give the expected
results. See:
• “Algebraic Loops” for information about direct feedthrough and
algebraic loops.
• “Highlighting Algebraic Loops Using the Algebraic Loop Diagnostic”
for information about seeing algebraic loops graphically
• “Display Algebraic Loop Information” for information about tracing
algebraic loops in the debugger.
• The “Diagnostics Pane: Solver” pane “Algebraic loop” option for
information about detecting algebraic loops automatically.
2-1011
Model, Model Variants
Direct Model Block Feedthrough Caused by Submodel
Structure
A Model block may be a direct feedthrough block due to the structure of
the referenced model. Where direct feedthrough results from submodel
structure, and causes an unwanted algebraic loop, you can:
• Automatically eliminate the algebraic loop using techniques
described in:
-
“Minimize algebraic loop”
“Minimize algebraic loop occurrences”
“How Simulink Eliminates Artificial Algebraic Loops”
• Manually insert one or more Unit Delay blocks as needed to break
the algebraic loop.
Direct Model Block Feedthrough Caused by Model
Configuration
ERT-based targets provide the option Model Configuration
Parameters > Code Generation > Interface > Single
output/update function. This option controls whether generated code
has separate output and update functions, or a combined output/update
function. See:
• “Embedded Model Functions” for information about separate and
combined output and update functions.
• “Single output/update function” for information about specifying
whether code has separate or combined functions.
When Single output/update function is enabled (the default), a
Model block has a combined output/update function. The function
makes the block a direct feedthrough block for all inports, regardless of
the structure of the referenced model. Where an unwanted algebraic
loop results, you can:
2-1012
Model, Model Variants
• Disable Single output/update function. The code for the Model
block then has separate output and update functions, eliminating the
direct feedthrough and hence the algebraic loop.
• Automatically eliminate the algebraic loop using techniques
described in:
-
“Minimize algebraic loop”
“Minimize algebraic loop occurrences”
“How Simulink Eliminates Artificial Algebraic Loops”
• Manually insert one or more Unit Delay blocks as needed to break
the algebraic loop.
Characteristics Direct Feedthrough
If “Single output/update function”
is enabled (the default), a Model
block is a direct feedthrough block
regardless of the structure of the
referenced model.
If “Single output/update function” is
disabled, a Model block may or may
not be a direct feedthrough block,
depending on the structure of the
referenced model.
See Also
Scalar Expansion
Depends on model referenced by this
block.
Multidimensionalized
Yes
• “Model Reference”
• “Set Up Model Variants”
2-1013
Model Info
Purpose
Display model properties and text in model
Library
Model-Wide Utilities
Description
The Model Info block displays model properties and text about a model
on the mask of the block. Use the Model Info block dialog box to specify
the content and format of the text that the block displays. You can
select model properties to display on the block. In the text displayed on
the block mask, Simulink replaces the property name with the current
value of the property in the model.
Data Type
Support
Not applicable.
2-1014
Model Info
Parameters
and
Dialog
Box
Specify Text and Properties to Display
Use the Enter text and tokens to display on Model Info block edit
box to specify the text and properties to display.
• In the edit box, enter any text you want to display on the block mask.
Edit the default text Model Info.
• To display a model property on the block mask, select a property in
the Model properties list and click the right arrow button.
The block adds a token of the form %<modelpropertyname> to the
edit box. In the text the block mask displays, Simulink will replace
the token with the value of the property.
1 For example, if you select Model Version in the Model
properties list and click the right arrow button, then the token
2-1015
Model Info
%<ModelVersion>
appears in the right edit box.
2 You could add some explanatory text before the model property,
e.g. “Model version is:”.
3 When you click Apply or OK, Simulink displays your new text
and the current value of the model property on the block mask in
the Model Editor like this example:
Model version is:
1.6
See “Version Information Properties” for descriptions of the model
properties.
Caution
Using third-party source control tool keyword expansion within model
properties tokens might corrupt your model files when you submit
them. See “Register Model Files with Source Control Tools”.
If you save your model in SLX format, third-party tools cannot perform
keyword substitution. Any information in the model file from such
third-party tool keyword substitution is cached when you first save
the MDL file as SLX, and is never updated again. The Model Info
block shows stale information from then on, so remove third-party
tool keyword substitution from Model Info blocks to ensure up-to-date
displays.
Configuration Manager Properties
The Configuration manager properties field is enabled only if you
previously specified an external configuration manager for this model
on the MATLAB Preferences dialog box for the model. The field lists
version control information maintained by the external system that you
2-1016
Model Info
can include in the Model Info block. To include an item from the list,
select it and then click the adjacent arrow button.
Note The selected item does not appear in the Model Info block until
you check the model in or out of the repository maintained by the
configuration manager and you have closed and reopened the model.
If you save your model in SLX format, keyword substitution of version
information is not available and you cannot add new configuration
manager properties in the Model Info block. For existing Configuration
manager properties, the block detects the problem, removes stale
version information and instead displays: “Not available in SLX model
file format”.
For a more flexible interface to source control tools, use the Simulink
Project Tool instead of the Model Info block. See “Simulink Projects”.
2-1017
Multiport Switch
Purpose
Choose between multiple block inputs
Library
Signal Routing
Description
Types of Block Inputs
The Multiport Switch block chooses among several inputs. The first
input is the control input, while the others are data inputs. The value of
the control input determines which data input passes to the output port.
Note This block is the same as the Index Vector block. If you set
Number of data ports to 1, you get the Index Vector block.
When you set Data port for default case to Additional data port,
an extra data port with a * label appears below the other data inputs.
For more information, see “How the Block Handles an Out-of-Range
Control Input” on page 2-1020.
Rules That Determine the Block Output
You specify the number of data inputs with Number of data ports.
Data inputs can be scalar or vector.
• If you specify only one data input and that input is a vector, the block
behaves as an index selector, and not as a multiport switch. The
block output is the input vector element whose index matches the
control input.
• If you specify more than one data input, the block behaves as a
multiport switch. The block output is the data input that corresponds
to the value of the control input. If at least one of the data inputs is a
vector, the block output is a vector. In this case, the block expands
any scalar inputs to vectors.
• If the data inputs are scalar, the output is a scalar.
2-1018
Multiport Switch
How the Block Interprets the Control Input
The following table summarizes how the block interprets the control
input and passes data to the output.
Control Truncation
Input
Setting for
Data Port
Order
Integer
value
Not an
integer
value
None
The block
truncates
the value to
an integer
by rounding
to floor.
Block Behavior During Simulation
The specified data
input passes to the
output based on...
And an out-of-range
error occurs when...
Zero-based
contiguous
Zero-based indexing
The control input is
less than 0 or greater
than the number of data
inputs minus one
One-based
contiguous
One-based indexing
The control input is
less than 1 or greater
than the number of data
inputs
Specify
indices
Indices you specify
The control input does
not correspond to any
specified data port
index
Zero-based
contiguous
Zero-based indexing
The truncated control
input is less than 0
or greater than the
number of data inputs
minus one
One-based
contiguous
One-based indexing
The truncated control
input is less than 1
or greater than the
number of data inputs
Specify
indices
Indices you specify
The truncated control
input does not
correspond to any
2-1019
Multiport Switch
Control Truncation
Input
Setting for
Data Port
Order
Block Behavior During Simulation
The specified data
input passes to the
output based on...
And an out-of-range
error occurs when...
specified data port
index
How the Block Handles an Out-of-Range Control Input
For a control input with an integer value, the input is out of range when
the value does not match any data port indices. For a control input that
is not an integer value, the input is out of range when the truncated
value does not match any data port indices. In both cases, the block
behavior depends on your settings for Data port for default case
and Diagnostic for default case.
Behavior for Simulation
The following behavior applies only to simulation for your model.
2-1020
Multiport Switch
Data port for
default case
Diagnostic for default case
None
Warning
Error
Last data
port
Use the last
data port and
do not report
any warning or
error.
Use the last
data port
and report a
warning.
Report an
error and stop
simulation.
Additional
data port
Use the
additional data
port with a
* label and
do not report
any warning or
error.
Use the
additional
data port
with a * label
and report a
warning.
Report an
error and stop
simulation.
Behavior for Code Generation
The following behavior applies to code generation for your model.
2-1021
Multiport Switch
Data port for
default case
Diagnostic for default case
None
Warning
Error
Last data
port
Use the last
data port.
Use the last
data port.
Use the last
data port.
Additional
data port
Use the
additional data
port with a *
label.
Use the
additional data
port with a *
label.
Use the
additional data
port with a *
label.
Guidelines on Setting Parameters for Enumerated Control
Port
When the control port on the Multiport Switch block is of enumerated
type, follow these guidelines:
2-1022
Multiport Switch
Scenario
What to Do
Rationale
The
enumerated
type contains
a value that
represents
invalid,
out-of-range,
or
uninitialized
values.
• Set Data port order
to Specify indices.
This block configuration
handles invalid values
that the enumerated type
explicitly represents.
The
enumerated
type contains
only valid
enumerated
values.
However, a
data input
port can get
invalid values
of enumerated
type.
• Set Data port for
default case to
The
enumerated
type contains
only valid
enumerated
values. Data
input ports
can never get
invalid values
• Set Data port for
default case to Last
data port.
• Set Data port indices
to use this value for
the last data port.
• Set Data port for
default case to Last
data port.
Additional data
port.
This block configuration
handles invalid values
that the enumerated
type does not explicitly
represent.
This block configuration
avoids unnecessary
diagnostic action.
• Set Diagnostic for
default case to None.
2-1023
Multiport Switch
Scenario
What to Do
Rationale
• Set Data port for
default case to
This block configuration
handles enumerated
values that do not have
a data input port, along
with invalid values.
of enumerated
type.
The block does
not have a
data input
port for every
value of the
enumerated
type.
Data Type
Support
Additional data
port.
The control signal can be of any data type that Simulink supports,
including fixed-point and enumerated types. If the control signal is
numeric, it cannot be complex. If the control signal is an enumerated
signal, the block uses the value of the underlying integer to select a
data port. If the underlying integer does not correspond to a data port,
an error occurs.
The data signals can be of any data type that Simulink supports. If any
data signal is of an enumerated type, all others must be of the same
enumerated type.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-1024
Multiport Switch
Parameters
and
Dialog
Box
The Main pane of the Multiport Switch block dialog box appears as
follows:
The Signal Attributes pane of the Multiport Switch block dialog box
appears as follows:
2-1025
Multiport Switch
• “Data port order” on page 2-1028
• “Number of data ports” on page 2-1030
• “Data port indices” on page 2-1031
• “Data port for default case” on page 2-1033
• “Diagnostic for default case” on page 2-1034
2-1026
Multiport Switch
• “Sample time (-1 for inherited)” on page 2-1938
• “Require all data port inputs to have the same data type” on page
2-1036
• “Lock output data type setting against changes by the fixed-point
tools” on page 2-1713
• “Integer rounding mode” on page 2-1714
• “Saturate on integer overflow” on page 2-1716
• “Allow different data input sizes” on page 2-1042
• “Output minimum” on page 2-1043
• “Output maximum” on page 2-1044
• “Output data type” on page 2-1045
• “Mode” on page 2-1047
• “Data type override” on page 2-1892
• “Signedness” on page 2-1050
• “Word length” on page 2-1051
• “Scaling” on page 2-1728
• “Fraction length” on page 2-1053
• “Slope” on page 2-1054
• “Bias” on page 2-1055
2-1027
Multiport Switch
Data port order
Specify the type of ordering for your data input ports.
Settings
Default: One-based contiguous (for Multiport Switch block),
Zero-based contiguous (for Index Vector block)
Zero-based contiguous
Block uses zero-based indexing for ordering contiguous data ports.
One-based contiguous
Block uses one-based indexing for ordering contiguous data ports.
Specify indices
Block uses noncontiguous indexing for ordering data ports.
Tips
• When the control port is of enumerated type, select Specify
indices.
• If you select Zero-based contiguous or One-based contiguous,
verify that the control port is not of enumerated type. This
configuration is deprecated and produces an error. You can run
slupdate on your model to replace each Multiport Switch block of this
configuration with a block that explicitly specifies data port indices.
• Avoid situations where the block contains unused data ports
for simulation or code generation. When the control port is of
fixed-point or built-in data type, verify that all data port indices
are representable with that type. Otherwise, the following block
behavior occurs:
2-1028
If the block has unused data
ports and data port order
is...
You get...
Zero-based contiguous or
One-based contiguous
A warning
Specify indices
An error
Multiport Switch
Dependencies
Selecting Zero-based contiguous or One-based contiguous enables
the Number of data ports parameter.
Selecting Specify indices enables the Data port indices parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1029
Multiport Switch
Number of data ports
Specify the number of data input ports to the block.
Settings
Default: 3 (for Multiport Switch block), 1 (for Index Vector block)
The block icon changes to match the number of data input ports you
specify.
Dependency
Selecting Zero-based contiguous or One-based contiguous for Data
port order enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1030
Multiport Switch
Data port indices
Specify an array of indices for your data ports.
Settings
Default: {1,2,3}
The block icon changes to match the data port indices you specify.
Tips
• To specify an array of indices that correspond to all values of
an enumerated type, enter enumeration('type_name') for this
parameter. Do not include braces.
For example, enumeration('MyColors') is a valid entry.
• To enter specific values of an enumerated type, use the
type_name.enumerated_name format. Do not enter the underlying
integer value.
For example, {MyColors.Red, MyColors.Green, MyColors.Blue}
is a valid entry.
• To indicate that more than one value maps to a data port, use
brackets.
For example, the following entries are both valid:
-
{MyColors.Red, MyColors.Green, [MyColors.Blue,
MyColors.Yellow]}
{[3,5],0,18}
• If the control port is of fixed-point or built-in data type, the values for
Data port indices must be representable with that type. Otherwise,
an error appears at compile time to alert you to unused data ports.
• If the control port is of enumerated data type, the values for Data
port indices must be enumerated values of that type.
• If Data port indices contains values of enumerated type, the control
port must be of that data type.
2-1031
Multiport Switch
Dependency
Selecting Specify indices for Data port order enables this
parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1032
Multiport Switch
Data port for default case
Specify whether to use the last data port for out-of-range inputs, or
to use an additional port.
Settings
Default: Last data port
Last data port
Block uses the last data port for output when the control port
value does not match any data port indices.
Additional data port
Block uses an additional data port for output when the control
port value does not match any data port indices.
Tip
If you set this parameter to Additional data port and Number of
data ports is 3, the number of input ports on the block is 5. The first
input is the control port, the next three inputs are data ports, and the
fifth input is the default port for out-of-range inputs.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1033
Multiport Switch
Diagnostic for default case
Specify the diagnostic action to take when the control port value does
not match any data port indices.
Settings
Default: Error
None
Do not show any warning or error message.
Warning
Show a warning message in the MATLAB Command Window and
continue the simulation.
Error
Show an error message in the Simulation Diagnostics Viewer and
stop the simulation. In this case, the Data port for default case
is used only for code generation and not simulation.
For more information, see “How the Block Handles an
Out-of-Range Control Input” on page 2-1020.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1034
Multiport Switch
Sample time (-1 for inherited)
Enter the discrete interval between sample time hits or specify another
appropriate sample time such as continuous or inherited.
Settings
Default: -1
By default, the block inherits its sample time based upon the context of
the block within the model. To set a different sample time, enter a valid
sample time based upon the table in “Types of Sample Time”.
See also “Specify Sample Time” in the online documentation for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1035
Multiport Switch
Require all data port inputs to have the same data type
Specify allowed data types.
Settings
Default: Off
On
Requires all data port inputs to have the same data type.
Off
Allows data port inputs to have different data types.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1036
Multiport Switch
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
2-1037
Multiport Switch
Integer rounding mode
Specify the rounding mode for fixed-point operations.
Settings
Default: Floor
Ceiling
Rounds both positive and negative numbers toward positive
infinity. Equivalent to the MATLAB ceil function.
Convergent
Rounds number to the nearest representable value. If a tie occurs,
rounds to the nearest even integer. Equivalent to the Fixed-Point
Toolbox convergent function.
Floor
Rounds both positive and negative numbers toward negative
infinity. Equivalent to the MATLAB floor function.
Nearest
Rounds number to the nearest representable value. If a tie occurs,
rounds toward positive infinity. Equivalent to the Fixed-Point
Toolbox nearest function.
Round
Rounds number to the nearest representable value. If a tie occurs,
rounds positive numbers toward positive infinity and rounds
negative numbers toward negative infinity. Equivalent to the
Fixed-Point Toolbox round function.
Simplest
Automatically chooses between round toward floor and round
toward zero to generate rounding code that is as efficient as
possible.
Zero
Rounds number toward zero. Equivalent to the MATLAB fix
function.
2-1038
Multiport Switch
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Rounding” in the Simulink Fixed Point
documentation.
2-1039
Multiport Switch
Saturate on integer overflow
Specify whether overflows saturate.
Settings
Default: Off
On
Overflows saturate to either the minimum or maximum value
that the data type can represent.
For example, an overflow associated with a signed 8-bit integer
can saturate to -128 or 127.
Off
Overflows wrap to the appropriate value that is representable
by the data type.
For example, the number 130 does not fit in a signed 8-bit integer
and wraps to -126.
Tips
• Consider selecting this check box when your model has possible
overflow and you want explicit saturation protection in the generated
code.
• Consider clearing this check box when you want to optimize efficiency
of your generated code.
Clearing this check box also helps you avoid overspecifying how
a block handles out-of-range signals. For more information, see
“Checking for Signal Range Errors”.
• When you select this check box, saturation applies to every internal
operation on the block, not just the output or result.
• In general, the code generation process can detect when overflow
is not possible. In this case, the code generator does not produce
saturation code.
2-1040
Multiport Switch
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1041
Multiport Switch
Allow different data input sizes
Select this check box to allow input signals with different sizes.
Settings
Default: Off
On
Allows input signals with different sizes, and propagate the input
signal size to the output signal.
Off
Requires that input signals be the same size.
Command-Line Information
Parameter: AllowDiffInputSize
Type: string
Value: 'on' | 'off'
Default: 'off'
2-1042
Multiport Switch
Output minimum
Specify the minimum value that the block outputs.
Settings
Default: []
The default value is [] (unspecified).
Simulink uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Tip
This number must be a finite real double scalar value.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1043
Multiport Switch
Output maximum
Specify the maximum value the block outputs.
Settings
Default: []
The default value is [] (unspecified).
Simulink uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Tip
This number must be a finite real double scalar value.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1044
Multiport Switch
Output data type
Specify the output data type.
Settings
Default: Inherit:
Inherit:
Inherit via internal rule
Inherit via internal rule
Simulink chooses a combination of output scaling and data type
that requires the smallest amount of memory consistent with
accommodating the calculated output range and maintaining
the output precision of the block and with the word size of the
targeted hardware implementation specified for the model.
If you set the Device type parameter on the Hardware
Implementation configuration parameters pane to ASIC/FPGA,
Simulink chooses the output data type without regard to
hardware constraints. Otherwise, Simulink chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and you specify ASIC/FPGA
as the targeted hardware type, the output data type is sfix24.
If you select Unspecified (assume 32-bit Generic) for a
generic 32-bit microprocessor as the target hardware, the output
data type is int32. If the word lengths provided by the target
microprocessor cannot accommodate the output range, Simulink
displays an error message in the Simulation Diagnostics Viewer.
Inherit:
Inherit via back propagation
Uses the data type of the driving block.
double
Specifies output data type double.
single
Specifies output data type single.
int8
Specifies output data type int8.
2-1045
Multiport Switch
uint8
Specifies output data type uint8.
int16
Specifies output data type int16.
uint16
Specifies output data type uint16.
int32
Specifies output data type int32.
uint32
Specifies output data type uint32.
fixdt(1,16,0)
Specifies output data type fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Specifies output data type fixed point fixdt(1,16,2^0,0).
<data type expression>
Uses a data type object, for example, Simulink.NumericType.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1046
Multiport Switch
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Specifies inheritance rules for data types. Selecting Inherit
enables a list of possible values:
• Inherit via internal rule (default)
• Inherit via back propagation
Built in
Specifies built-in data types. Selecting Built in enables a list
of possible values:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Specifies fixed-point data types.
Expression
Specifies expressions that evaluate to data types. Selecting
Expression enables you to enter an expression.
Dependency
Clicking the Show data type assistant button enables this parameter.
2-1047
Multiport Switch
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-1048
Multiport Switch
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-1049
Multiport Switch
Signedness
Specify fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specifies the fixed-point data as signed.
Unsigned
Specifies the fixed-point data as unsigned.
Dependency
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type”.
2-1050
Multiport Switch
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Large word sizes represent large values with greater precision than
small word sizes.
Dependency
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type”.
2-1051
Multiport Switch
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1052
Multiport Switch
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependency
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type”.
2-1053
Multiport Switch
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependency
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type”.
2-1054
Multiport Switch
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependency
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type”.
Bus
Support
The Multiport Switch block is a bus-capable block. The data inputs can
be virtual or nonvirtual bus signals subject to the following restrictions:
• All the buses must be equivalent (same hierarchy with identical
names and attributes for all elements).
• All signals in a nonvirtual bus input to a Multiport Switch block must
have the same sample time. This requirement holds even when the
elements of the associated bus object specify inherited sample times.
You can use a Rate Transition block to change the sample time of an
individual signal, or of all signals in a bus. See “About Composite
Signals” and “Bus-Capable Blocks” for more information.
You can use an array of buses as an input signal to a Multiport Switch
block. For details about defining and using an array of buses, see
“Combine Buses into an Array of Buses”. When you use an array of
buses with a Multiport Switch block, set Number of data ports to a
value of 2 or greater.
2-1055
Multiport Switch
Examples
Zero-Based Indexing for Data Ports
The sf_aircontrol model uses a Multiport Switch block in the
Physical Plant subsystem. This block uses zero-based indexing for
contiguous ordering of three data ports.
The indices are visible on the data port labels. You do not have to open
the block dialog box to determine whether the data ports use zero-based
or one-based indexing.
When you set Data port for default case to Last data port, the last
data port includes a * on the label. The comma after the * indicates that
the data port index has a value. This port corresponds to the default
case, which applies when the control input does not match the data
port indices 0, 1, or 2. In this case, the Multiport Switch block outputs
a value of –0.1.
2-1056
Multiport Switch
One-Based Indexing for Data Ports
The sf_semantics_hotel_checkin model uses a Multiport Switch
block. This block uses one-based indexing for contiguous ordering of
three data ports.
If you increase the size of the block icon, the indices are visible on
the data port labels. You do not have to open the block dialog box to
determine whether the data ports use zero-based or one-based indexing.
2-1057
Multiport Switch
Enumerated Names for Data Port Indices
The sldemo_fuelsys model uses a Multiport Switch block in the
fuel_rate_control/fuel_calc/feedforward_fuel_rate subsystem.
This block uses the enumerated type sld_FuelModes to specify three
data port indices: LOW, RICH, and DISABLED.
When you set Data port for default case to Last data port, the last
data port includes a * on the label. The comma and ellipsis after the *
indicate that the data port index has a value. This port corresponds to
the default case, which applies when the control input does not match
the data port indices LOW, RICH, or DISABLED. In this case, the
Multiport Switch block outputs a value of 0.
2-1058
Multiport Switch
Noncontiguous Values for Data Port Indices
The following model uses a Multiport Switch block that specifies
noncontiguous integer values for data ports.
The values of the indices are visible on the data port labels. You do not
have to open the block dialog box to determine which value maps to
each data port.
When you set Data port for default case to Additional data port,
an extra port with a * label appears. This port corresponds to the
default case, which applies when the control input does not match the
data port indices 3, 5, 0, or 18. In this case, the Multiport Switch block
outputs a value of 1.
2-1059
Multiport Switch
Behavior for an Index Vector Block
The following model uses two Index Vector blocks that specify
zero-based and one-based indexing, respectively.
If the value of the control input is not an integer, the block truncates the
value by rounding to floor. For more information, see “How the Block
Interprets the Control Input” on page 2-1019.
Characteristics Bus-capable
2-1060
Yes, with restrictions
Direct Feedthrough
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes
Dimensionalized
Yes
Multiport Switch
See Also
Multidimensionalized
Yes
Zero-Crossing Detection
No
Switch
2-1061
Mux
Purpose
Combine several input signals into vector
Library
Signal Routing
Description
The Mux block combines its inputs into a single vector output. An input
can be a scalar or vector signal. All inputs must be of the same data
type and numeric type. The elements of the vector output signal take
their order from the top to bottom, or left to right, input port signals.
See “How to Rotate a Block” for a description of the port order for
various block orientations. To avoid adding clutter to a model, Simulink
hides the name of a Mux block when you copy it from the Simulink
library to a model. See “Mux Signals” for information about creating
and decomposing vectors.
Note The Mux block allows you to connect signals of differing data and
numeric types and matrix signals to its inputs. In this case, the Mux
block acts like a Bus Creator block and outputs a bus signal rather
than a vector. MathWorks discourages using Mux blocks to create bus
signals, and might not support this practice in future releases. See
“Avoid Mux/Bus Mixtures” for more information.
Use the Number of inputs parameter to specify input signal names
and sizes as well as the number of inputs. You can use one of the
following formats:
2-1062
Mux
Format
Block Behavior
Scalar
Specifies the number of inputs to
the Mux block.
When you use this format, the
block accepts scalar or vector
signals of any size. Simulink
assigns each input the name
signalN, where N is the input
port number.
Vector
The length of the vector specifies
the number of inputs. Each
element specifies the size of the
corresponding input.
A positive value specifies that
the corresponding port can
accept only vectors of that size.
For example, [2 3] specifies
two input ports of sizes 2 and
3, respectively. If an input
signal width does not match the
expected width, an error message
appears. A value of -1 specifies
that the corresponding port can
accept scalars or vectors of any
size.
2-1063
Mux
Format
Block Behavior
Cell array
The length of the cell array
specifies the number of inputs.
The value of each cell specifies the
size of the corresponding input.
A scalar value N specifies a vector
of size N. A value of -1 means
that the corresponding port can
accept scalar or vector signals of
any size.
Signal name list
You can enter a list of signal
names separated by commas.
Simulink assigns each name
to the corresponding port and
signal. For example, if you enter
position,velocity, the Mux
block will have two inputs, named
position and velocity.
MathWorks encourages using Vector Concatenate blocks rather than
Mux blocks to combine vectors. The primary exception is the creation of
a vector of function calls, which requires a Mux block. In future releases,
Mux blocks might have no unique capabilities and might be deprecated.
To create a composite signal, in which the constituent signals retain
their identities and can have different data types, use a Bus Creator
block rather than a Mux block. Although you can use a Mux block to
create a composite signal, MathWorks discourages this practice. See
“Avoid Mux/Bus Mixtures” for more information.
Data Type
Support
The Mux block accepts real or complex signals of any data type that
Simulink supports, including fixed-point and enumerated data types.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-1064
Mux
Parameters
and
Dialog
Box
2-1065
Mux
Number of inputs
Specify number and size of inputs.
Settings
Default: 2
You can enter a comma-separated list of signal names for this
parameter field.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1066
Mux
Display option
Specify the appearance of the block in the model.
Settings
Default: bar
bar
Displays the block in a solid foreground color
none
Mux appears inside the block
signals
Displays signal names next to each port
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1067
Mux
Examples
The sf_car model uses a Mux block to combine two signals for input to
a Scope block:
The sf_aircontrol model uses a Mux block to combine two signals for
input to a Stateflow chart:
The following models also show how to use the Mux block:
2-1068
Mux
• sldemo_auto_climatecontrol
• sldemo_suspn
• sldemo_zeroxing
• penddemo
Characteristics Virtual
Yes
For more information, see “Virtual
Blocks” in the Simulink documentation.
See Also
Demux
2-1069
Outport
Purpose
Create output port for subsystem or external output
Library
Ports & Subsystems, Sinks
Description
Outport blocks are the links from a system to a destination outside
the system.
Simulink software assigns Outport block port numbers according to
these rules:
• It automatically numbers the Outport blocks within a top-level
system or subsystem sequentially, starting with 1.
• If you add an Outport block, it is assigned the next available number.
• If you delete an Outport block, other port numbers are automatically
renumbered to ensure that the Outport blocks are in sequence and
that no numbers are omitted.
Outport Blocks in a Subsystem
Outport blocks in a subsystem represent outputs from the subsystem.
A signal arriving at an Outport block in a subsystem flows out of the
associated output port on that Subsystem block. The Outport block
associated with an output port on a Subsystem block is the block whose
Port number parameter matches the relative position of the output
port on the Subsystem block. For example, the Outport block whose
Port number parameter is 1 sends its signal to the block connected to
the topmost output port on the Subsystem block.
If you renumber the Port number of an Outport block, the block
becomes connected to a different output port, although the block
continues to send the signal to the same block outside the subsystem.
When you create a subsystem by selecting existing blocks, if more than
one Outport block is included in the grouped blocks, Simulink software
automatically renumbers the ports on the blocks.
The Outport block name appears in the Subsystem icon as a port label.
To suppress display of the label, click the Outport block and select
Format > Hide Name.
2-1070
Outport
Outport Blocks in Conditionally Executed Contexts
When an Outport block is in a conditionally executed subsystem or a
Model block, use one of the following approaches:
• Specify an initial output value for the Outport block.
• Use the value inherited from input signal of the Outport block.
Specifying Initial Conditions
To explicitly specify an initial output value:
1 Select Dialog in the Source of initial output value drop-down list.
2 Specify the Initial output parameter.
If you select Dialog, you can also specify what happens to the output
when the subsystem is disabled, using the Output when disabled
drop-down menu. Select either:
• reset – The output value is reset to the Initial output value when
the subsystem is disabled.
• held – The output value remains at its most recent value when the
subsystem is disabled.
Note If you are connecting the output of the conditionally executed
subsystem to a Merge block, set Output when disabled to held to
ensure consistent simulation results.
If you are using simplified initialization mode, you must select held
when connecting a conditionally executed subsystem to a Merge block.
However, you do not need to specify an Initial Condition (IC) for the
Outport block of a conditionally executed subsystem that directly drives
a Merge block. (This rule applies only when Outport and Merge blocks
are in the same model.) For more information, see “Underspecified
initialization detection”.
2-1071
Outport
Inheriting Initial Conditions
The initial output value of the outport block can be inherited from the
following sources:
• Output port of another conditionally executed subsystem
• Merge block (with Initial output specified)
• Function-Call Model Reference block
• Constant block (simplified initialization mode only)
• IC block (simplified initialization mode only)
The procedure you use to inherit the initial conditions of the Outport
block differs depending on whether you are using classic initialization
mode or simplified initialization mode.
To inherit initial conditions in classic initialization mode:
1 Select Dialog in the Source of initial output value drop-down list.
2 Set the Initial output parameter to [] (empty matrix).
3 Click OK.
Note For all other driving blocks, specify an explicit initial output
value.
To inherit initial conditions in simplified initialization mode:
1 Select Input signal in the Source of initial output value
drop-down list.
2 Click OK.
The Initial output and Output when disabled parameters are
disabled, and the values are both inherited from the input signal.
2-1072
Outport
For more information on classic and simplified initialization mode, see
“Underspecified initialization detection”.
Outport Blocks in a Top-Level System
Outport blocks in a top-level system have two uses: to supply external
outputs to the workspace, which you can do by using either the Model
Configuration Parameters dialog box or the sim command, and to
provide a means for analysis functions to obtain output from the system.
• To supply external outputs to the workspace, use the Configuration
Parameters dialog box (see Exporting Output Data to the MATLAB
Workspace) or the sim command (see sim). For example, if a system
has more than one Outport block and the save format is array, the
following command
[t,x,y] = sim(...);
writes y as a matrix, with each column containing data for a different
Outport block. The column order matches the order of the port
numbers for the Outport blocks.
If you specify more than one variable name after the second (state)
argument, data from each Outport block is written to a different
variable. For example, if the system has two Outport blocks, to save
data from Outport block 1 to speed and the data from Outport block
2 to dist, you could specify this command:
[t,x,speed,dist] = sim(...);
• To provide a means for the linmod and trim analysis functions to
obtain output from the system (see “Linearizing Models”)
Connecting Buses to Root Level Outports
A root level Outport of a model can accept a virtual bus only if all
elements of the bus have the same data type. The Outport block
automatically unifies the bus to a vector having the same number of
elements as the bus, and outputs that vector.
2-1073
Outport
If you want a root level Outport of a model to accept a bus signal that
contains mixed types, you must set the Outport block Data type
parameter to use a bus object name for the Bus: <object name> or
<data type expression> option, to define the type of bus that the
Outport produces. If the bus signal is virtual, it will be converted to
nonvirtual, as described in “Automatic Bus Conversion”. See “Bus
Objects” more information.
Data Type
Support
The Outport block accepts real or complex signals of any data type that
Simulink supports. An Outport block can also accept fixed-point and
enumerated data types when the block is not a root-level output port.
The complexity and data type of the block output are the same as those
of its input. The Outport block also accepts a bus object as a data type.
Note If you specify a bus object as the data type for this block,
do not set the minimum and maximum values for bus data on the
block. Simulink ignores these settings. Instead, set the minimum and
maximum values for bus elements of the bus object specified as the data
type. The values should be finite real double scalar.
For information on the Minimum and Maximum properties of a bus
element, see Simulink.BusElement.
For more information, see “Data Types Supported by Simulink”.
The elements of a signal array connected to an Outport block can
be of differing complexity and data types except in the following
circumstance: If the output port is in a conditionally executed
subsystem and the initial output is specified, all elements of an input
array must be of the same complexity and data types.
Typical Simulink data type conversion rules apply to an output port’s
Initial output parameter. If the initial output value is in the range
of the block’s output data type, Simulink software converts the initial
output to the output data type. If the specified initial output is out
2-1074
Outport
of the range of the output data type, Simulink software halts the
simulation and signals an error.
2-1075
Outport
Parameters
and
Dialog
Box
2-1076
The Main pane of the Outport block dialog box appears as follows:
Outport
The Signal Attributes pane of the Outport block dialog box appears
as follows:
2-1077
Outport
2-1078
Outport
• “Package” on page 2-1941
• “Icon display” on page 2-1081
• “Source of initial output value” on page 2-1082
• “Output when disabled” on page 2-1083
• “Initial output” on page 2-1084
• “Minimum” on page 2-1886
• “Maximum” on page 2-1887
• “Data type” on page 2-1086
• “Show data type assistant” on page 2-1665
• “Mode” on page 2-1089
• “Data type override” on page 2-1892
• “Signedness” on page 2-1893
• “Word length” on page 2-1896
• “Scaling” on page 2-1728
• “Fraction length” on page 2-1897
• “Slope” on page 2-1898
• “Bias” on page 2-1898
• “Lock output data type setting against changes by the fixed-point
tools” on page 2-1713
• “Output as nonvirtual bus in parent model” on page 2-1097
• “Port dimensions (-1 for inherited)” on page 2-1099
• “Variable-size signal” on page 2-1100
• “Sample time (-1 for inherited)” on page 2-1938
• “Signal type” on page 2-1103
• “Sampling mode” on page 2-1104
2-1079
Outport
Port number
Specify the port number of the block.
Settings
Default: 1
This parameter controls the order in which the port that corresponds to
the block appears on the parent subsystem or model block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1080
Outport
Icon display
Specify the information to be displayed on the icon of this input port.
Settings
Default: Port number
Signal name
Display the name of the signal connected to this port (or signals if
the input is a bus).
Port number
Display port number of this port.
Port number and signal name
Display both the port number and the names of the signals
connected to this port.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1081
Outport
Source of initial output value
Select the source of the initial output value of the Outport block.
Settings
Default: Dialog
Dialog
The initial output value is specified by the Initial output
parameter on the dialog.
Input signal
The initial output value is inherited from the input signal.
Tips
• If you are using classic initialization mode, you must select Dialog.
Selecting Input signal will cause an error.
• If you are using classic initialization mode and want to inherit the
initial output value, set this parameter to Dialog, and then specify []
(empty matrix) for the Initial output value. For more information,
see Inheriting Initial Conditions on page 1072.
Dependencies
This parameter applies only if the Outport resides in an Enabled
Subsystem.
Selecting Dialog enables the following parameters:
• Output when disabled
• Initial output
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1082
Outport
Output when disabled
Specify what happens to the block output when the subsystem is
disabled.
Settings
Default: held
held
Output is held when the subsystem is disabled.
reset
Output is reset when the subsystem is disabled.
Tips
• If you are connecting the output of a conditionally executed
subsystem to a Merge block, set Output when disabled to held to
ensure consistent simulation results.
• If you are using simplified initialization mode, you must select held
when connecting a conditionally executed subsystem to a Merge
block.
Dependencies
• Selecting Dialog in Source of initial output value enables this
parameter.
• This parameter applies only if the Outport resides in an Enabled
Subsystem.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1083
Outport
Initial output
For conditionally executed subsystems, specify the block output before
the subsystem executes and while it is disabled.
Settings
Default: [ ]
Simulink software does not allow the initial output of this block to be
inf or NaN.
Tips
• If you are using classic initialization mode, specify [] (empty matrix)
to inherit the initial output value from the input signal. For more
information, see Inheriting Initial Conditions on page 1072.
• You can also specify [] if you are using classic initialization
mode, and your model does not depend on the initial output of the
conditionally executed subsystem.
• If you are using simplified initialization mode, you cannot specify
[], you must specify an explicit value. If you do not want to specify
an initial output value for this block, set Source of initial output
value to Input signal.
• For information about specifying an initial condition structure, see
“Specify Initial Conditions for Bus Signals”
Dependencies
• Selecting Dialog in Source of initial output value enables this
parameter.
• This parameter applies only if the Outport resides in an Enabled
Subsystem.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1084
Outport
Minimum
Specify the minimum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the minimum value for bus data on the block. Simulink ignores
this setting. Instead, set the minimum values for bus elements of the
bus object specified as the data type. For information on the Minimum
property of a bus element, see Simulink.BusElement.
Simulink software uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1085
Outport
Maximum
Specify the maximum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the maximum value for bus data on the block. Simulink ignores this
setting. Instead, set the maximum values for bus elements of the bus
object specified as the data type. For information on the Maximum
property of a bus element, see Simulink.BusElement.
Simulink software uses this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Data type
Specify the output data type of the external input.
Settings
Default: Inherit:
Inherit:
auto
auto
A rule that inherits a data type
double
Data type is double.
single
Data type is single.
2-1086
Outport
int8
Data type is int8.
uint8
Data type is uint8.
int16
Data type is int16.
uint16
Data type is uint16.
int32
Data type is int32.
uint32
Data type is uint32.
boolean
Data type is boolean.
fixdt(1,16,0)
Data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Data type is fixed point fixdt(1,16,2^0,0).
Enum:
<class name>
Data type is enumerated, for example, Enum:
Bus:
BasicColors.
<object name>
Data type is a bus object.
<data type expression>
The name of a data type object, for example
Simulink.NumericType
Do not specify a bus object as the expression.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1087
Outport
Show data type assistant
Display the Data Type Assistant.
Settings
The Data Type Assistant helps you set the Output data type
parameter.
For more information, see “Specify Block Output Data Types”.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1088
Outport
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rule for data types. Selecting Inherit enables a
second menu/text box to the right.
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
• boolean
Fixed point
Fixed-point data types.
Enumerated
Enumerated data types. Selecting Enumerated enables a second
menu/text box to the right, where you can enter the class name.
Bus
Bus object. Selecting Bus enables a Bus object parameter to the
right, where you enter the name of a bus object that you want to
use to define the structure of the bus. If you need to create or
2-1089
Outport
change a bus object, click Edit to the right of the Bus object
field to open the Simulink Bus Editor. For details about the Bus
Editor, see “Manage Bus Objects with the Bus Editor”.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
Do not specify a bus object as the expression.
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-1090
Outport
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-1091
Outport
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1092
Outport
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1093
Outport
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1094
Outport
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1095
Outport
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1096
Outport
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
Output as nonvirtual bus in parent model
Select this parameter if you want the bus emerging in the parent model
to be nonvirtual. The bus that is input to the port can be virtual or
nonvirtual, regardless of the setting of Output as nonvirtual bus
in parent model.
Settings
Default: Off
On
Select this parameter if you want the bus emerging in the parent
model to be nonvirtual.
Off
Clear this parameter if you want the bus emerging in the parent
model to be virtual.
2-1097
Outport
Tips
All signals in a nonvirtual bus must have the same sample time, even
if the elements of the associated bus object specify inherited sample
times. Any bus operation that would result in a nonvirtual bus that
violates this requirement generates an error. Therefore, if you select
this option all signals in the bus must have the same sample time.
You can use a Rate Transition block to change the sample time of an
individual signal, or of all signals in a bus, to allow the signal or bus to
be included in a nonvirtual bus.
Dependency
via bus object enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1098
Outport
Port dimensions (-1 for inherited)
Specify the dimensions that a signal must have in order to be connected
to this Outport block.
Settings
Default: -1
Valid values are:
-1
A signal of any dimensions can be connected to this
port.
N
The signal connected to this port must be a vector
of size N.
[R C]
The signal connected to this port must be a matrix
having R rows and C columns.
Dependency
Clearing via bus object enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1099
Outport
Variable-size signal
Specify the type of signals allowed out of this port.
Settings
Default: Inherit
Inherit
Allow variable-size and fixed-size signals.
No
Do not allow variable-size signals.
Yes
Allow only variable-size signals.
Dependencies
When the signal at this port is a variable-size signal, the Port
dimensions parameter specifies the maximum dimensions of the
signal.
Command-Line Information
Parameter: VarSizeSig
Type: string
Value: 'Inherit’| 'No' | 'Yes'
Default: 'Inherit'
2-1100
Outport
Sample time (-1 for inherited)
Enter the discrete interval between sample time hits or specify another
appropriate sample time such as continuous or inherited.
Settings
Default: -1
By default, the block inherits its sample time based upon the context of
the block within the model. To set a different sample time, enter a valid
sample time based upon the table in “Types of Sample Time”.
See also “Specify Sample Time” in the online documentation for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1101
Outport
2-1102
Outport
Signal type
Specify the numeric type of the signal output by this block.
Settings
Default: auto
auto
Output the numeric type of the signal that is connected to its
input.
real
Output a real-valued signal. The signal connected to this block
must be real. If it is not, Simulink software displays an error if
you try to update the diagram or simulate the model that contains
this block.
complex
Output a complex signal. The signal connected to this block must
be complex. If it is not, Simulink software displays an error if you
try to update the diagram or simulate the model that contains
this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1103
Outport
Sampling mode
Specify the sampling mode (Sample based or Frame based) that the
input signal must match.
Settings
Default: auto
auto
Accept any sampling mode.
Sample based
The output signal is sample-based.
Frame based
The output signal is frame-based.
Dependency
Frame-based processing requires a DSP System Toolbox license.
For more information, see “Sample- and Frame-Based Concepts” in the
DSP System Toolbox documentation.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1104
Outport
Characteristics Sample Time
Inherited from the driving block
Dimensionalized
Yes
Multidimensionalized
Yes
Virtual
Yes, when the block resides in a
subsystem block and not at the root
level of a model
For more information, see
“Virtual Blocks” in the Simulink
documentation.
Zero-Crossing Detection
See Also
No
Inport
2-1105
Permute Dimensions
Purpose
Rearrange dimensions of multidimensional array dimensions
Library
Math Operations
Description
The block reorders the elements of the input signal so that they are in
the order you specify in the Order parameter.
Data Type
Support
This block accepts signals of any data type that Simulink supports,
including fixed-point and enumerated data types. Output must be the
same data type as the input.
You can use an array of buses as an input signal to a Permute
Dimensions block. For details about defining and using an array of
buses, see “Combine Buses into an Array of Buses”.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-1106
Permute Dimensions
Parameters
and
Dialog
Box
Order
Specify the permutation order to apply to the dimensions of the
input signal. This parameter is a vector of elements, where the
number of elements in the vector is the number of dimensions
of the input signal.
Characteristics Direct Feedthrough
Yes
Sample Time
Inherited from driving block
Scalar Expansion
No
2-1107
Permute Dimensions
See Also
2-1108
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Math Function (transpose), permute (in the MATLAB reference
documentation)
PID Controller
Purpose
Simulate continuous- or discrete-time PID controllers
Library
Continuous, Discrete
Description
Implement a continuous- or discrete-time controller (PID, PI, PD,
P, or I) in your Simulink model. PID controller gains are tunable
either manually or automatically. Automatic tuning requires Simulink
Control Design™ software (PID Tuner or SISO Design Tool).
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. A first-order pole filters the derivative action.
Configurable options in the PID Controller block include:
• Controller type (PID, PI, PD, P, or I)
• Controller form (Parallel or Ideal)
• Time domain (continuous or discrete)
• Initial conditions and reset trigger
• Output saturation limits and built-in anti-windup mechanism
• Signal tracking for bumpless control transfer and multiloop control
In one common implementation, the PID Controller block operates in
the feedforward path of the feedback loop:
2-1109
PID Controller
The input of the block is typically an error signal, which is the difference
between a reference signal and the system output. For a two-input
block that permits setpoint weighting, see the PID Controller (2 DOF)
block reference page.
You can generate code to implement your controller using any Simulink
data type, including fixed-point data types. (Code generation requires
Simulink Coder software; fixed-point implementation requires the
Fixed-Point Toolbox product.)
For examples illustrating some applications of the PID Controller block,
see the following Simulink examples:
• Anti-Windup Control Using a PID Controller
• Bumpless Control Transfer Between Manual and PID Control
Data Type
Support
The PID Controller block accepts real signals of any numeric data type
that Simulink software supports, including fixed-point data types. See
“Data Types Supported by Simulink” in the Simulink documentation
for more information.
Parameters
The following table summarizes the PID Controller block parameters,
accessible on the block parameter dialog box.
Task
Parameters
Choose controller form and type.
• Controller Form in Main tab
• Controller
Choose discrete or continuous time.
• Time-domain
• Sample time
Choose an integration method (discrete
time).
2-1110
• Integrator method
• Filter method
PID Controller
Task
Parameters
Set and tune controller gains.
• Proportional (P) in Main tab
• Integral (I) in Main tab
• Derivative (D) in Main tab
• Filter coefficient (N) in Main tab
Set integrator and filter initial conditions.
• Initial conditions Source in Main tab
• Integrator Initial condition in Main
tab
• Filter Initial condition in Main tab
• External reset in Main tab
• Ignore reset when linearizing in Main
tab
Limit block output.
• Limit output in PID Advanced tab
• Lower saturation limit in PID
Advanced tab
• Upper saturation limit in PID
Advanced tab
• Ignore saturation when linearizing
in PID Advanced tab
Configure anti-windup mechanism (when
you limit block output).
• Anti-windup method in PID Advanced
tab
• Back-calculation gain (Kb) in PID
Advanced tab
Enable signal tracking.
• Enable tracking mode in PID
Advanced tab
• Tracking gain (Kt) in PID Advanced
tab
2-1111
PID Controller
Task
Parameters
Configure data types.
• Parameter data type in Data Type
Attributes tab
• Product output data type in Data
Type Attributes tab
• Summation output data type in Data
Type Attributes tab
• Accumulator data type in Data Type
Attributes tab
• Integrator output data type in Data
Type Attributes tab
• Filter output data type in Data Type
Attributes tab
• Saturation output data type in Data
Type Attributes tab
• Lock output data type setting against
changes by the fixed-point tools in
Data Type Attributes tab
• Saturate on integer overflow in Data
Type Attributes tab
• Integer rounding mode in Data Type
Attributes tab
Configure block for code generation.
• State name in State Attributes tab
• State name must resolve to Simulink
signal object in State Attributes tab
• Code generation storage class in
State Attributes tab
• Code generation storage type
qualifier in State Attributes tab
2-1112
PID Controller
Controller form
Select the controller form.
Settings
Parallel (Default)
Selects a controller form in which the output is the sum of
the proportional, integral, and derivative actions, weighted
according to the independent gain parameters P, I, and D. The
filter coefficient N sets the location of the pole in the derivative
filter. For a continuous-time parallel PID controller, the transfer
function is:
⎡
⎛1⎞
⎛ Ns ⎞ ⎤
C par ( s ) = ⎢ P + I ⎜ ⎟ + D ⎜
⎟⎥
⎝s⎠
⎝ s + N ⎠⎦
⎣
For a discrete-time parallel PID controller, the transfer function
takes the form:
N
⎡
⎤
C par ( z) = P + Ia( z) + D ⎢
⎣ 1 + Nb( z) ⎥⎦
where the Integrator method determines a(z) and the Filter
method determines b(z) (for sampling time Ts):
2-1113
PID Controller
Forward
Euler
method
a( z)
(determined
by Integrator
method)
b( z)
(determined
by Filter
method)
Backward
Euler
method
Trapezoidal
method
Ts
z −1
Ts z
z −1
Ts z + 1
2 z −1
Ts
z −1
Ts z
z −1
Ts z + 1
2 z −1
The controller transfer function for the current settings is
displayed in the block dialog box.
2-1114
PID Controller
Parallel PID Controller
Ideal
Selects a controller form in which the proportional gain P acts on
the sum of all actions. The transfer functions are the same as
for the parallel form, except that P multiplies all terms. For a
continuous-time ideal PID controller, the transfer function is:
⎡
⎛1⎞
⎛ Ns ⎞ ⎤
Cid ( s ) = P ⎢1 + I ⎜ ⎟ + D ⎜
⎟⎥
⎝s⎠
⎝ s + N ⎠⎦
⎣
For a discrete-time ideal PID controller the transfer function is:
N
⎤
⎡
Cid ( z) = P ⎢1 + Ia( z) + D
⎥⎦
1
+
Nb
(
z
)
⎣
2-1115
PID Controller
where the Integrator method determines a(z) and the Filter
method determines b(z) as described previously for the parallel
controller form.
Ideal PID Controller
2-1116
PID Controller
Controller
Specify the controller type.
Settings
PID (Default)
Implements a controller with proportional, integral, and
derivative action.
PI
Implements a controller with proportional and integral action.
PD
Implements a controller with proportional and derivative action.
P
Implements a controller with proportional action.
I
Implements a controller with integral action.
The controller transfer function for the current settings is displayed in
the block dialog box.
2-1117
PID Controller
Time-domain
Select continuous or discrete time domain. The appearance of the block
changes to reflect your selection.
Settings
Continuous-time (Default)
Selects the continuous-time representation.
Discrete-time
Selects the discrete-time representation. Selecting Discrete-time
also allows you to specify the:
• Sample time, which is the discrete interval between samples.
• Discrete integration methods for the integrator and the
derivative filter using the Integrator method and Filter
method menus.
2-1118
PID Controller
Integrator method
(Available only when you set Time-domain to Discrete-time.)
Specify the method used to compute the integrator output. For
more information about discrete-time integration methods, see the
Discrete-Time Integrator block reference page.
Settings
Forward Euler (Default)
Selects the Forward Rectangular (left-hand) approximation.
• This method is best for small sampling times, where the
Nyquist limit is large compared to the bandwidth of the
controller. For larger sampling times, the Forward Euler
method can result in instability, even when discretizing a
system that is stable in continuous time.
Backward Euler
Selects the Backward Rectangular (right-hand) approximation.
• If you are generating code using Simulink Coder software
or the Fixed-Point Toolbox product and you activate the
Back-calculation Anti-windup method, this integration
method can cause algebraic loops in your controller. Algebraic
loops can lead to slower performance of generated code. For
more information about algebraic loops in Simulink models, see
“Algebraic Loops” in the Simulink documentation.
• An advantage of the Backward Euler method is that
discretizing a stable continuous-time system using this method
always yields a stable discrete-time result.
Trapezoidal
Selects the Bilinear approximation.
• If you are generating code using Simulink Coder software
or the Fixed-Point Toolbox product and you activate the
Back-calculation Anti-windup method, this integration
method can cause algebraic loops in your controller. Algebraic
loops can lead to slower performance of generated code. For
2-1119
PID Controller
more information about algebraic loops in Simulink models, see
“Algebraic Loops” in the Simulink documentation.
• An advantage of the Trapezoidal method is that discretizing
a stable continuous-time system using this method always
yields a stable discrete-time result. Of all available integration
methods, the Trapezoidal method yields the closest match
between frequency-domain properties of the discretized system
and the corresponding continuous-time system.
2-1120
PID Controller
Filter method
(Available only when you set Time-domain to Discrete-time.)
Specify the method used to compute the derivative filter output. For
more information about discrete-time integration methods, see the
Discrete-Time Integrator block reference page.
Settings
Forward Euler (Default)
Selects the Forward Rectangular (left-hand) approximation.
• This method is best for small sampling times, where the
Nyquist limit is large compared to the bandwidth of the
controller. For larger sampling times, the Forward Euler
method can result in instability, even when discretizing a
system that is stable in continuous time.
Backward Euler
Selects the Backward Rectangular (right-hand) approximation.
• If you are generating code using Simulink Coder software or
the Fixed-Point Toolbox product, this filter method can cause
algebraic loops in your controller. Algebraic loops can lead to
slower performance of generated code. For more information
about algebraic loops in Simulink models, see “Algebraic Loops”
in the Simulink documentation.
• An advantage of the Backward Euler method is that
discretizing a stable continuous-time system using this method
always yields a stable discrete-time result. Any filter parameter
value N > 0 yields a stable result with this method.
Trapezoidal
Selects the Bilinear approximation.
• If you are generating code using Simulink Coder software or
the Fixed-Point Toolbox product, this filter method can cause
algebraic loops in your controller. Algebraic loops can lead to
slower performance of generated code. For more information
about algebraic loops in Simulink models, see “Algebraic Loops”
in the Simulink documentation.
2-1121
PID Controller
• An advantage of the Trapezoidal method is that discretizing a
stable continuous-time system using this method always yields
a stable discrete-time result. Any filter parameter value N > 0
yields a stable result with this method. Of all available filter
methods, the Trapezoidal method yields the closest match
between frequency-domain properties of the discretized system
and the corresponding continuous-time system.
2-1122
PID Controller
Sample time (-1 for inherited)
(Available only when you set Time-domain to Discrete-time.) Specify
the discrete interval between samples.
Settings
Default: 1
By default, the block uses a discrete sample time of 1. To specify a
different sample time, enter another discrete value, such as 0.1.
If you specify a value of -1, the PID Controller block inherits the sample
time from the upstream block. Do not enter a value of 0; to implement a
continuous-time controller, select the Time-domain Continuous-time.
See “Specify Sample Time” in the online documentation for more
information.
2-1123
PID Controller
Proportional (P)
(Available for PID, PD, PI, and P controllers.) Specify the proportional
gain P.
Default: 1
Enter a finite, real gain value into the Proportional (P) field. Use
either scalar or vector gain values. For a Parallel PID Controller
form, the proportional action is independent of the integral and
derivative actions. For an Ideal PID Controller form, the
proportional action acts on the integral and derivative actions. See
“Controller form” on page 2-1113 for more information about the role of
P in the controller transfer function.
When you have Simulink Control Design software installed, you can
automatically tune the controller gains using the PID Tuner or the
SISO Design Tool. See “Choosing a Compensator Design Approach”.
2-1124
PID Controller
Integral (I)
(Available for PID, PI, and I controllers.) Specify the integral gain I.
Default: 1
Enter a finite, real gain value into the Integral (I) field. Use either
scalar or vector gain values.
When you have Simulink Control Design software installed, you can
automatically tune the controller gains using the PID Tuner or the
SISO Design Tool. See “Choosing a Compensator Design Approach”.
2-1125
PID Controller
Derivative (D)
(Available for PID and PD controllers.) Specify the derivative gain D.
Default: 0
Enter a finite, real gain value into the Derivative (D) field. Use either
scalar or vector gain values.
When you have Simulink Control Design software installed, you can
automatically tune the controller gains using the PID Tuner or the
SISO Design Tool. See “Choosing a Compensator Design Approach”.
2-1126
PID Controller
Filter coefficient (N)
(Available for PID and PD controllers.) Specify the filter coefficient N,
which determines the pole location of the filter in the derivative action:
The filter pole falls at s = -N in the Continuous-time Time-domain.
For Discrete-time, the location of the pole depends on which Filter
method you select (for sampling time Ts):
• Forward Euler:
z pole = 1 − NTs
• Backward Euler:
z pole =
1
1 + NTs
• Trapezoidal:
z pole =
1 − NTs / 2
1 + NTs / 2
Default: 100.
2-1127
PID Controller
Enter a finite, real gain value into the Filter Coefficient (N) field.
Use either scalar or vector gain values. Note that the PID controller
block does not support N = inf (ideal unfiltered derivative).
When you have Simulink Control Design software installed, you can
automatically tune the controller gains using the PID Tuner or the
SISO Design Tool. See “Choosing a Compensator Design Approach”.
Automatic tuning requires N > 0.
2-1128
PID Controller
Initial conditions Source
(Only available for controllers with integral or derivative action.) Select
the source of the integrator and filter initial conditions. Simulink uses
initial conditions to initialize the integrator and filter output at the
start of a simulation or at a specified trigger event (See “External reset”
on page 2-1132). The integrator and filter initial conditions in turn
determine the initial block output.
Settings
internal (Default)
Specifies the integrator and filter initial conditions explicitly
using the Integrator Initial condition and Filter Initial
condition parameters.
external
Specifies the integrator and filter initial conditions externally.
An additional input port appears under the block input for each
initial condition: I0 for the integrator and D0 for the filter:
2-1129
PID Controller
Integrator Initial condition
(Available only when Initial conditions Source is internal and the
controller includes integral action.) Specify the integrator initial value.
Simulink uses the initial condition to initialize the integrator output at
the start of a simulation or at a specified trigger event (see “External
reset” on page 2-1132). The integrator initial condition, together with
the filter initial condition, determines the initial output of the PID
controller block.
Default: 0
Simulink does not permit the integrator initial condition to be inf or
NaN.
2-1130
PID Controller
Filter Initial condition
(Available only when Initial conditions Source is internal and the
controller includes integral action.) Specify the filter initial value.
Simulink uses the initial condition to initialize the filter output at
the start of a simulation or at a specified trigger event (see “External
reset” on page 2-1132). The filter initial condition, together with the
integrator initial condition, determines the initial output of the PID
controller block.
Default: 0
Simulink does not permit the filter initial condition to be inf or NaN.
2-1131
PID Controller
External reset
Select the trigger event that resets the integrator and filter outputs to
the initial conditions you specify in the Integrator Initial condition
and Filter Initial condition fields. Selecting any option other than
none enables a reset input on the block for the external reset signal, as
shown:
Or, if the Initial conditions Source is External,
Settings
none (Default)
Does not reset the integrator and filter outputs to initial
conditions.
rising
Resets the outputs when the reset signal has a rising edge.
falling
Resets the outputs when the reset signal has a falling edge.
either
Resets the outputs when the reset signal either rises or falls.
2-1132
PID Controller
level
Resets and holds the outputs to the initial conditions while the
reset signal is nonzero.
Note To be compliant with the Motor Industry Software Reliability
Association (MISRA) software standard, your model must use Boolean
signals to drive the external reset ports of the PID controller block.
2-1133
PID Controller
Ignore reset when linearizing
Force Simulink linearization commands to ignore any reset mechanism
that you have chosen with the External reset menu. Ignoring reset
states allows you to linearize a model around an operating point even if
that operating point causes the PID Controller block to reset.
Settings
Off (Default)
Simulink linearization commands do not ignore states
corresponding to the reset mechanism.
On
Simulink linearization commands ignore states corresponding
to the reset mechanism.
2-1134
PID Controller
Enable zero-crossing detection
Enable zero-crossing detection in continuous-time models upon reset
and upon entering or leaving a saturation state.
Zero-crossing detection can accurately locate signal discontinuities
without resorting to excessively small time steps that can lead to lengthy
simulation times. If you select Limit output or activate an External
reset in your PID Controller block, activating zero-crossing detection
can reduce computation time in your simulation. For more information,
see “Zero-Crossing Detection” in the Simulink documentation.
Settings
On (Default)
Uses zero-crossing detection at any of the following events: reset;
entering or leaving an upper saturation state; and entering or
leaving a lower saturation state.
Off
Does not use zero-crossing detection.
Enabling zero-crossing detection for the PID Controller block also
enables zero-crossing detection for all under-mask blocks that include
the zero-crossing detection feature.
2-1135
PID Controller
Limit output
Limit the block output to values you specify as the Lower saturation
limit and Upper saturation limit parameters.
Activating this option limits the block output internally to the block,
obviating the need for a separate Saturation block after the controller in
your Simulink model. It also allows you to activate the block’s built-in
anti-windup mechanism (see “Anti-windup method” on page 2-1139).
Settings
Off (Default)
Does not limit the block output, which equals the weighted sum of
the proportional, integral, and derivative actions.
On
Limits the block output to the Lower saturation limit or the
Upper saturation limit whenever the weighted sum exceeds
those limits. Allows you to select an Anti-windup method.
2-1136
PID Controller
Lower saturation limit
(Available only when you select the Limit output check box.) Specify
the lower limit for the block output. The block output is held at
the Lower saturation limit whenever the weighted sum of the
proportional, integral, and derivative actions goes below that value.
Default: -inf
2-1137
PID Controller
Upper saturation limit
(Available only when you select the Limit output check box.) Specify
the upper limit for the block output. The block output is held at
the Upper saturation limit whenever the weighted sum of the
proportional, integral, and derivative actions exceeds that value.
Default: inf
2-1138
PID Controller
Anti-windup method
(Available only when you select the Limit output option and the
controller includes integral action.) Select an anti-windup mechanism
to discharge the integrator when the block is saturated, which occurs
when the sum of the block components exceeds the output limits.
When you select the Limit output check box and the weighted sum of
the controller components exceeds the specified output limits, the block
output holds at the specified limit. However, the integrator output
can continue to grow (integrator wind-up), increasing the difference
between the block output and the sum of the block components. Without
a mechanism to prevent integrator wind-up, two results are possible:
• If the sign of the input signal never changes, the integrator continues
to integrate until it overflows. The overflow value is the maximum or
minimum value for the data type of the integrator output.
• If the sign of the input signal changes once the weighted sum has
grown beyond the output limits, it can take a long time to discharge
the integrator and return the weighted sum within the block
saturation limit.
In both cases, controller performance can suffer. To combat the effects
of wind-up without an anti-windup mechanism, it may be necessary
to detune the controller (for example, by reducing the controller
gains), resulting in a sluggish controller. Activating an anti-windup
mechanism can improve controller performance.
Settings
none (Default)
Does not use an anti-windup mechanism. This setting may cause
the block’s internal signals to be unbounded even if the output
appears to be bounded by the saturation limits. This can result in
slow recovery from saturation or unexpected overflows.
back-calculation
Discharges the integrator when the block output saturates using
the integral-gain feedback loop:
2-1139
PID Controller
You can also specify a value for the Back-calculation
coefficient (Kb).
clamping
Stops integration when the sum of the block components exceeds
the output limits and the integrator output and block input have
the same sign. Resumes integration when the sum of the block
components exceeds the output limits and the integrator output
and block input have opposite sign. The integrator portion of the
block is:
The clamping circuit implements the logic necessary to determine
whether integration continues.
2-1140
PID Controller
Back-calculation gain (Kb)
(Available only when the back-calculation Anti-windup method is
active.) Specify the gain coefficient of the anti-windup feedback loop.
The back-calculation anti-windup method discharges the integrator
on block saturation using a feedback loop having gain coefficient Kb.
Default: 1
2-1141
PID Controller
Ignore saturation when linearizing
Force Simulink linearization commands ignore PID Controller block
output limits. Ignoring output limits allows you to linearize a model
around an operating point even if that operating point causes the PID
Controller block to exceed the output limits.
Settings
On (Default)
Simulink linearization commands ignore states corresponding
to saturation.
Off
Simulink linearization commands do not ignore states
corresponding to saturation.
2-1142
PID Controller
Enable tracking mode
(Available for any controller with integral action.) Activate signal
tracking, which lets the output of the PID Controller block follow a
tracking signal. Provide the tracking signal to the block at the TR port,
which becomes active when you select Enable tracking mode.
When signal tracking is active, the difference between the tracked
signal and the block output is fed back to the integrator input with a
gain Kt. The structure is illustrated for a PI controller:
2-1143
PID Controller
You can also specify the Tracking coefficient (Kt).
2-1144
PID Controller
Bumpless control transfer
Use signal tracking, for example, to achieve bumpless control transfer
in systems that switch between two controllers. You can make one
controller track the output of the other controller by connecting the TR
port to the signal you want to track. For example:
In this example, the outputs Out1 and Out2 can drive a controlled
system (not shown) through a switch that transfers control between
the “Active controller” block and the PID Controller block. The signal
tracking feature of the PID Controller block provides smooth operation
upon transfer of control from one controller to another, ensuring that
the two controllers have the same output at the time of transfer.
Multiloop control
Use signal tracking to prevent block wind-up in multiloop control
approaches, as this example illustrates:
2-1145
PID Controller
The inner-loop subsystem contains the following blocks:
In this example, the inner loop has an effective gain of 1 when it does
not saturate. Without signal tracking, the inner loop winds up in
saturation. Signal tracking ensures that the PID Controller output does
not exceed the saturated output of the inner loop.
Settings
Off (Default)
Disables signal tracking and removes TR block input.
On
Enables signal tracking and activates TR input.
2-1146
PID Controller
Tracking gain (Kt)
(Available only when you select Enable tracking mode.) Specify Kt,
which is the gain of the signal tracking feedback loop.
Default: 1
2-1147
PID Controller
Parameter data type
Select the data type of the gain parameters P, I, D, N, Kb, and Kt.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Inherit via back propagation
Use data type of the driving block.
Inherit:
Same as input
Use data type of input signal.
double
single
int8
2-1148
PID Controller
uint8
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1149
PID Controller
Product output data type
Select the product output data type of the gain parameters P, I, D,
N, Kb, and Kt .
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Inherit via back propagation
Use data type of the driving block.
Inherit:
Same as input
Use data type of input signal.
double
single
int8
2-1150
PID Controller
uint8
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1151
PID Controller
Summation output data type
Select the summation output data type of the sums Sum, Sum D, Sum
I1 , SumI2 ,and SumI3, which are sums computed internally within the
block. To see where Simulink computes each of these sums , right-click
the PID Controller block in your model and select Look Under Mask:
• Sum is the weighted sum of the proportional, derivative, and integral
signals.
• SumD is the sum in the derivative filter feedback loop.
• SumI1 is the sum of the block input signal (weighted by the integral
gain I) and SumI2. SumI1 is computed only when Limit output
and Anti-windup method back-calculation are active.
• SumI2 is the difference between the weighted sum Sum and the
limited block output. SumI2 is computed only when Limit output
and Anti-windup method back-calculation are active.
• SumI3 is the difference between the block output and the signal at
the block’s tracking input. SumI3 is computed only when you select
the Enable tracking mode box.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
2-1152
PID Controller
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Same as first input
Use data type of first input signal.
double
single
int8
uint8
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
2-1153
PID Controller
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1154
PID Controller
Accumulator data type
Specify the accumulator data type.
Settings
Default: Inherit:
Inherit:
Inherit via internal rule
Inherit via internal rule
Use internal rule to determine accumulator data type.
Inherit:
Same as first input
Use data type of first input signal.
double
Accumulator data type is double.
single
Accumulator data type is single.
int8
Accumulator data type is int8.
uint8
Accumulator data type is uint8.
int16
Accumulator data type is int16.
uint16
Accumulator data type is uint16.
int32
Accumulator data type is int32.
uint32
Accumulator data type is uint32.
fixdt(1,16,0)
Accumulator data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Accumulator data type is fixed point fixdt(1,16,2^0,0).
2-1155
PID Controller
<data type expression>
The name of a data type object, for example
Simulink.NumericType
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specify Data Types Using Data Type
Assistant”.
2-1156
PID Controller
Integrator output data type
Select the data type of the integrator output.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Same as input
Use data type of input signal.
double
single
int8
uint8
2-1157
PID Controller
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1158
PID Controller
Filter output data type
Select the data type of the filter output.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Same as input
Use data type of input signal.
double
single
int8
uint8
2-1159
PID Controller
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1160
PID Controller
Saturation output data type
Select the saturation output data type.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Same as input (Default)
Use data type of input signal.
double
single
int8
uint8
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
2-1161
PID Controller
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1162
PID Controller
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second menu/text box to the right. Select one of the following
choices:
• Inherit via internal rule (default)
• Inherit via back propagation
• Same as first input
• Same as accumulator
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Fixed-point data types.
2-1163
PID Controller
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-1164
PID Controller
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second menu/text box to the right. Select one of the following
choices:
• Inherit via back propagation
• Same as input (default)
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Fixed-point data types.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
2-1165
PID Controller
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-1166
PID Controller
Mode
Select the category of accumulator data to specify
Settings
Default: Inherit
Inherit
Specifies inheritance rules for data types. Selecting Inherit
enables a list of possible values:
• Inherit via internal rule (default)
• Same as first input
Built in
Specifies built-in data types. Selecting Built in enables a list
of possible values:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Specifies fixed-point data types.
Expression
Specifies expressions that evaluate to data types. Selecting
Expression enables you to enter an expression.
Dependency
Clicking the Show data type assistant button for the accumulator
data type enables this parameter.
2-1167
PID Controller
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-1168
PID Controller
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-1169
PID Controller
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1170
PID Controller
Signedness
Specify whether you want the fixed-point data to be signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data to be signed.
Unsigned
Specify the fixed-point data to be unsigned.
Dependencies
Selecting Mode > Fixed point for the accumulator data type enables
this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1171
PID Controller
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision, Binary point, Integer
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values. This option appears for some blocks.
Integer
Specify integer. This setting has the same result as specifying a
binary point location and setting fraction length to 0. This option
appears for some blocks.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1172
PID Controller
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1173
PID Controller
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Binary point
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Dependencies
Selecting Mode > Fixed point for the accumulator data type enables
this parameter.
Selecting Binary point enables:
• Fraction length
Selecting Slope and bias enables:
• Slope
• Bias
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1174
PID Controller
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1175
PID Controller
Word length
Specify the bit size of the word that will hold the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Large word sizes represent large values with greater precision than
small word sizes.
Dependencies
Selecting Mode > Fixed point for the accumulator data type enables
this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1176
PID Controller
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1177
PID Controller
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point for the accumulator data type
enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1178
PID Controller
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1179
PID Controller
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias for the accumulator data type
enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1180
PID Controller
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1181
PID Controller
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias for the accumulator data type
enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1182
PID Controller
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
2-1183
PID Controller
Saturate on integer overflow
Specify whether overflows saturate.
Settings
Default: Off
On
Overflows saturate to either the minimum or maximum value
that the data type can represent.
For example, an overflow associated with a signed 8-bit integer
can saturate to -128 or 127.
Off
Overflows wrap to the appropriate value that is representable
by the data type.
For example, the number 130 does not fit in a signed 8-bit integer
and wraps to -126.
Tips
• Consider selecting this check box when your model has possible
overflow and you want explicit saturation protection in the generated
code.
• Consider clearing this check box when you want to optimize efficiency
of your generated code.
Clearing this check box also helps you avoid overspecifying how
a block handles out-of-range signals. For more information, see
“Checking for Signal Range Errors”.
• When you select this check box, saturation applies to every internal
operation on the block, not just the output or result.
• In general, the code generation process can detect when overflow
is not possible. In this case, the code generator does not produce
saturation code.
2-1184
PID Controller
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1185
PID Controller
Integer rounding mode
Specify the rounding mode for fixed-point operations.
Settings
Default: Floor
Ceiling
Rounds both positive and negative numbers toward positive
infinity. Equivalent to the MATLAB ceil function.
Convergent
Rounds number to the nearest representable value. If a tie occurs,
rounds to the nearest even integer. Equivalent to the Fixed-Point
Toolbox convergent function.
Floor
Rounds both positive and negative numbers toward negative
infinity. Equivalent to the MATLAB floor function.
Nearest
Rounds number to the nearest representable value. If a tie occurs,
rounds toward positive infinity. Equivalent to the Fixed-Point
Toolbox nearest function.
Round
Rounds number to the nearest representable value. If a tie occurs,
rounds positive numbers toward positive infinity and rounds
negative numbers toward negative infinity. Equivalent to the
Fixed-Point Toolbox round function.
Simplest
Automatically chooses between round toward floor and round
toward zero to generate rounding code that is as efficient as
possible.
Zero
Rounds number toward zero. Equivalent to the MATLAB fix
function.
2-1186
PID Controller
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Rounding” in the Simulink Fixed Point
documentation.
2-1187
PID Controller
State name
Assign unique name to each state. The state names apply only to the
selected block.
To assign a name to a single state, enter the name between quotes;
for example, 'velocity'.
To assign names to multiple states, enter a comma-delimited list
surrounded by braces; for example, {'a', 'b', 'c'}. Each name must
be unique. To assign state names with a variable that has been defined
in the MATLAB workspace, enter the variable without quotes. The
variable can be a string, cell, or structure.
Settings
Default: '
2-1188
' (no name)
PID Controller
State name must resolve to Simulink signal object
Require that state name resolve to Simulink signal object.
Settings
Default: Off
On
Require that state name resolve to Simulink signal object.
Off
Do not require that state name resolve to Simulink signal object.
Dependencies
State name enables this parameter.
Selecting this check box disables Code generation storage class.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1189
PID Controller
Code generation storage class
Select state storage class.
Settings
Default: Auto
Auto
Auto is the appropriate storage class for states that you do not
need to interface to external code.
ExportedGlobal
State is stored in a global variable
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
Dependencies
State name enables this parameter.
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage type
qualifier.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
“State Storage Classes” in the Simulink Coder documentation.
2-1190
PID Controller
Code generation storage type qualifier
Specify the Simulink Coder storage type qualifier.
Settings
Default: '
'
If left blank, no qualifier is assigned.
Dependency
Setting Code generation storage class to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Characteristics Direct Feedthrough
The following ports support direct
feedthrough:
• Reset port
• Integrator and filter initial condition
port
• Input port, for every integration
method except Forward Euler
See Also
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Supported for gain parameters P, I, and
D and for filter coefficient N
States
Inherited from driving block and
parameters
Dimensionalized
Yes
Zero-Crossing Detection
Yes (in continuous-time domain)
PID Controller (2 DOF), Gain, Integrator, Discrete-Time Integrator,
Derivative, Discrete Derivative.
2-1191
PID Controller (2 DOF)
Purpose
Simulate continuous- or discrete-time two-degree-of-freedom PID
controllers
Library
Continuous, Discrete
Description
Implement a continuous- or discrete-time two-degree-of-freedom
controller (PID, PI, or PD) in your Simulink model. The PID
Controller (2DOF) block allows you to implement setpoint weighting
in your controller to achieve both smooth setpoint tracking and good
disturbance rejection.
The PID Controller (2DOF) block generates an output signal based
on the difference between a reference signal and a measured system
output. The block computes a weighted difference signal for each of the
proportional, integral, and derivative actions according to the setpoint
weights you specify. The block output is the sum of the proportional,
integral, and derivative actions on the respective difference signals,
where each action is weighted according to the gain parameters. A
first-order pole filters the derivative action. Controller gains are
tunable either manually or automatically. Automatic tuning requires
Simulink Control Design software (PID Tuner or SISO Design Tool).
Configurable options in the PID Controller (2DOF) block include:
• Controller type (PID, PI, or PD)
• Controller form (Parallel or Ideal)
• Time domain (continuous or discrete)
• Initial conditions and reset trigger
• Output saturation limits and built-in anti-windup mechanism
• Signal tracking for bumpless control transfer and multiloop control
In one common implementation, the PID Controller (2DOF) block
operates in the feedforward path of the feedback loop. The block
receives a reference signal at the Ref input and a measured system
output at the other input. For example:
2-1192
PID Controller (2 DOF)
For a single-input block that accepts an error signal (a difference
between a setpoint and a system output), see the PID Controller block
reference page.
You can generate code to implement your controller using any Simulink
data type, including fixed-point data types. (Code generation requires
Simulink Coder software; fixed-point implementation requires the
Fixed-Point Toolbox product.)
For an example illustrating an application of the PID Controller (2
DOF) block, see the Simulink example Two Degree-of-Freedom PID
Control for Setpoint Tracking.
Data Type
Support
The PID Controller (2DOF) block accepts real signals of any numeric
data type that Simulink software supports, including fixed-point data
types. See “Data Types Supported by Simulink” in the Simulink
documentation for more information.
Parameters
The following table summarizes the PID Controller (2DOF)block
parameters, accessible via the block parameter dialog box.
2-1193
PID Controller (2 DOF)
Task
Parameters
Choose controller form and type.
• Controller Form in Main tab
• Controller
Choose discrete or continuous time.
• Time-domain
• Sample time
Choose an integration method (discrete
time).
• Integrator method
Set and tune controller gains.
• Proportional (P) in Main tab
• Filter method
• Integral (I) in Main tab
• Derivative (D) in Main tab
• Filter coefficient (N) in Main tab
• Setpoint weight (b) in Main tab
• Setpoint weight (c) in Main tab
Set integrator and filter initial conditions.
• Initial conditions Source in Main tab
• Integrator Initial condition in Main
tab
• Filter Initial condition in Main tab
• External reset in Main tab
• Ignore reset when linearizing in Main
tab
2-1194
PID Controller (2 DOF)
Task
Parameters
Limit block output.
• Limit output in PID Advanced tab
• Lower saturation limit in PID
Advanced tab
• Upper saturation limit in PID
Advanced tab
• Ignore saturation when linearizing
in PID Advanced tab
Configure anti-windup mechanism (when
you limit block output).
• Anti-windup method in PID Advanced
tab
• Back-calculation gain (Kb) in PID
Advanced tab
Enable signal tracking.
• Enable tracking mode in PID
Advanced tab
• Tracking gain (Kt) in PID Advanced
tab
Configure data types.
• Parameter data type in Data Type
Attributes tab
• Product output data type in Data
Type Attributes tab
• Summation output data type in Data
Type Attributes tab
• Accumulator data type in Data Type
Attributes tab
• Integrator output data type in Data
Type Attributes tab
• Filter output data type in Data Type
Attributes tab
2-1195
PID Controller (2 DOF)
Task
Parameters
• Saturation output data type in Data
Type Attributes tab
• Lock output data type setting against
changes by the fixed-point tools in
Data Type Attributes tab
• Saturate on integer overflow in Data
Type Attributes tab
• Integer rounding mode in Data Type
Attributes tab
Configure block for code generation.
• State name in State Attributes tab
• State name must resolve to Simulink
signal object in State Attributes tab
• Code generation storage class in
State Attributes tab
• Code generation storage type
qualifier in State Attributes tab
2-1196
PID Controller (2 DOF)
Controller form
Select the controller form.
Settings
Parallel (Default)
Selects a controller form in which the proportional, integral, and
derivative gains P, I, and D operate independently. The filter
coefficient N sets the location of the pole in the derivative filter.
Parallel two-degree-of-freedom PID controller, where input 1
receives a reference signal and input 2 receives feedback from
the measured system output:
The parallel two-degree-of-freedom PID controller can be
equivalently modeled by the following block diagram:
2-1197
PID Controller (2 DOF)
R(s) represents the reference signal and Y(s) represents the
feedback from measured system output. In this model, C(s) is a
single degree-of-freedom controller, and F(s) acts as a prefilter
on the reference signal. For a parallel two-degree-of-freedom PID
controller in the Continuous-time Time-domain, the transfer
functions F(s) and C(s) are:
Fpar ( s ) =
(bP + cDN ) s 2 + (bPN + I ) s + IN
( P + DN ) s 2 + ( PN + I ) s + IN
C par ( s ) =
( P + DN ) s 2 + ( PN + I ) s + IN
s(s + N )
where b and c are the Setpoint weight parameters.
Alternatively, the parallel two-degree-of-freedom PID controller
can be modeled by the following block diagram:
2-1198
PID Controller (2 DOF)
R(s), Y(s), and C(s) are as discussed previously. In this
realization, Q(s) acts as feed-forward conditioning on the
reference signal R(s). For a parallel PID controller in the
Continuous-time Time-domain, the transfer function Q(s) is:
Q par ( s ) =
( (b − 1) P + (c − 1) DN ) s + (b − 1) PN
s+N
Ideal
Selects a controller form in which the proportional gain P acts
on the sum of all actions.
Ideal two-degree-of-freedom PID controller, where input 1
receives a reference signal and input 2 receives feedback from
the measured system output:
2-1199
PID Controller (2 DOF)
Similarly to the parallel controller form discussed previously,
the ideal two-degree-of-freedom PID controller can be modeled
as a single degree-of-freedom controller C(s) with a prefilter
F(s). For an ideal two-degree-of-freedom PID controller in the
Continuous-time Time-domain, the transfer functions F(s)
and C(s) are:
Fid ( s ) =
(b + cDN ) s 2 + (bN + I ) s + IN
(1 + DN ) s 2 + ( N + I ) s + IN
Cid ( s ) = P
(1 + DN ) s 2 + ( N + I ) s + IN
s(s + N )
where b and c are the Setpoint weight parameters.
Alternatively, modeling the ideal two-degree-of-freedom PID
controller as a one-degree-of-freedom controller C(s) with
2-1200
PID Controller (2 DOF)
feed-forward conditioning Q(s) on the reference signal gives, in
continuous-time:
Qid ( s ) = P
( (b − 1) + (c − 1) DN ) s + (b − 1) N
s+N
The controller transfer function for the current settings is displayed in
the block dialog box.
2-1201
PID Controller (2 DOF)
Controller
Specify the controller type.
Settings
PID (Default)
Implements a controller with proportional, integral, and
derivative action.
PI
Implements a controller with proportional and integral action.
PD
Implements a controller with proportional and derivative action.
The controller transfer function for the current settings is displayed in
the block dialog box.
2-1202
PID Controller (2 DOF)
Time-domain
Select continuous or discrete time domain. The appearance of the block
changes to reflect your selection.
Settings
Continuous-time (Default)
Selects the continuous-time representation.
Discrete-time
Selects the discrete-time representation. Selecting Discrete-time
also allows you to specify the:
• Sample time, which is the discrete interval between samples.
• Discrete integration methods for the integrator and the
derivative filter using the Integrator method and Filter
method menus.
2-1203
PID Controller (2 DOF)
Integrator method
(Available only when you set Time-domain to Discrete-time.)
Specify the method used to compute the integrator output. For
more information about discrete-time integration methods, see the
Discrete-Time Integrator block reference page.
Settings
Forward Euler (Default)
Selects the Forward Rectangular (left-hand) approximation.
• This method is best for small sampling times, where the
Nyquist limit is large compared to the bandwidth of the
controller. For larger sampling times, the Forward Euler
method can result in instability, even when discretizing a
system that is stable in continuous time.
Backward Euler
Selects the Backward Rectangular (right-hand) approximation.
• If you are generating code using Simulink Coder software
or the Fixed-Point Toolbox product and you activate the
Back-calculation Anti-windup method, this integration
method can cause algebraic loops in your controller. Algebraic
loops can lead to slower performance of generated code. For
more information about algebraic loops in Simulink models, see
“Algebraic Loops” in the Simulink documentation.
• An advantage of the Backward Euler method is that
discretizing a stable continuous-time system using this method
always yields a stable discrete-time result.
Trapezoidal
Selects the Bilinear approximation.
• If you are generating code using Simulink Coder software
or the Fixed-Point Toolbox product and you activate the
Back-calculation Anti-windup method, this integration
method can cause algebraic loops in your controller. Algebraic
loops can lead to slower performance of generated code. For
2-1204
PID Controller (2 DOF)
more information about algebraic loops in Simulink models, see
“Algebraic Loops” in the Simulink documentation.
• An advantage of the Trapezoidal method is that discretizing
a stable continuous-time system using this method always
yields a stable discrete-time result. Of all available integration
methods, the Trapezoidal method yields the closest match
between frequency-domain properties of the discretized system
and the corresponding continuous-time system.
2-1205
PID Controller (2 DOF)
Filter method
(Available only when you set Time-domain to Discrete-time.)
Specify the method used to compute the derivative filter output. For
more information about discrete-time integration methods, see the
Discrete-Time Integrator block reference page.
Settings
Forward Euler (Default)
Selects the Forward Rectangular (left-hand) approximation.
• This method is best for small sampling times, where the
Nyquist limit is large compared to the bandwidth of the
controller. For larger sampling times, the Forward Euler
method can result in instability, even when discretizing a
system that is stable in continuous time.
Backward Euler
Selects the Backward Rectangular (right-hand) approximation.
• If you are generating code using Simulink Coder software or
the Fixed-Point Toolbox product, this filter method can cause
algebraic loops in your controller. Algebraic loops can lead to
slower performance of generated code. For more information
about algebraic loops in Simulink models, see “Algebraic Loops”
in the Simulink documentation.
• An advantage of the Backward Euler method is that
discretizing a stable continuous-time system using this method
always yields a stable discrete-time result. Any filter parameter
value N > 0 yields a stable result with this method.
Trapezoidal
Selects the Bilinear approximation.
• If you are generating code using Simulink Coder software or
the Fixed-Point Toolbox product, this filter method can cause
algebraic loops in your controller. Algebraic loops can lead to
slower performance of generated code. For more information
about algebraic loops in Simulink models, see “Algebraic Loops”
in the Simulink documentation.
2-1206
PID Controller (2 DOF)
• An advantage of the Trapezoidal method is that discretizing a
stable continuous-time system using this method always yields
a stable discrete-time result. Any filter parameter value N > 0
yields a stable result with this method. Of all available filter
methods, the Trapezoidal method yields the closest match
between frequency-domain properties of the discretized system
and the corresponding continuous-time system.
2-1207
PID Controller (2 DOF)
Sample time (-1 for inherited)
(Available only when you set Time-domain to Discrete-time.) Specify
the discrete interval between samples.
Settings
Default: 1
By default, the block uses a discrete sample time of 1. To specify a
different sample time, enter another discrete value, such as 0.1.
If you specify a value of –1, the PID Controller (2DOF) block inherits
the sample time from upstream blocks. Do not enter a value of 0; to
implement a continuous-time controller, select the Time-domain
Continuous-time.
See “Specify Sample Time” in the online documentation for more
information.
2-1208
PID Controller (2 DOF)
Proportional (P)
Specify the proportional gain P.
Default: 1
Enter a finite, real gain value into the Proportional (P) field. Use
either scalar or vector gain values. For a parallel PID Controller
form, the proportional action is independent of the integral and
derivative actions. For an ideal PID Controller form, the
proportional action acts on the integral and derivative actions. See
“Controller form” on page 2-1197 for more information about the role of
P in the controller transfer function.
When you have Simulink Control Design software installed, you can
automatically tune the controller gains using the PID Tuner or the
SISO Design Tool. See “Choosing a Compensator Design Approach”.
2-1209
PID Controller (2 DOF)
Integral (I)
(Available for PID and PI controllers.) Specify the integral gain I.
Default: 1
Enter a finite, real gain value into the Integral (I) field. Use either
scalar or vector gain values.
When you have Simulink Control Design software installed, you can
automatically tune the controller gains using the PID Tuner or the
SISO Design Tool. See “Choosing a Compensator Design Approach”.
2-1210
PID Controller (2 DOF)
Derivative (D)
(Available for PID and PD controllers.) Specify the derivative gain D.
Default: 0
Enter a finite, real gain value into the Derivative (D) field. Use either
scalar or vector gain values.
When you have Simulink Control Design software installed, you can
automatically tune the controller gains using the PID Tuner or the
SISO Design Tool. See “Choosing a Compensator Design Approach”.
2-1211
PID Controller (2 DOF)
Filter coefficient (N)
Specifies the filter coefficient of the controller.
(Available for PID and PD controllers.) Specify the filter coefficient N,
which determines the pole location of the filter in the derivative action:
The filter pole falls at s = -N in the Continuous-time Time-domain.
For Discrete-time, the location of the pole depends on which Filter
method you select (for sampling time Ts):
• Forward Euler:
z pole = 1 − NTs
• Backward Euler:
z pole =
1
1 + NTs
• Trapezoidal:
z pole =
1 − NTs / 2
1 + NTs / 2
Default: 100.
2-1212
PID Controller (2 DOF)
Enter a finite, real gain value into the Filter Coefficient (N) field.
Use either scalar or vector gain values. Note that the PID controller
(2DOF) block does not support N = inf (ideal unfiltered derivative).
When you have Simulink Control Design software installed, you can
automatically tune the controller gains using the PID Tuner or the
SISO Design Tool. See “Choosing a Compensator Design Approach”.
Automatic tuning requires N > 0.
2-1213
PID Controller (2 DOF)
Setpoint weight (b)
Specify the proportional setpoint weight b.
Default: 1
Enter the proportional setpoint weight value into the Setpoint weight
(b) field. Setting b = 0 eliminates the proportional action on the
reference signal, which can reduce overshoot in the system response to
step changes in the setpoint.
The following diagrams show the role of Setpoint weight (b) in
Parallel and Ideal PID controllers. See “Controller form” on page
2-1197 for a discussion of the corresponding transfer functions.
Parallel Two-Degree-of-Freedom PID Controller
2-1214
PID Controller (2 DOF)
Ideal Two-Degree-of-Freedom PID Controller
2-1215
PID Controller (2 DOF)
Setpoint weight (c)
(Available for PID and PD controllers.) Specify the derivative setpoint
weight c.
Enter the derivative setpoint weight value into the Setpoint weight (c)
field. To implement a controller that achieves both effective disturbance
rejection and smooth setpoint tracking without excessive transient
response, set c = 0. Setting c = 0 yields a controller with derivative
action on the measured system response but not on the reference input.
The following diagrams show the role of Setpoint weight (c) in
Parallel and Ideal PID controllers. See “Controller form” on page
2-1197 for a discussion of the corresponding transfer functions.
Parallel Two-Degree-of-Freedom PID Controller
2-1216
PID Controller (2 DOF)
Ideal Two-Degree-of-Freedom PID Controller
2-1217
PID Controller (2 DOF)
Initial conditions Source
Select the source of the integrator and filter initial conditions. Simulink
uses initial conditions to initialize the integrator and filter output at
the start of a simulation or at a specified trigger event (see “External
reset” on page 2-1221). The integrator and filter initial conditions in
turn determine the initial block output.
Settings
internal (Default)
Specifies the integrator and filter initial conditions explicitly
using the Integrator Initial condition and Filter Initial
condition parameters.
external
Specifies the integrator and filter initial conditions externally.
An additional input port appears under the block inputs for each
initial condition: I0 for the integrator and D0 for the filter:
2-1218
PID Controller (2 DOF)
Integrator Initial condition
(Available only when Initial conditions Source is internal and the
controller includes integral action.) Specify the integrator initial value.
Simulink uses the initial condition to initialize the integrator output at
the start of a simulation or at a specified trigger event (see “External
reset” on page 2-1221). The integrator initial condition, together with
the filter initial condition, determines the initial output of the PID
Controller (2DOF) block.
Default: 0
Simulink does not permit the integrator initial condition to be inf or
NaN.
2-1219
PID Controller (2 DOF)
Filter Initial condition
(Available only when Initial conditions Source is internal and the
controller includes integral action.) Specify the filter initial value.
Simulink uses the initial condition to initialize the filter output at
the start of a simulation or at a specified trigger event (see “External
reset” on page 2-1221). The filter initial condition, together with the
integrator initial condition, determines the initial output of the PID
Controller (2DOF) block.
Default: 0
Simulink does not permit the filter initial condition to be inf or NaN.
2-1220
PID Controller (2 DOF)
External reset
Select the trigger event that resets the integrator and filter outputs to
the initial conditions you specify in the Integrator Initial condition
and Filter Initial condition fields. Selecting any option other than
none enables a reset input on the block for the external reset signal, as
shown:
Or, if the Initial conditions Source is External:
Settings
none (Default)
Does not reset the integrator and filter outputs to initial
conditions.
rising
Resets the outputs when the reset signal has a rising edge.
falling
Resets the outputs when the reset signal has a falling edge.
2-1221
PID Controller (2 DOF)
either
Resets the outputs when the reset signal either rises or falls.
level
Resets and holds the outputs to the initial conditions while the
reset signal is nonzero.
Note To be compliant with the Motor Industry Software Reliability
Association (MISRA) software standard, your model must use Boolean
signals to drive the external reset ports of the PID controller (2DOF)
block.
2-1222
PID Controller (2 DOF)
Ignore reset when linearizing
Force Simulink linearization commands to ignore any reset mechanism
that you have chosen with the External reset menu. Ignoring reset
states allows you to linearize a model around an operating point even if
that operating point causes the PID Controller (2DOF) block to reset.
Settings
Off (Default)
Simulink linearization commands do not ignore states
corresponding to the reset mechanism.
On
Simulink linearization commands ignore states corresponding
to the reset mechanism.
2-1223
PID Controller (2 DOF)
Enable zero-crossing detection
Enable zero-crossing detection in continuous-time models upon reset
and upon entering or leaving a saturation state.
Zero-crossing detection can accurately locate signal discontinuities
without resorting to excessively small time steps that can lead to
lengthy simulation times. If you select Limit output or activate
an External reset in your PID Controller (2DOF) block, activating
zero-crossing detection can reduce computation time in your simulation.
For more information, see “Zero-Crossing Detection” in the Simulink
documentation.
Settings
On (Default)
Uses zero-crossing detection at any of the following events: reset;
entering or leaving an upper saturation state; and entering or
leaving a lower saturation state.
Off
Does not use zero-crossing detection.
Enabling zero-crossing detection for the PID Controller (2DOF) block
also enables zero-crossing detection for all under-mask blocks that
include the zero-crossing detection feature.
2-1224
PID Controller (2 DOF)
Limit output
Limit the block output to values you specify as the Lower saturation
limit and Upper saturation limit parameters.
Activating this option limits the block output internally to the block,
obviating the need for a separate Saturation block after the controller
in your Simulink model. It also allows you to activate the built-in
anti-windup mechanism (see “Anti-windup method” on page 2-1228).
Settings
Off (Default)
Does not limit the block output, which is the weighted sum of the
proportional, integral, and derivative actions.
On
Limits the block output to the Lower saturation limit or the
Upper saturation limit whenever the weighted sum exceeds
those limits. Allows you to select an Anti-windup method.
2-1225
PID Controller (2 DOF)
Lower saturation limit
(Available only when you select the Limit Output box.) Specify the
lower limit for the block output. The block output is held at the Lower
saturation limit whenever the weighted sum of the proportional,
integral, and derivative actions goes below that value.
Default: -inf
2-1226
PID Controller (2 DOF)
Upper saturation limit
(Available only when you select the Limit Output box.) Specify the
upper limit for the block output. The block output is held at the Upper
saturation limit whenever the weighted sum of the proportional,
integral, and derivative actions exceeds that value.
Default: inf
2-1227
PID Controller (2 DOF)
Anti-windup method
(Available only when you select the Limit Output option and the
controller includes integral action.) Select an anti-windup mechanism
to discharge the integrator when the block is saturated, which occurs
when the sum of the block components exceeds the output limits.
When you select the Limit output check box and the weighted sum of
the controller components exceeds the specified output limits, the block
output holds at the specified limit. However, the integrator output
can continue to grow (integrator wind-up), increasing the difference
between the block output and the sum of the block components. Without
a mechanism to prevent integrator wind-up, two results are possible:
• If the sign of the input signal never changes, the integrator continues
to integrate until it overflows. The overflow value is the maximum or
minimum value for the data type of the integrator output.
• If the sign of the input signal changes once the weighted sum has
grown beyond the output limits, it can take a long time to discharge
the integrator and return the weighted sum within the block
saturation limit.
In both cases, controller performance can suffer. To combat the effects
of wind-up without an anti-windup mechanism, it may be necessary
to detune the controller (for example, by reducing the controller
gains), resulting in a sluggish controller. Activating an anti-windup
mechanism can improve controller performance.
Settings
none (Default)
Does not use an anti-windup mechanism. This setting can cause
the block’s internal signals to be unbounded even if the output
appears to be bounded by the saturation limits. This can result in
slow recovery from saturation or unexpected overflows.
back-calculation
Discharges the integrator when the block output saturates using
the integral-gain feedback loop:
2-1228
PID Controller (2 DOF)
You can also specify a value for the Back-calculation
coefficient (Kb).
clamping
Stops integration when the sum of the block components exceeds
the output limits and the integrator output and block input have
the same sign. Resumes integration when the sum of the block
components exceeds the output limits and the integrator output
and block input have opposite sign. The integrator portion of the
block is:
The clamping circuit implements the logic necessary to determine
whether integration continues.
2-1229
PID Controller (2 DOF)
Back-calculation gain (Kb)
(Available only when the back-calculation Anti-windup method is
active.) Specify the gain coefficient of the anti-windup feedback loop.
The back-calculation anti-windup method discharges the integrator
on block saturation using a feedback loop having gain coefficient Kb.
Default: 1
2-1230
PID Controller (2 DOF)
Ignore saturation when linearizing
Force Simulink linearization commands ignore PID Controller (2DOF)
block output limits. Ignoring output limits allows you to linearize a
model around an operating point even if that operating point causes the
PID Controller (2DOF) block to exceed the output limits.
Settings
On (Default)
Simulink linearization commands ignore states corresponding
to saturation.
Off
Simulink linearization commands do not ignore states
corresponding to saturation.
2-1231
PID Controller (2 DOF)
Enable tracking mode
(Available for any controller with integral action.) Activate signal
tracking, which lets the output of the PID Controller (2DOF) block
follow a tracking signal. Provide the tracking signal to the block at the
TR port, which becomes active when you select Enable tracking mode.
When signal tracking is active, the difference between the tracked signal
and the block output is fed back to the integrator input with a gain Kt.
You can also specify the value of the Tracking coefficient (Kt).
For information about using tracking mode to implement bumpless
control transfer scenarios and multiloop controllers, see “Enable
tracking mode” on page 2-1143 in the PID Controller reference page.
Settings
Off (Default)
Disables signal tracking and removes TR block input.
On
Enables signal tracking and activates TR input.
2-1232
PID Controller (2 DOF)
Tracking gain (Kt)
(Available only when you select Enable tracking mode.) Specify Kt,
which is the gain of the signal tracking feedback loop.
Default: 1
2-1233
PID Controller (2 DOF)
Parameter data type
Select the data type of the gain parameters P, I, D, N, Kb, and Kt and
the setpoint weighting parameters b and c.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Inherit via back propagation
Use data type of the driving block.
Inherit:
Same as input
Use data type of input signal.
double
single
int8
2-1234
PID Controller (2 DOF)
uint8
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1235
PID Controller (2 DOF)
Product output data type
Select the product output data type of the gain parameters P, I, D, N,
Kb, and Kt and the setpoint weighting parameters b and c .
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Inherit via back propagation
Use data type of the driving block.
Inherit:
Same as input
Use data type of input signal.
double
single
int8
2-1236
PID Controller (2 DOF)
uint8
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1237
PID Controller (2 DOF)
Summation output data type
Select the summation output data type of the sums Sum, Sum1,
Sum2, Sum3, Sum D, Sum I1 , SumI2 ,and SumI3, which are sums
computed internally within the block. To see where Simulink computes
each of these sums , right-click the PID Controller (2DOF) block in your
model and select Look Under Mask:
• Sum is the weighted sum of the proportional, derivative, and integral
signals.
• Sum1 is the difference between the reference input weighted by b
and the measured system response.
• Sum2 is the difference between the reference input weighted by c
and the measured system response.
• Sum3 is the difference between the unweighted reference input and
the measured system response.
• SumD is the sum in the derivative filter feedback loop.
• SumI1 is the sum of the block input signal (weighted by the integral
gain I) and SumI2. SumI1 is computed only when Limit output
and Anti-windup method back-calculation are active.
• SumI2 is the difference between the weighted sum Sum and the
limited block output. SumI2 is computed only when Limit output
and Anti-windup method back-calculation are active.
• SumI3 is the difference between the block output and the signal at
the block’s tracking input. SumI3 is computed only when you select
the Enable tracking mode box.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
2-1238
PID Controller (2 DOF)
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Same as first input
Use data type of first input signal.
double
single
int8
uint8
int16
uint16
int32
uint32
2-1239
PID Controller (2 DOF)
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1240
PID Controller (2 DOF)
Accumulator data type
Specify the accumulator data type.
Settings
Default: Inherit:
Inherit:
Inherit via internal rule
Inherit via internal rule
Use internal rule to determine accumulator data type.
Inherit:
Same as first input
Use data type of first input signal.
double
Accumulator data type is double.
single
Accumulator data type is single.
int8
Accumulator data type is int8.
uint8
Accumulator data type is uint8.
int16
Accumulator data type is int16.
uint16
Accumulator data type is uint16.
int32
Accumulator data type is int32.
uint32
Accumulator data type is uint32.
fixdt(1,16,0)
Accumulator data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Accumulator data type is fixed point fixdt(1,16,2^0,0).
2-1241
PID Controller (2 DOF)
<data type expression>
The name of a data type object, for example
Simulink.NumericType
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specify Data Types Using Data Type
Assistant”.
2-1242
PID Controller (2 DOF)
Integrator output data type
Select the data type of the integrator output.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Same as input
Use data type of input signal.
double
single
int8
uint8
2-1243
PID Controller (2 DOF)
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1244
PID Controller (2 DOF)
Filter output data type
Select the data type of the filter output.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Inherit via internal rule (Default)
Simulink software chooses a combination of output scaling and
data type that requires the smallest amount of memory. This
memory requirement accommodates the calculated output range
and maintains the output precision of the block and word size of
the targeted hardware implementation specified for the model. If
the Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic) (a generic 32-bit
microprocessor) is the specified target hardware, the output data
type is int32.
Inherit:
Same as input
Use data type of input signal.
double
single
int8
uint8
2-1245
PID Controller (2 DOF)
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1246
PID Controller (2 DOF)
Saturation output data type
Select the saturation output data type.
See “Data Types Supported by Simulink” in the Simulink documentation
for more information.
Settings
Inherit:
Same as input (Default)
Use data type of input signal.
double
single
int8
uint8
int16
uint16
int32
uint32
fixdt(1,16)
fixdt(1,16,0)
fixdt(1,16,2^0,0)
2-1247
PID Controller (2 DOF)
<data type expression>
Name of a data type object. For example, Simulink.NumericType.
2-1248
PID Controller (2 DOF)
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second menu/text box to the right. Select one of the following
choices:
• Inherit via internal rule (default)
• Inherit via back propagation
• Same as first input
• Same as accumulator
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Fixed-point data types.
2-1249
PID Controller (2 DOF)
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-1250
PID Controller (2 DOF)
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second menu/text box to the right. Select one of the following
choices:
• Inherit via back propagation
• Same as input (default)
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Fixed-point data types.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
2-1251
PID Controller (2 DOF)
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-1252
PID Controller (2 DOF)
Mode
Select the category of accumulator data to specify
Settings
Default: Inherit
Inherit
Specifies inheritance rules for data types. Selecting Inherit
enables a list of possible values:
• Inherit via internal rule (default)
• Same as first input
Built in
Specifies built-in data types. Selecting Built in enables a list
of possible values:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Specifies fixed-point data types.
Expression
Specifies expressions that evaluate to data types. Selecting
Expression enables you to enter an expression.
Dependency
Clicking the Show data type assistant button for the accumulator
data type enables this parameter.
2-1253
PID Controller (2 DOF)
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-1254
PID Controller (2 DOF)
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-1255
PID Controller (2 DOF)
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1256
PID Controller (2 DOF)
Signedness
Specify whether you want the fixed-point data to be signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data to be signed.
Unsigned
Specify the fixed-point data to be unsigned.
Dependencies
Selecting Mode > Fixed point for the accumulator data type enables
this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1257
PID Controller (2 DOF)
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision, Binary point, Integer
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values. This option appears for some blocks.
Integer
Specify integer. This setting has the same result as specifying a
binary point location and setting fraction length to 0. This option
appears for some blocks.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1258
PID Controller (2 DOF)
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1259
PID Controller (2 DOF)
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Binary point
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Dependencies
Selecting Mode > Fixed point for the accumulator data type enables
this parameter.
Selecting Binary point enables:
• Fraction length
Selecting Slope and bias enables:
• Slope
• Bias
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1260
PID Controller (2 DOF)
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1261
PID Controller (2 DOF)
Word length
Specify the bit size of the word that will hold the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Large word sizes represent large values with greater precision than
small word sizes.
Dependencies
Selecting Mode > Fixed point for the accumulator data type enables
this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1262
PID Controller (2 DOF)
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1263
PID Controller (2 DOF)
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point for the accumulator data type
enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1264
PID Controller (2 DOF)
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1265
PID Controller (2 DOF)
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias for the accumulator data type
enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1266
PID Controller (2 DOF)
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1267
PID Controller (2 DOF)
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias for the accumulator data type
enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specifying a Fixed-Point Data Type” for more information.
2-1268
PID Controller (2 DOF)
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
2-1269
PID Controller (2 DOF)
Saturate on integer overflow
Specify whether overflows saturate.
Settings
Default: Off
On
Overflows saturate to either the minimum or maximum value
that the data type can represent.
For example, an overflow associated with a signed 8-bit integer
can saturate to -128 or 127.
Off
Overflows wrap to the appropriate value that is representable
by the data type.
For example, the number 130 does not fit in a signed 8-bit integer
and wraps to -126.
Tips
• Consider selecting this check box when your model has possible
overflow and you want explicit saturation protection in the generated
code.
• Consider clearing this check box when you want to optimize efficiency
of your generated code.
Clearing this check box also helps you avoid overspecifying how
a block handles out-of-range signals. For more information, see
“Checking for Signal Range Errors”.
• When you select this check box, saturation applies to every internal
operation on the block, not just the output or result.
• In general, the code generation process can detect when overflow
is not possible. In this case, the code generator does not produce
saturation code.
2-1270
PID Controller (2 DOF)
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1271
PID Controller (2 DOF)
Integer rounding mode
Specify the rounding mode for fixed-point operations.
Settings
Default: Floor
Ceiling
Rounds both positive and negative numbers toward positive
infinity. Equivalent to the MATLAB ceil function.
Convergent
Rounds number to the nearest representable value. If a tie occurs,
rounds to the nearest even integer. Equivalent to the Fixed-Point
Toolbox convergent function.
Floor
Rounds both positive and negative numbers toward negative
infinity. Equivalent to the MATLAB floor function.
Nearest
Rounds number to the nearest representable value. If a tie occurs,
rounds toward positive infinity. Equivalent to the Fixed-Point
Toolbox nearest function.
Round
Rounds number to the nearest representable value. If a tie occurs,
rounds positive numbers toward positive infinity and rounds
negative numbers toward negative infinity. Equivalent to the
Fixed-Point Toolbox round function.
Simplest
Automatically chooses between round toward floor and round
toward zero to generate rounding code that is as efficient as
possible.
Zero
Rounds number toward zero. Equivalent to the MATLAB fix
function.
2-1272
PID Controller (2 DOF)
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Rounding” in the Simulink Fixed Point
documentation.
2-1273
PID Controller (2 DOF)
State name
Assign unique name to each state. The state names apply only to the
selected block.
To assign a name to a single state, enter the name between quotes;
for example, 'velocity'.
To assign names to multiple states, enter a comma-delimited list
surrounded by braces; for example, {'a', 'b', 'c'}. Each name must
be unique. To assign state names with a variable that has been defined
in the MATLAB workspace, enter the variable without quotes. The
variable can be a string, cell, or structure.
Settings
Default: '
' (no name)
State name must resolve to Simulink signal object
Require that state name resolve to Simulink signal object.
Settings
Default: Off
On
Require that state name resolve to Simulink signal object.
Off
Do not require that state name resolve to Simulink signal object.
Dependencies
State name enables this parameter.
Selecting this check box disables Code generation storage class.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1274
PID Controller (2 DOF)
Code generation storage class
Select state storage class.
Settings
Default: Auto
Auto
Auto is the appropriate storage class for states that you do not
need to interface to external code.
ExportedGlobal
State is stored in a global variable
ImportedExtern
model_private.h declares the state as an extern variable.
ImportedExternPointer
model_private.h declares the state as an extern pointer.
Dependencies
State name enables this parameter.
Setting this parameter to ExportedGlobal, ImportedExtern, or
ImportedExternPointer enables Code generation storage type
qualifier.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
“State Storage Classes” in the Simulink Coder documentation.
2-1275
PID Controller (2 DOF)
Code generation storage type qualifier
Specify the Simulink Coder storage type qualifier.
Settings
Default: '
'
If left blank, no qualifier is assigned.
Dependency
Setting Code generation storage class to ExportedGlobal,
ImportedExtern, or ImportedExternPointer enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
Characteristics Direct Feedthrough
The following ports support direct
feedthrough:
• Reset port
• Integrator and filter initial condition
port
• Input port, for every integration
method except Forward Euler
2-1276
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Supported for gain parameters P, I,
and D for filter coefficient N, and for
setpoint weights b and c
States
Inherited from driving block and
parameters
Dimensionalized
Yes
Zero-Crossing Detection
Yes (in continuous-time domain)
PID Controller (2 DOF)
See Also
PID Controller, Gain, Integrator, Discrete-Time Integrator, Derivative,
Discrete Derivative.
2-1277
Polynomial
Purpose
Perform evaluation of polynomial coefficients on input values
Library
Math Operations
Description
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. The inputs and coefficients must be real.
Data Type
Support
The Polynomial block accepts real signals of type double or single.
The Polynomial coefficients parameter must be of the same type as
the inputs. The output data type is the same as the input data type.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-1278
Polynomial
Parameters
and
Dialog
Box
Polynomial coefficients
Specify polynomial coefficients in MATLAB polyval form. The
first coefficient corresponds to xN and the remaining coefficients
correspond to decreasing orders of x. The last coefficient
represents the constant for the polynomial. See polyval in the
MATLAB documentation for more information.
2-1279
Polynomial
Examples
The sldemo_boiler model shows how to use the Polynomial block.
In the Boiler Plant model/digital thermometer subsystem, the
Polynomial block models a first-order polynomial using the coefficients
[0.05 0.75]:
Characteristics Direct Feedthrough
2-1280
Yes
Sample Time
Inherited from the driving block
Scalar Expansion
No
Dimensionalized
Yes
Multidimensionalized
No
Zero-Crossing Detection
No
Prelookup
Purpose
Compute index and fraction for Interpolation Using Prelookup block
Library
Lookup Tables
Description
How This Block Works with an Interpolation Using Prelookup
Block
The Prelookup block works best with the Interpolation Using Prelookup
block. The Prelookup block calculates the index and interval fraction
that specify how its input value u relates to the breakpoint data set. You
feed the resulting index and fraction values into an Interpolation Using
Prelookup block to interpolate an n-dimensional table. This combination
of blocks performs the same operation that a single instance of the
n-D Lookup Table block performs. However, the Prelookup and
Interpolation Using Prelookup blocks offer greater flexibility that
can provide more efficient simulation and code generation. For more
information, see “Efficiency of Performance” in the Simulink User’s
Guide.
Supported Block Operations
To use the Prelookup block, you specify a set of breakpoint values
directly on the dialog box or feed values into the bp input port.
Typically, this breakpoint data set corresponds to one dimension of the
table data in an Interpolation Using Prelookup block. The Prelookup
block generates a pair of outputs for each input value u by calculating:
• The index of the breakpoint set element that is less than or equal to u
and forms an interval containing u
• The interval fraction in the range 0 ≤ f < 1, which represents the
normalized position of u on the breakpoint interval between the index
and the next index value for in-range input
For example, if the breakpoint data set is [ 0 5 10 20 50 100 ] and
the input value u is 55, the index is 4 and the fractional value is 0.1.
Labels for the index and interval fraction appear as k and f on the
Prelookup block icon. The index value is zero-based.
2-1281
Prelookup
The interval fraction can be negative or greater than 1 for out-of-range
input. See the documentation for the Extrapolation method block
parameter for more information.
Data Type
Support
The Prelookup block accepts real signals of any numeric data type that
Simulink supports, except Boolean. The Prelookup block supports
fixed-point data types for signals and breakpoint data.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-1282
Prelookup
Parameters
and
Dialog
Box
The Main pane of the Prelookup block dialog box appears as follows:
Breakpoint data
Specify whether to enter breakpoint data directly on the dialog
box or to inherit the data from an input port.
• If you set Source to Dialog, enter breakpoint data in the edit
field under Value. Each breakpoint data set must be a strictly
monotonically increasing vector that contains two or more
elements. For this option, you specify breakpoint attributes on
the Data Types pane.
2-1283
Prelookup
• If you set Source to Input port, verify that an upstream
signal supplies breakpoint data to the bp input port. Each
breakpoint data set must be a strictly monotonically increasing
vector that contains two or more elements. For this option, your
block inherits breakpoint attributes from the bp input port.
Click the Edit button to open the Lookup Table Editor (see “Edit
Existing LookupTables” in the Simulink documentation).
Tip To learn how to define evenly spaced breakpoints, see
“Formulation of Evenly Spaced Breakpoints” in the Simulink
documentation.
Index search method
Select Evenly spaced points, Linear search, or Binary
search. Each search method has speed advantages in different
situations:
• For evenly spaced breakpoint sets (for example, 10, 20, 30, and
so on), you achieve optimal speed by selecting Evenly spaced
points to calculate table indices.
This algorithm uses only the first two breakpoints of a set to
determine the offset and spacing of the remaining points.
• For unevenly spaced breakpoint sets, follow these guidelines:
— If input values for u do not vary much between time steps,
selecting Linear search with Begin index search using
previous index result produces the best performance.
— If input values for u jump more than one or two table
intervals per time step, selecting Binary search produces
the best performance.
A suboptimal choice of index search method can lead to slow
performance of models that rely heavily on lookup tables.
2-1284
Prelookup
Tip The generated code stores only the first breakpoint, the
spacing, and the number of breakpoints when:
• The breakpoint data is not tunable.
• The index search method is Evenly spaced points.
Begin index search using previous index result
Select this check box when you want the block to start its search
using the index found at the previous time step. For input values
of u that change slowly with respect to the interval size, enabling
this option can improve performance. Otherwise, the linear
search and binary search methods can take longer, especially for
large breakpoint sets.
Output only the index
Select this check box when you want the block to output only the
resulting index value, without the interval fraction.
Typical applications include:
• Feeding a Direct Lookup Table (n-D) block, with no
interpolation on the interval
• Feeding selection ports of a subtable selection for an
Interpolation Using Prelookup block
• Performing nonlinear quantizations
Extrapolation method
Specify how to handle out-of-range values for the block input u.
Options include:
• Clip
2-1285
Prelookup
Block Input
Block Outputs
Less than the first breakpoint
• Index of the first
breakpoint (for example, 0)
— Interval fraction of 0
Greater than the last
breakpoint
• Index of the next-to-last
breakpoint
— Interval fraction of 1
Suppose the range is [1 2 3] and you select this option. If u is
0.5, the index is 0 and the interval fraction is 0. If u is 3.5, the
index is 1 and the interval fraction is 1.
• Linear
Block Input
Block Outputs
Less than the first breakpoint
• Index of the first
breakpoint (for example, 0)
— Interval fraction that
represents the linear
distance from u to the first
breakpoint
Greater than the last
breakpoint
• Index of the next-to-last
breakpoint
— Interval fraction that
represents the linear
distance from the
next-to-last breakpoint
to u
Suppose the range is [1 2 3] and you select this option. If u is
0.5, the index is 0 and the interval fraction is -0.5. If u is 3.5,
the index is 1 and the interval fraction is 1.5.
2-1286
Prelookup
Tip The Prelookup block supports linear extrapolation only when
all of these conditions apply:
• The input u, breakpoint data, and fraction output use
floating-point data types.
• The index uses a built-in integer data type.
Use last breakpoint for input at or above upper limit
Specify how to index input values of u that are greater than or
equal to the last breakpoint. The index value is zero-based. When
input equals the last breakpoint, block outputs differ as follows:
Check Box
Block Outputs
Selected
• Index of the last element in the breakpoint
data set
• Interval fraction of 0
Cleared
• Index of the next-to-last breakpoint
• Interval fraction of 1
This check box is visible only when:
• Output only the index is cleared.
• Extrapolation method is Clip.
However, when Output only the index is selected and
Extrapolation method is Clip, the block behaves as if this
check box is selected even though it is invisible.
2-1287
Prelookup
Tip When you select Use last breakpoint for input at or
above upper limit for a Prelookup block, you must also select
Valid index input may reach last index for the Interpolation
Using Prelookup block to which it connects. This action allows the
blocks to use the same indexing convention when accessing the
last elements of their breakpoint and table data sets.
Diagnostic for out-of-range input
Specify whether to produce a warning or error when the input u is
out of range. Options include:
• None — no warning or error
• Warning — display a warning in the MATLAB Command
Window and continue the simulation
• Error — halt the simulation and display an error in the
Simulation Diagnostics Viewer
Remove protection against out-of-range input in generated code
Specify whether or not to include code that checks for out-of-range
breakpoint inputs.
2-1288
Check Box
Result
When to Use
Selected
Generated code
does not include
conditional
statements to check
for out-of-range
breakpoint inputs.
For code efficiency
Cleared
Generated code
includes conditional
statements to check
for out-of-range
breakpoint inputs.
For safety-critical
applications
Prelookup
Depending on your application, you can run the following Model
Advisor checks to verify the usage of this check box:
• By Product > Embedded Coder > Identify lookup table
blocks that generate expensive out-of-range checking
code
• By Product > Simulink Verification and
Validation > Modeling Standards > DO-178C/DO-331
Checks > Check usage of lookup table blocks
For more information about the Model Advisor, see “Consult the
Model Advisor” in the Simulink documentation.
Sample time
Specify the time interval between samples. To inherit the sample
time, set this parameter to -1. See “Specify Sample Time” in the
Simulink User’s Guide for more information.
2-1289
Prelookup
The Data Types pane of the Prelookup block dialog box appears as
follows:
Note The parameters for breakpoint attributes (data type, minimum,
and maximum) are not available when you set Source to Input port.
In this case, the block inherits all breakpoint attributes from the bp
input port.
Breakpoint > Data Type
Specify the breakpoint data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
as input
2-1290
Same
Prelookup
• The name of a built-in data type, for example, single
• The name of a data type object, for example, a
Simulink.NumericType object
• An expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
breakpoint data type.
See “Specify Data Types Using Data Type Assistant” in the
Simulink User’s Guide for more information.
Tip Specify a breakpoint data type different from the data type of
input u for these cases:
• Lower memory requirement for storing breakpoint data that
uses a smaller type than the input signal u
• Sharing of prescaled breakpoint data between two Prelookup
blocks with different data types for input u
• Sharing of custom storage breakpoint data in the generated
code for blocks with different data types for input u
Breakpoint > Minimum
Specify the minimum value that the breakpoint data can have.
The default value is [] (unspecified).
Breakpoint > Maximum
Specify the maximum value that the breakpoint data can have.
The default value is [] (unspecified).
2-1291
Prelookup
Index > Data Type
Specify a data type that can index all elements in the breakpoint
data set. You can:
• Select a built-in integer data type from the list.
• Specify an integer data type using a fixed-point representation.
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the index
data type.
See “Specify Data Types Using Data Type Assistant” in the
Simulink User’s Guide for more information.
Fraction > Data Type
Specify the data type of the interval fraction. You can:
• Select a built-in data type from the list.
• Specify data type inheritance through an internal rule.
• Specify a fixed-point data type using the [Slope Bias] or
binary-point-only scaling representation.
— If you use the [Slope Bias] representation, the scaling must
be trivial — that is, the slope is 1 and the bias is 0.
— If you use the binary-point-only representation, the fixed
power-of-two exponent must be less than or equal to zero.
Click the Show data type assistant button
to
display the Data Type Assistant, which helps you set the
fraction data type.
See “Specify Data Types Using Data Type Assistant” in the
Simulink User’s Guide for more information.
2-1292
Prelookup
Lock output data type setting against changes by the fixed-point
tools
Select to lock the output data type setting of this block against
changes by the Fixed-Point Tool and the Fixed-Point Advisor. For
more information, see “Use Lock Output Data Type Setting”.
Integer rounding mode
re youSpecify the rounding mode for fixed-point operations. For
more information, see “Rounding” in the Simulink Fixed Point
documentation.
Block parameters always round to the nearest representable
value. To control the rounding of a block parameter, enter an
expression using a MATLAB rounding function into the mask
field.
Examples
In the following model, a Constant block feeds the breakpoint data set
to the bp input port of the Prelookup block.
The Prelookup block inherits the following breakpoint attributes from
the bp input port:
2-1293
Prelookup
Breakpoint Attribute
Value
Minimum
–Inf
Maximum
Inf
Data type
single
Similarly, a Constant block feeds the table data values to the T input
port of the Interpolation Using Prelookup block, which inherits the
following table attributes:
Table Attribute
Value
Minimum
–Inf
Maximum
Inf
Data type
single
Simulink uses double-precision, floating-point data to perform the
computations in this model. However, the model stores the breakpoint
and table data as single-precision, floating-point data. Using a
lower-precision data type to store breakpoint and table data reduces
the memory requirement.
For other examples, see “Prelookup and Interpolation Blocks” in the
Simulink documentation.
Characteristics Direct Feedthrough
See Also
2-1294
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes
Dimensionalized
Yes
Zero-Crossing Detection
No
Interpolation Using Prelookup
Probe
Purpose
Output signal attributes, including width, dimensionality, sample time,
and complex signal flag
Library
Signal Attributes
Description
The Probe block outputs selected information about the signal on its
input. The block can output the input signal’s width, dimensionality,
sample time, and a flag indicating whether the input is a complex-valued
signal. The block has one input port. The number of output ports
depends on the information that you select for probing, that is, signal
dimensionality, sample time, and/or complex signal flag. Each probed
value is output as a separate signal on a separate output port. The
block accepts real or complex-valued signals of any built-in data type.
It outputs signals of type double. During simulation, the block icon
displays the probed data.
Data Type
Support
The Probe block accepts signals of the following data types:
• Floating point
• Built-in integer
• Fixed point
• Boolean
• Enumerated (input only)
• Bus object
2-1295
Probe
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
You can use an array of buses as an input signal to a Probe block. For
details about defining and using an array of buses, see “Combine Buses
into an Array of Buses”.
Parameters
and
Dialog
Box
The Main pane of the Probe block dialog box appears as follows:
Probe width
Select to output the width, or number of elements, of the probed
signal.
2-1296
Probe
Probe sample time
Select to output the sample time of the probed signal. The output
is a two-element vector that specifies the period and offset of the
sample time, respectively. See “Specify Sample Time” for more
information.
Detect complex signal
Select to output 1 if the probed signal is complex; otherwise, 0.
Probe signal dimensions
Select to output the dimensions of the probed signal.
Detect framed signal
Select to output 1 if the probed signal is framed; otherwise, 0.
The Signal Attributes pane of the Probe block dialog box appears
as follows:
2-1297
Probe
Note The Probe block ignores the Data type override setting of the
Fixed-Point Tool.
Data type for width
Select the output data type for the width information.
Data type for sample time
Select the output data type for the sample time information.
Data type for signal complexity
Select the output data type for the complexity information.
2-1298
Probe
Data type for signal dimensions
Select the output data type for the dimensions information.
Data type for signal frames
Select the output data type for the frames information.
Note For Data type for width, Data type for sample time, and
Data type for signal dimensions, the Boolean data type is not
supported. Furthermore, if you select Same as input in any of these
drop-down lists, and the block’s input signal data type is Boolean, when
you simulate your model, you see an error.
Examples
The sldemo_fuelsys model shows how you can use the Probe block.
In the fuel_rate_control/validate_sample_time subsystem, the
Probe block determines the sample time of the input signal to verify
that it matches the assumed value of the design:
Characteristics Direct Feedthrough
Yes
Sample Time
Inherited from driving block
Scalar Expansion
Yes
Dimensionalized
Yes
2-1299
Probe
2-1300
Multidimensionalized
Yes
Zero-Crossing Detection
No
Product
Purpose
Multiply and divide scalars and nonscalars or multiply and invert
matrices
Library
Math Operations
Description
Default Product Block Use
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. The default parameter values that specify
this behavior are:
• Multiplication: Element-wise(.*)
• Number of inputs: 2
Setting non-default values for either of these parameters can change
a Product block to function as a Divide block or a Product of Elements
block. See the documentation of those two blocks for more information.
If all you need is to multiply two inputs to create an output, you can use
the Product block with default parameter values. If you need additional
capabilities, see “Product Block Capabilities” on page 2-1302.
The following table shows the output of the Product block for example
inputs using default block parameter values.
2-1301
Product
Inputs and Behavior
Example
Scalar X Scalar
Output the product of the
two inputs.
Scalar X Nonscalar
Output a nonscalar having
the same dimensions as
the input nonscalar. Each
element of the output
nonscalar is the product of
the input scalar and the
corresponding element of
the input nonscalar.
Nonscalar X Nonscalar
Output a nonscalar having
the same dimensions as
the inputs. Each element
of the output is the product
of corresponding elements
of the inputs.
Product Block Capabilities
The Product block, the Divide block, and the Product of Elements block
are actually the same underlying block with different default values
for the Number of inputs parameter. All three blocks can therefore
provide the same capabilities. The Product block (or the Divide block or
Product of Elements block if appropriately configured) can:
• Numerically multiply and divide any number of scalar, vector, or
matrix inputs
2-1302
Product
• Perform matrix multiplication and division on any number of matrix
inputs
The Product block performs scalar or matrix multiplication, depending
on the value of the Multiplication parameter. The block accepts one
or more inputs, depending on the Number of inputs parameter. The
Number of inputs parameter also specifies the operation to perform
on each input.
The Product block can input any combination of scalars, vectors, and
matrices for which the operation to perform has a mathematically
defined result. The block performs the specified operations on the
inputs, then outputs the result.
The Product block has two modes: Element-wise mode, which processes
nonscalar inputs element by element, and Matrix mode, which processes
nonscalar inputs as matrices. The next two sections describe these
two modes.
Element-wise Mode
When the value of the Multiplication parameter is Element-wise(.*),
the Product block is in Element-wise mode, in which it operates on the
individual numeric elements of any nonscalar inputs. The MATLAB
equivalent is the .* operator. In element-wise mode, the Product
block can perform a variety of multiplication, division, and arithmetic
inversion operations.
The value of the Number of inputs parameter controls both how many
inputs exist and whether each is multiplied or divided to form the
output. When the Product block in Element-wise mode has only one
input, it is functionally equivalent to a Product of Elements block. When
the block has multiple inputs, any nonscalar inputs must have identical
dimensions, and the block outputs a nonscalar with those dimensions.
To calculate the output, the block first expands any scalar input to a
nonscalar that has the same dimensions as the nonscalar inputs.
This table shows the output of the Product block for example inputs,
using the indicated values for the Number of inputs parameter.
2-1303
Product
Parameter Values
Number of inputs: 2
Number of inputs: */
Number of inputs: /**/
2-1304
Examples
Product
Parameter Values
Examples
Number of inputs: **
Number of inputs: */*
Matrix Mode
When the value of the Multiplication parameter is Matrix(*), the
Product block is in Matrix mode, in which it processes nonscalar inputs
as matrices. The MATLAB equivalent is the * operator. In Matrix
mode, the Product block can invert a single square matrix, or multiply
and divide any number of matrices that have dimensions for which the
result is mathematically defined.
The value of the Number of inputs parameter controls both how many
inputs exist and whether each input matrix is multiplied or divided to
form the output. The syntax of Number of inputs is the same as in
Element-wise mode. The difference between the modes is in the type of
multiplication and division that occur.
Expected Differences Between Simulation and Code
Generation
For element-wise operations on complex floating-point inputs,
simulation and code generation results might differ in near-overflow
cases. Although complex numbers is selected and non-finite
numbers is not selected on the Code Generation > Interface pane
2-1305
Product
of the Configuration Parameters dialog box, the code generator does
not emit special case code for intermediate overflows. This method
improves the efficiency of embedded operations for the general case that
does not include extreme values. If the inputs might include extreme
values, please manage these cases explicitly.
The generated code might not produce the exact same pattern of NaN
and inf values as simulation when these values are mathematically
meaningless. For example, if the simulation output contains a NaN,
output from the generated code also contains a NaN, but not necessarily
in the same place.
Data Type
Support
The Product block accepts real or complex signals of any numeric data
type that Simulink supports, including fixed-point data types. For more
information, see “Data Types Supported by Simulink” in the Simulink
documentation.
The Product block does not support numeric division for complex signals
with boolean or fixed-point data types. For other types, the block
accepts complex signals as divisors only when the input and output
signals all specify the same built-in data type. In this case, however,
the block ignores its specified rounding mode.
The Product block accepts multidimensional signals when operating
in Element-wise mode, but not when operating in Matrix mode. See
“Signal Dimensions”, “Element-wise Mode” on page 2-1303, and “Matrix
Mode” on page 2-1305 for more information.
2-1306
Product
Parameters
and
Dialog
Box
The Main pane of the Product block dialog box appears as follows:
2-1307
Product
Signal Attributes Pane
The Signal Attributes pane of the Product block dialog box appears
as follows:
2-1308
Product
2-1309
Product
Show data type assistant
Display the Data Type Assistant.
Settings
The Data Type Assistant helps you set the Output data type
parameter.
For more information, see “Specify Block Output Data Types”.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1310
Product
Number of inputs
Control two properties of the Product block:
• The number of input ports on the block
• Whether each input is multiplied or divided into the output
Settings
Default:2
• 1 or * or /
Has one input. In Element-wise mode, the input is processed as
described for the Product of Elements block. In Matrix mode, if the
parameter value is 1 or * the block outputs the input value. If the
value is / the input must be a square matrix (including a scalar as
a degenerate case) and the block outputs the matrix inverse. See
“Element-wise Mode” on page 2-1303 and “Matrix Mode” on page
2-1305 for more information.
• An integer value > 1
Has number of inputs given by the integer value. The inputs are
multiplied together in Element-wise mode or Matrix mode, as
specified by the Multiplication parameter. See “Element-wise
Mode” on page 2-1303 and “Matrix Mode” on page 2-1305 for more
information.
• An unquoted string of two or more * and / characters
Has the number of inputs given by the length of the string. Each
input that corresponds to a * character is multiplied into the output.
Each input that corresponds to a / character is divided into the
output. The operations occur in Element-wise mode or Matrix mode,
as specified by the Multiplication parameter. See “Element-wise
Mode” on page 2-1303 and “Matrix Mode” on page 2-1305 for more
information.
2-1311
Product
Dependency
Setting Number of inputs to * and selecting Element-wise(.*) for
Multiplication enable the following parameter:
• Multiply over
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1312
Product
Multiplication
Specify whether the Product block operates in Element-wise mode or
Matrix mode.
Settings
Default: Element-wise(.*)
Element-wise(.*)
Operate in Element-wise mode.
Matrix(*)
Operate in Matrix mode.
Dependency
Selecting Element-wise(.*) and setting Number of inputs to *
enable the following parameter:
• Multiply over
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1313
Product
Multiply over
Affect multiplication on matrix input.
Settings
Default: All dimensions
All dimensions
Output a scalar that is product of all elements of the matrix, or
the product of their inverses, depending on the value of Number
of inputs.
Specified dimension
Output a vector, the composition of which depends on the value
of the Dimension parameter.
Dependencies
• Enable this parameter by selecting Element-wise(.*) for
Multiplication and setting Number of inputs to * or 1 or /.
• Setting this parameter to Specified dimension enables the
Dimension parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1314
Product
Dimension
Affect multiplication on matrix input.
Settings
Default: 1
Minimum: 1
Maximum: 2
1
Output a vector that contains an element for each column of the
input matrix.
2
Output a vector that contains an element for each row of the
input matrix.
Tips
Each element of the output vector contains the product of all elements
in the corresponding column or row of the input matrix, or the product
of the inverses of those elements, depending on the value of Number
of inputs:
• 1 or *
Multiply the values of the column or row elements
• /
Multiply the inverses of the column or row elements
Dependency
Enable this parameter by selecting Specified dimension for Multiply
over.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1315
Product
Sample time (-1 for inherited)
Enter the discrete interval between sample time hits or specify another
appropriate sample time such as continuous or inherited.
Settings
Default: -1
By default, the block inherits its sample time based upon the context of
the block within the model. To set a different sample time, enter a valid
sample time based upon the table in “Types of Sample Time”.
See also “Specify Sample Time” in the online documentation for more
information.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1316
Product
Require all inputs to have the same data type
Require that all inputs have the same data type.
Settings
Default: Off
On
Require that all inputs have the same data type.
Off
Do not require that all inputs have the same data type.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1317
Product
Lock output data type setting against changes by the
fixed-point tools
Select to lock the output data type setting of this block against changes
by the Fixed-Point Tool and the Fixed-Point Advisor.
Settings
Default: Off
On
Locks the output data type setting for this block.
Off
Allows the Fixed-Point Tool and the Fixed-Point Advisor to
change the output data type setting for this block.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Use Lock Output Data Type Setting”.
2-1318
Product
Integer rounding mode
Specify the rounding mode for fixed-point operations.
Settings
Default: Zero
Ceiling
Rounds both positive and negative numbers toward positive
infinity. Equivalent to the MATLAB ceil function.
Convergent
Rounds number to the nearest representable value. If a tie occurs,
rounds to the nearest even integer. Equivalent to the Fixed-Point
Toolbox convergent function.
Floor
Rounds both positive and negative numbers toward negative
infinity. Equivalent to the MATLAB floor function.
Nearest
Rounds number to the nearest representable value. If a tie occurs,
rounds toward positive infinity. Equivalent to the Fixed-Point
Toolbox nearest function.
Round
Rounds number to the nearest representable value. If a tie occurs,
rounds positive numbers toward positive infinity and rounds
negative numbers toward negative infinity. Equivalent to the
Fixed-Point Toolbox round function.
Simplest
Automatically chooses between round toward floor and round
toward zero to generate rounding code that is as efficient as
possible.
Zero
Rounds number toward zero. Equivalent to the MATLAB fix
function.
2-1319
Product
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Rounding”.
2-1320
Product
Saturate on integer overflow
Specify whether overflows saturate.
Settings
Default: Off
On
Overflows saturate to either the minimum or maximum value
that the data type can represent.
For example, an overflow associated with a signed 8-bit integer
can saturate to -128 or 127.
Off
Overflows wrap to the appropriate value that is representable
by the data type.
For example, the number 130 does not fit in a signed 8-bit integer
and wraps to -126.
Tips
• Consider selecting this check box when your model has possible
overflow and you want explicit saturation protection in the generated
code.
• Consider clearing this check box when you want to optimize efficiency
of your generated code.
Clearing this check box also helps you avoid overspecifying how
a block handles out-of-range signals. For more information, see
“Checking for Signal Range Errors”.
• When you select this check box, saturation applies to every internal
operation on the block, not just the output or result.
• In general, the code generation process can detect when overflow
is not possible. In this case, the code generator does not produce
saturation code.
2-1321
Product
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1322
Product
Output minimum
Specify the minimum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the minimum value for bus data on the block. Simulink ignores
this setting. Instead, set the minimum values for bus elements of the
bus object specified as the data type. For information on the Minimum
property of a bus element, see Simulink.BusElement.
Simulink uses the minimum to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1323
Product
Output maximum
Specify the maximum value that the block should output.
Settings
Default: [] (unspecified)
This number must be a finite real double scalar value.
Note If you specify a bus object as the data type for this block, do not
set the maximum value for bus data on the block. Simulink ignores this
setting. Instead, set the maximum values for bus elements of the bus
object specified as the data type. For information on the Maximum
property of a bus element, see Simulink.BusElement.
Simulink uses the maximum value to perform:
• Parameter range checking (see “Check Parameter Values”) for some
blocks
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
2-1324
Product
Output data type
Specify the output data type.
Settings
Default: Inherit:
Inherit:
Inherit via internal rule
Inherit via internal rule
Simulink chooses a combination of output scaling and data type
that requires the smallest amount of memory consistent with
accommodating the calculated output range and maintaining
the output precision of the block and with the word size of the
targeted hardware implementation specified for the model. If the
Device type parameter on the Hardware Implementation
configuration parameters pane is set to ASIC/FPGA, Simulink
software chooses the output data type without regard to hardware
constraints. Otherwise, Simulink software chooses the smallest
available hardware data type capable of meeting the range and
precision constraints. For example, if the block multiplies an
input of type int8 by a gain of int16 and ASIC/FPGA is specified
as the targeted hardware type, the output data type is sfix24.
If Unspecified (assume 32-bit Generic), i.e., a generic 32-bit
microprocessor, is specified as the target hardware, the output
data type is int32. If none of the word lengths provided by
the target microprocessor can accommodate the output range,
Simulink software displays an error message in the Simulation
Diagnostics Viewer.
Inherit:
Inherit via back propagation
Use data type of the driving block.
Inherit:
Same as first input
Use data type of the first input signal.
double
Output data type is double.
single
Output data type is single.
2-1325
Product
int8
Output data type is int8.
uint8
Output data type is uint8.
int16
Output data type is int16.
uint16
Output data type is uint16.
int32
Output data type is int32.
uint32
Output data type is uint32.
fixdt(1,16,0)
Output data type is fixed point fixdt(1,16,0).
fixdt(1,16,2^0,0)
Output data type is fixed point fixdt(1,16,2^0,0).
<data type expression>
Use a data type object, for example, Simulink.NumericType.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specify Block Output Data Types”.
2-1326
Product
Mode
Select the category of data to specify.
Settings
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit enables a
second menu/text box to the right. Select one of the following
choices:
• Inherit via internal rule (default)
• Inherit via back propagation
• Same as first input
Built in
Built-in data types. Selecting Built in enables a second
menu/text box to the right. Select one of the following choices:
• double (default)
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
Fixed point
Fixed-point data types.
Expression
Expressions that evaluate to data types. Selecting Expression
enables a second menu/text box to the right, where you can enter
the expression.
2-1327
Product
Dependency
Clicking the Show data type assistant button enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
See “Specify Data Types Using Data Type Assistant”.
2-1328
Product
Data type override
Specify data type override mode for this signal.
Settings
Default: Inherit
Inherit
Inherits the data type override setting from its context, that is,
from the block, Simulink.Signal object or Stateflow chart in
Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the
fixed-point data type specified for the signal.
Tip
The ability to turn off data type override for an individual data type
provides greater control over the data types in your model when you
apply data type override. For example, you can use this option to ensure
that data types meet the requirements of downstream blocks regardless
of the data type override setting.
Dependency
This parameter appears only when the Mode is Built in or Fixed
point.
2-1329
Product
Signedness
Specify whether you want the fixed-point data as signed or unsigned.
Settings
Default: Signed
Signed
Specify the fixed-point data as signed.
Unsigned
Specify the fixed-point data as unsigned.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1330
Product
Word length
Specify the bit size of the word that holds the quantized integer.
Settings
Default: 16
Minimum: 0
Maximum: 32
Dependencies
Selecting Mode > Fixed point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1331
Product
Scaling
Specify the method for scaling your fixed-point data to avoid overflow
conditions and minimize quantization errors.
Settings
Default: Best precision
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify best-precision values.
Dependencies
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
• Fraction length
• Calculate Best-Precision Scaling
Selecting Slope and bias enables:
• Slope
• Bias
• Calculate Best-Precision Scaling
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1332
Product
Fraction length
Specify fraction length for fixed-point data type.
Settings
Default: 0
Binary points can be positive or negative integers.
Dependencies
Selecting Scaling > Binary point enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
2-1333
Product
Slope
Specify slope for the fixed-point data type.
Settings
Default: 2^0
Specify any positive real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
Bias
Specify bias for the fixed-point data type.
Settings
Default: 0
Specify any real number.
Dependencies
Selecting Scaling > Slope and bias enables this parameter.
Command-Line Information
See “Block-Specific Parameters” on page 8-109 for the command-line
information.
See Also
For more information, see “Specifying a Fixed-Point Data Type”.
Characteristics Direct Feedthrough
2-1334
Yes
Sample Time
Specified in the Sample time
parameter
Scalar Expansion
Yes
Product
Dimensionalized
Yes
Multidimensionalized
Yes, only when the
Multiplication parameter specifies
Element-wise(.*)
Zero-Crossing Detection
See Also
No
• Divide
• Dot Product
• Product of Elements
2-1335
Product of Elements
Purpose
Copy or invert one scalar input, or collapse one nonscalar input
Library
Math Operations
Description
The Product of Elements block inputs one scalar, vector, or matrix.
You can use the block to:
• Copy a scalar input unchanged
• Invert a scalar input (divide 1 by it)
• Collapse a vector or matrix to a scalar by multiplying together all
elements or taking successive inverses of the elements
• Collapse a matrix to a vector by multiplying together the elements of
each row or column or taking successive inverses of the elements of
each row or column
The Product of Elements block is functionally a Product block that has
two preset parameter values:
• Multiplication: Element-wise(.*)
• Number of inputs: *
Setting non-default values for either of those parameters can change
a Product of Elements block to be functionally equivalent to a Product
block or a Divide block. See the documentation of those two blocks for
more information.
Algorithm
The Product of Elements block uses the following algorithms to perform
element-wise operations on inputs of floating-point, built-in integer,
and fixed-point types:
Input
Element-Wise Operation
Algorithm
Real scalar, u
Multiplication
y = u
Division
y = 1/u
2-1336
Product of Elements
Input
Element-Wise Operation
Algorithm
Real vector or matrix,
with elements u1,
Multiplication
y = u1*u2*u3*...*uN
Division
y = ((((1/u1)/u2)/u3).../uN)
Multiplication
y = u
Division
y = 1/u
Multiplication
y = u1*u2*u3*...*uN
Division
y = ((((1/u1)/u2)/u3).../uN)
u2, u3, ..., uN
Complex scalar, u
Complex vector
or matrix, with
elements u1, u2,
u3, ..., uN
If the specified dimension for element-wise multiplication or division
is a row or column of a matrix, the algorithm applies to that row or
column. For example, consider the following model:
The top Product of Elements block collapses the matrix input to a scalar
by taking successive inverses of the four elements:
• y = ((((1/2+i)/3)/4-i)/5)
2-1337
Product of Elements
The bottom Product of Elements block collapses the matrix input to a
vector by taking successive inverses along the second dimension:
• y(1) = ((1/2+i)/3)
• y(2) = ((1/4-i)/5)
2-1338
Product of Elements
Parameters
and
Dialog
Box
The Product of Elements block has the same parameters and dialog box
as the Product block, plus the parameter Multiply over, which has
the default value All dimensions:
2-1339
Product of Elements
If you set Multiply over to Specified dimension, the Dimension
parameter appears.
To copy, invert, or collapse one input to create an output, you can use
the Product of Elements block with default values for all parameters
except Number of inputs, Multiply over, and Dimension. These
values can require change. For other capabilities, see the Product block
documentation, which also describes the “Signal Attributes Pane” on
page 2-1308 of the Product of Elements block.
Number of inputs
This parameter is the same as in the Product block, but the value
must be * (the default), 1, or / to achieve the behavior of a Product
of Elements block.
Parameter
Value
Block Behavior
* or 1
• Copies a scalar input unchanged
• Collapses a vector input to a scalar by multiplying
all elements together
• Collapses a matrix input to a scalar or vector by
multiplying elements together based on the Multiply
over parameter
For more information, see “Algorithm” on page 2-1336.
/
• Outputs the arithmetic inverse of a scalar input
• Collapses a vector input to a scalar by taking
successive inverses of the elements
• Collapses a matrix input to a scalar or vector by
taking successive inverses of elements based on the
Multiply over parameter
For more information, see “Algorithm” on page 2-1336.
2-1340
Block Icon
Product of Elements
Multiply over
This parameter appears only when Multiplication is
Element-wise(.*) and Number of inputs is *, 1, or /. The
parameter affects only a matrix input. The possible values are:
• All dimensions — The block outputs a scalar that is the
product of all matrix elements, or the result of taking successive
inverses of the elements, depending on the value of Number
of inputs.
• Specified dimension — The block outputs a vector, in which
the composition depends on the value of the Dimension
parameter.
Dimension
This parameter appears only when the Multiply over parameter
appears and is set to Specified dimension. The parameter
affects only a matrix input, and must be 1 for a scalar or vector
input. The possible values are:
• 1 — Output a vector that contains an element for each column
of the input matrix.
• 2 — Output a vector that contains an element for each row of
the input matrix.
Each element of the output vector contains the product of all
elements in the corresponding column or row of the input matrix,
or the result of taking successive inverses of those elements. The
output vector depends on the value of Number of inputs:
• * or 1
Multiply the values of the column or row elements.
• /
Take successive inverses of the column or row elements. For
more information, see “Algorithm” on page 2-1336.
2-1341
Product of Elements
Examples
This table shows the output of the Product of Elements block for
example inputs using default block parameter values, except as shown
in the table.
Parameter Values
Multiplication:
Element-wise(.*)
Number of inputs: *
Multiplication:
Element-wise(.*)
Number of inputs: /
Multiplication:
Element-wise(.*)
Number of inputs: *
Multiplication:
Element-wise(.*)
Number of inputs: *
Multiply over: All
dimensions
2-1342
Examples
Product of Elements
Parameter Values
Examples
Multiplication:
Element-wise(.*)
Number of inputs: *
Multiply over:
Specified dimension
Dimension: 1
Multiplication:
Element-wise(.*)
Number of inputs: /
Multiply over:
Specified dimension
Dimension: 2
2-1343
Pulse Generator
Purpose
Generate square wave pulses at regular intervals
Library
Sources
Description
The Pulse Generator block generates square wave pulses at regular
intervals. The block’s waveform parameters, Amplitude, Pulse
Width, Period, and Phase delay, determine the shape of the output
waveform. The following diagram shows how each parameter affects
the waveform.
The Pulse Generator can emit scalar, vector, or matrix signals of any
real data type. To cause the block to emit a scalar signal, use scalars
to specify the waveform parameters. To cause the block to emit a
vector or matrix signal, use vectors or matrices, respectively, to specify
the waveform parameters. Each element of the waveform parameters
affects the corresponding element of the output signal. For example,
the first element of a vector amplitude parameter determines the
amplitude of the first element of a vector output pulse. All the waveform
parameters must have the same dimensions after scalar expansion. The
data type of the output is the same as the data type of the Amplitude
parameter.
Use the Pulse type parameter to specify whether the block’s output
is time-based or sample-based. If you select sample-based, the block
computes its outputs at fixed intervals that you specify. If you select
2-1344
Pulse Generator
time-based, Simulink software computes the block’s outputs only at
times when the output actually changes. This choice can result in fewer
computations for computing the block’s output over the simulation time
period.
Depending on the pulse’s waveform characteristics, the intervals
between changes in the block’s output can vary. For this reason, a
time-based Pulse Generator block has a variable sample time. Simulink
software uses brown as the sample time color of such blocks (see “View
Sample Time Information” for more information).
Simulink software cannot use a fixed-step solver to compute the output
of a time-based pulse generator. If you specify a fixed-step solver for
models that contain time-based pulse generators, Simulink software
computes a fixed sample time for the time-based pulse generators. Then
the time-based pulse generators simulate as sample-based.
Tip If you use a fixed-step solver and the Pulse type is time-based,
you must choose the step size such that the period, phase delay, and
pulse width (in seconds) are integer multiples of the step size. For
example, suppose that the period is 4 seconds, the pulse width is 75%
(i.e., 3 s), and the phase delay is 1 s. In this case, the computed sample
time is 1 s. Therefore, you must choose a fixed-step size that is 1 or
that divides 1 exactly (e.g., 0.25). You can guarantee this by setting
the fixed-step solver’s step size to auto on the Solver pane of the
Configuration Parameters dialog box.
If you select time-based as the block’s pulse type, you must specify
the pulse’s phase delay and period in units of seconds. If you specify
sample-based, you must specify the block’s sample time in seconds,
using the Sample time parameter, then specify the block’s phase
delay and period as integer multiples of the sample time. For example,
suppose that you specify a sample time of 0.5 second and want the pulse
to repeat every two seconds. In this case, you would specify 4 as the
value of the block’s Period parameter.
2-1345
Pulse Generator
Data Type
Support
The Pulse Generator block outputs real signals of any numeric data type
that Simulink supports, including fixed-point data types. The data type
of the output signal is the same as that of the Amplitude parameter.
For more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
2-1346
Pulse Generator
Parameters
and
Dialog
Box
Pulse type
The pulse type for this block: time-based or sample-based. The
default is time-based.
2-1347
Pulse Generator
• If you select Use simulation time, the block generates an
output pulse where the time variable equals the simulation
time.
• If you select Use external signal, the block generates an
output pulse where the time variable equals the value from the
input port, which can differ from the simulation time.
Amplitude
The pulse amplitude. The default is 1.
Period
The pulse period specified in seconds if the pulse type is
time-based or as number of sample times if the pulse type is
sample-based. The default is 10 seconds.
Pulse Width
The duty cycle specified as the percentage of the pulse period
that the signal is on if time-based or as number of sample times
if sample-based. The default is 5 percent.
Phase delay
The delay before the pulse is generated specified in seconds if the
pulse type is time-based or as number of sample times if the pulse
type is sample-based. The default is 0 seconds.
Sample time
The length of the sample time for this block in seconds. This
parameter appears only if the block’s pulse type is sample-based.
See “Specify Sample Time” in the Simulink User’s Guide for more
information.
Interpret vector parameters as 1-D
If you select this check box and the other parameters are one-row
or one-column matrices, after scalar expansion, the block outputs
a 1-D signal (vector). Otherwise the output dimensionality is
the same as that of the other parameters. See “Determining
the Output Dimensions of Source Blocks” in the “Working with
Signals” chapter of the Simulink User’s Guide.
2-1348
Pulse Generator
Examples
The following Simulink examples show how to use the Pulse Generator
block:
• sldemo_auto_climatecontrol
• sldemo_boiler
Characteristics Sample Time
Inherited
Scalar Expansion
Yes, of parameters
Dimensionalized
Yes
Zero-Crossing Detection
No
2-1349
Quantizer
Purpose
Discretize input at specified interval
Library
Discontinuities
Description
The Quantizer block passes its input signal through a stair-step function
so that many neighboring points on the input axis are mapped to one
point on the output axis. The effect is to quantize a smooth signal into a
stair-step output. The output is computed using the round-to-nearest
method, which produces an output that is symmetric about zero.
y = q * round(u/q)
where y is the output, u the input, and q the Quantization interval
parameter.
Data Type
Support
2-1350
The Quantizer block accepts and outputs real or complex signals of type
single or double. For more information, see “Data Types Supported
by Simulink” in the Simulink documentation.
Quantizer
Parameters
and
Dialog
Box
Quantization interval
The interval around which the output is quantized. Permissible
output values for the Quantizer block are n*q, where n is an
integer and q the Quantization interval. The default is 0.5.
Treat as gain when linearizing
Simulink software by default treats the Quantizer block as unity
gain when linearizing. This setting corresponds to the large-signal
linearization case. If you clear this check box, the linearization
routines assume the small-signal case and set the gain to zero.
Sample time (-1 for inherited)
Specify the sample time of this Outport block. See “Specify
Sample Time” in the online documentation for information on
specifying sample times. The output of this block changes at the
specified rate to reflect the value of its input.
2-1351
Quantizer
Examples
The sldemo_boiler model shows how you can use the Quantizer block.
The Quantizer block appears in the Boiler Plant model/digital
thermometer/ADC subsystem.
The ADC subsystem digitizes the input analog voltage by:
• Multiplying the analog voltage by 256/5 with the Gain block
• Rounding the value to integer floor with the Quantizer block
• Limiting the output to a maximum of 255 (the largest unsigned 8-bit
integer value) with the Saturation block
For more information, see “Exploring the Fixed-Point "Bang-Bang
Control" Model” in the Stateflow documentation.
Characteristics Direct Feedthrough
2-1352
Yes
Sample Time
Inherited from driving block
Scalar Expansion
Yes, of parameter
Dimensionalized
Yes
Zero-Crossing Detection
No
Ramp
Purpose
Generate constantly increasing or decreasing signal
Library
Sources
Description
The Ramp block generates a signal that starts at a specified time
and value and changes by a specified rate. The block’s Slope, Start
time, and Initial output parameters determine the characteristics
of the output signal. All must have the same dimensions after scalar
expansion.
Data Type
Support
The Ramp block outputs signals of type double. For more
information, see “Data Types Supported by Simulink” in the Simulink
documentation.
2-1353
Ramp
Parameters
and
Dialog
Box
Slope
Specify the rate of change of the generated signal. The default is 1.
Start time
Specify the time at which the block begins generating the signal.
The default is 0.
Initial output
Specify the initial value of the output signal. The default is 0.
Interpret vector parameters as 1-D
If you select this option and the other parameters are one-row or
one-column matrices, after scalar expansion, the block outputs
a 1-D signal (vector). Otherwise, the output dimensionality is
2-1354
Ramp
the same as that of the other parameters. See “Determining
the Output Dimensions of Source Blocks” in the Simulink
documentation.
Examples
The following Simulink examples show how to use the Ramp block:
• sldemo_VariableTransportDelay_pipe
Characteristics Sample Time
Inherited from driven block
Scalar Expansion
Yes
Dimensionalized
Yes
Zero-Crossing Detection
Yes
2-1355
Random Number
Purpose
Generate normally distributed random numbers
Library
Sources
Description
The Random Number block generates normally distributed random
numbers. To generate uniformly distributed random numbers, use the
Uniform Random Number block.
You can generate a repeatable sequence using any Random Number
block with the same nonnegative seed and parameters. The seed resets
to the specified value each time a simulation starts. By default, the
block produces a sequence that has a mean of 0 and a variance of 1. To
generate a vector of random numbers with the same mean and variance,
specify the Seed parameter as a vector.
Avoid integrating a random signal, because solvers must integrate
relatively smooth signals. Instead, use the Band-Limited White Noise
block.
The numeric parameters of this block must have the same dimensions
after scalar expansion. If you select the Interpret vector parameters
as 1-D check box and the numeric parameters are row or column vectors
after scalar expansion, the block outputs a 1-D signal. If you clear the
Interpret vector parameters as 1-D check box, the block outputs a
signal of the same dimensionality as the parameters.
Data Type
Support
2-1356
The Random Number block outputs a real signal of type double. For
more information, see “Data Types Supported by Simulink” in the
Simulink documentation.
Random Number
Parameters
and
Dialog
Box
Mean
Specify the mean of the random numbers. The default is 0.
Variance
Specify the variance of the random numbers. The default is 1.
Seed
Specify the starting seed for the random number generator. The
default is 0.
2-1357
Random Number
The seed must be 0 or a positive integer. Output is repeatable for
a given seed.
Sample time
Specify the time interval between samples. The default is 0.1,
which matches the default sample time of the Band-Limited
White Noise block. See “Specify Sample Time” in the Simulink
documentation for more information.
Interpret vector parameters as 1-D
If you select this check box and the other parameters are row
or column vectors after scalar expansion, the block outputs a
1-D signal. Otherwise, the block outputs a signal of the same
dimensionality as the other parameters. For more information,
see “Determining the Output Dimensions of Source Blocks” in
the Simulink documentation.
Characteristics Sample Time
See Also
2-1358
Specified in the Sample time
parameter
Scalar Expansion
Yes, of parameters
Dimensionalized
Yes
Multidimensionalized
Yes
Zero-Crossing Detection
No
Uniform Random Number
Rate Limiter
Purpose
Limit rate of change of signal
Library
Discontinuities
Description
The Rate Limiter block limits the first derivative of the signal passing
through it. The output changes no faster than the specified limit. The
derivative is calculated using this equation:‘
rate =
u(i) − y(i − 1)
t(i) − t(i − 1)
u(i) and t(i) are the current block input and time, and y(i–1) and t(i–1)
are the output and time at the previous step. The output is determined
by comparing rate to the Rising slew rate and Falling slew rate
parameters:
• If rate is greater than the Rising slew rate parameter (R), the
output is calculated as
y(i) = Δt ⋅ R + y(i − 1).
• If rate is less than the Falling slew rate parameter (F), the output
is calculated as
y(i) = Δt ⋅ F + y(i − 1).
• If rate is between the bounds of R and F, the change in output is
equal to the change in input:
y(i) = u(i)
When the block is running in continuous mode (for example, Sample
time mode is inherited and Sample time of the driving block is
zero), the Initial condition is ignored. The block output at t = 0 is
equal to the initial input:
2-1359
Rate Limiter
y(0) = u(0)
When the block is running in discrete mode (for example, Sample time
mode