0% found this document useful (0 votes)
17 views

simulink_mab_guidelines

The document outlines the MathWorks Advisory Board Control Algorithm Modeling Guidelines for Simulink, detailing the purpose, naming conventions, and various modeling considerations. It includes sections on Model Advisor checks, configuration parameters, and usage patterns, along with contact information for MathWorks. The guidelines are intended to assist users in adhering to best practices in modeling with Simulink and Stateflow.

Uploaded by

林子筠
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

simulink_mab_guidelines

The document outlines the MathWorks Advisory Board Control Algorithm Modeling Guidelines for Simulink, detailing the purpose, naming conventions, and various modeling considerations. It includes sections on Model Advisor checks, configuration parameters, and usage patterns, along with contact information for MathWorks. The guidelines are intended to assist users in adhering to best practices in modeling with Simulink and Stateflow.

Uploaded by

林子筠
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 620

Simulink®

MathWorks® Advisory Board Control Algorithm


Modeling Guidelines

R2024b
How to Contact MathWorks

Latest news: www.mathworks.com

Sales and services: www.mathworks.com/sales_and_services

User community: www.mathworks.com/matlabcentral

Technical support: www.mathworks.com/support/contact_us

Phone: 508-647-7000

The MathWorks, Inc.


1 Apple Hill Drive
Natick, MA 01760-2098
MathWorks® Advisory Board Modeling Guidelines
© COPYRIGHT 2007–2024 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
March 2009 Online only New for Version 2.0 (Release 2009a)
September 2009 Online only Revised for Version 2.1 (Release 2009b)
March 2010 Online only Rereleased for Version 2.1 (Release 2010a)
September 2010 Online only Rereleased for Version 2.1 (Release 2010b)
April 2011 Online only Rereleased for Version 2.1 (Release 2011a)
September 2011 Online only Rereleased for Version 2.1 (Release 2011b)
March 2012 Online only Rereleased for Version 2.2 (Release 2012a)
September 2012 Online only Rereleased for Version 2.2 (Release 2012b)
March 2013 Online only Revised for Version 3.0 (Release 2013a)
September 2013 Online only Rereleased for Version 3.0 (Release 2013b)
March 2014 Online only Revised for Version 3.1 (Release 2014a)
October 2014 Online only Rereleased for Version 3.1 (Release 2014b)
March 2015 Online only Rereleased for Version 3.1 (Release 2015a)
September 2015 Online only Rereleased for Version 3.1 (Release 2015b)
March 2016 Online only Rereleased for Version 3.1 (Release 2016a)
September 2016 Online only Rereleased for Version 3.1 (Release 2016b)
March 2017 Online only Rereleased for Version 3.1 (Release 2017a)
September 2017 Online only Rereleased for Version 3.1 (Release 2017b)
March 2018 Online only Rereleased for Version 3.1 (Release 2018a)
September 2018 Online only Rereleased for Version 3.1 (Release 2018b)
March 2019 Online only Rereleased for Version 3.1 (Release 2019a)
September 2019 Online only Rereleased for Version 3.2 (Release 2019b)
March 2020 Online only MAAB guidelines revised and reintroduced as the
MathWorks Advisory Board (MAB) Modeling
Guidelines, Version 5.0 (Release 2020a)
September 2020 Online only Rereleased for Version 5.0 (Release 2020b)
March 2021 Online only Rereleased for Version 5.0 (Release 2021a)
September 2021 Online only Rereleased for Version 5.0 (Release 2021b)
March 2022 Online only Revised for Version 5.0 (Release 2022a)
September 2022 Online only Revised for Version 5.0 (Release 2022b)
March 2023 Online only Revised for Version 5.0 (Release 2023a)
September 2023 Online only Revised for Version 23.2 (R2023b)
March 2024 Online only Revised for Version 24.1 (R2024a)
September 2024 Online only Revised for Version 24.2 (R2024b)
Contents

Introduction
1
Purpose of the Guidelines and Template . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

Model Advisor Checks for MAB Modeling Guidelines . . . . . . . . . . . . . . . . 1-6

Model Advisor Checks for JMAAB Modeling Guidelines . . . . . . . . . . . . . 1-17


See Also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32

Naming Conventions
2
General Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2

Content Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11

Simulink
3
Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2

Diagram Appearance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12

Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68

Conditional Subsystem Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-103

Operation Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-125

Other Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-174

Stateflow
4
Stateflow Blocks / Data / Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2

v
Stateflow Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29

Conditional Transition / Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-82

Label Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-149

Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-176

MATLAB
5
MATLAB Appearance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

MATLAB Data and Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7

MATLAB Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15

Considerations
6
Considerations for Determining Guideline Operation Rules . . . . . . . . . . . 6-2
Process Definition and Development Environment . . . . . . . . . . . . . . . . . . 6-2
MATLAB and Simulink Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
MATLAB and Simulink Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Usable Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
Using Optimization and Configuration Parameters . . . . . . . . . . . . . . . . . . 6-3

Considerations for Applying Guidelines to a Project . . . . . . . . . . . . . . . . . 6-5


Using the Model Analysis Process When Applying Guidelines . . . . . . . . . . 6-5
Adoption of the Guideline Rule and Process Settings . . . . . . . . . . . . . . . . . 6-5
Setting the Guideline Rule Application Field and the Clarifying the
Exclusion Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
Parameter Recommendations in the Guidelines . . . . . . . . . . . . . . . . . . . . . 6-6
Verifying Adherence to the Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
Modifying Adherence to the Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6

Using Simulink and Stateflow


A
Understanding Model Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2
Hierarchical Structure of a Controller Model . . . . . . . . . . . . . . . . . . . . . . A-2
Relationship Between Simulink Models and Embedded Implementation
...................................................... A-9

Using Simulink and Stateflow in Modeling . . . . . . . . . . . . . . . . . . . . . . . . A-16


Simulink Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-17

vi Contents
Stateflow Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-24
Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-31

Modeling Knowledge
B
Usage Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2
Simulink Patterns for If, elseif, else Constructs . . . . . . . . . . . . . . . . . . . . . B-2
Simulink Patterns for case Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2
Simulink Patterns for Logical Constructs . . . . . . . . . . . . . . . . . . . . . . . . . B-3
Simulink Patterns for Vector Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-4
Using Switch and If, Elseif, Else Action Subsystems . . . . . . . . . . . . . . . . . B-6
Use of If, Elseif, Else Action Subsystem to Replace Multiple Switches . . . . B-8
Usage Rules for Action Subsystems Using Conditional Control Flow . . . . B-12
Test for Information From Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-16
Flow Chart Patterns for Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-17
Flow Chart Patterns for Condition Actions . . . . . . . . . . . . . . . . . . . . . . . B-18
Flow Chart Patterns for If, Elseif, Else Constructs . . . . . . . . . . . . . . . . . B-19
Flow Chart Patterns for Case Constructs . . . . . . . . . . . . . . . . . . . . . . . . B-20
Flow Chart Patterns for Loop Constructs . . . . . . . . . . . . . . . . . . . . . . . . B-21
State Machine Patterns for Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . B-22
State Machine Patterns for Transition Actions . . . . . . . . . . . . . . . . . . . . B-22
jc_0321Limiting State Layering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-23
Number of States per Stateflow Container . . . . . . . . . . . . . . . . . . . . . . . B-24
Function Call from Stateflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-24
Function Types Available in Stateflow . . . . . . . . . . . . . . . . . . . . . . . . . . B-24

Glossary
C

vii
1

Introduction

• “Purpose of the Guidelines and Template” on page 1-2


• “Model Advisor Checks for MAB Modeling Guidelines” on page 1-6
• “Model Advisor Checks for JMAAB Modeling Guidelines” on page 1-17
1 Introduction

Purpose of the Guidelines and Template


MathWorks Advisory Board (MAB) guidelines stipulate important basic rules for modeling in Simulink
and Stateflow. The overall purpose of these modeling guidelines is to allow for a simple, common
understanding by modelers and consumers of control system models.

The main objectives of these guidelines are:

• Readability

• Improve graphical understandability


• Improve readability of functional analysis
• Prevent connection mistakes
• Comments, etc.
• Simulation and verification

• Mechanism to enable simulation


• Testability
• Code Generation

• Improve the efficiency of code generation (ROM, RAM efficiency)


• Ensure the robustness of generated code

Note Model runtime errors and recommendations that cannot be implemented are outside of the
scope of these rules.

Guidelines are documented by using a standard template. Use of this template is recommended when
creating original guidelines.

Note This template specifies the minimum requirements that are needed to understand a guideline.
New items can be added to the template as long as they do not duplicate existing information.

Section Heading Format Section Description


Rule ID: Title XX_nnnn: Title of the guideline A rule ID, which is used to
(unique, short) identify the guideline, consists
of two lower case letters and a
four-digit number. The letter
and number combination is
separated by an underscore. For
example, xx_nnnn.A rule ID is
permanent and will not change.

Note The two-letters in the rule


ID identify the guideline author.

1-2
Purpose of the Guidelines and Template

Section Heading Format Section Description


Sub ID Recommendations NA-MAAB: x, y, z Specifies guideline sub IDs that
are recommended for use by the
JMAAB: x, y, z NA-MAAB (North American
MathWorks Automotive Advisory
Board) and JMAAB (Japan
MathWorks Automotive Advisory
Board) modeling standards
organizations. Each
organization is a region-specific
consortium of automotive OEMs
and suppliers; NA-MAAB
represents North America and
Europe. JMAAB represents
Japan.
MATLAB Versions All MAB guidelines support all
RX, RY, RZ versions of MATLAB and
RX and earlier Simulink products. When a rule
RX and later applies only to a specific
RX through RY version(s), the version is
identified in the MATLAB
Version field by using one of
these formats:

• All — All versions of MATLAB


• RX, RY, RZ — A specific
version of MATLAB
• RX and earlier — Versions of
MATLAB until version RX
• RX and later — Versions of
MATLAB from version RX to
the current version
• RX through RY — Versions of
MATLAB between RX and RY

1-3
1 Introduction

Section Heading Format Section Description


Rule > Sub ID Specifies the condition(s) of the Specifies the condition(s) of the
rule by using Sub IDs. There rule. Sub IDs are designated as
can be multiple sub IDs per rule either:
ID.
• Selectable ― Consist of one
The subsections for a Sub ID lower-case letter
include: (alphabetical order). The
choice of whether to adopt a
• Custom Parameter selectable sub ID is left to
• (Optional) Exclusion the user.
• (Optional) Example • Mutually Exclusive ―
Consist of one lower case
letter (alphabetical order)
and a single-digit number.
When choosing to accept or
reject a mutually exclusive
sub ID, only one option can
be selected.

For example, Sub IDs for


guideline xy_0000 are:

• xy_0000a ― Represents a
selectable (user’s choice)
option
• xy_0000b1

xy_0000b2

― Mutually Exclusive (if


using, choose from
xy_0000b1 or xy_0000b2)

For rules that include custom


parameters, the chosen value is
specific for the project with
regard to the item being
described. Example of objects
and values are provided in the
description field. However, a
project’s processes, condition of
the control target, and skill
levels of the engineers should
be comprehensively evaluated
when specifying a custom
parameter.

1-4
Purpose of the Guidelines and Template

Section Heading Format Section Description


Rationale Motivation for the Sub IDs Provides reasoning for the use
of the guideline with regard to
readability, verification
efficiency, efficiency of code
after code generation, etc.
Verification Verification methods Method(s) that verify
compliance of the model with
guideline conditions, such as:

• Model Advisor check


• Manual verification method
Last Change R<year> MATLAB revision in which the
content of the guideline was last
updated. For example, R2020a.
See Also References Additional information that can
be helpful to better understand
the guideline.

1-5
1 Introduction

Model Advisor Checks for MAB Modeling Guidelines


This table identifies the Model Advisor checks that you can use to verify compliance of your model
with MathWorks Advisor Board (MAB) modeling guidelines.

In the Model Advisor, to access the MAB checks, select:

• By Product > Simulink Check > Modeling Standards > MAB Checks
• By Task > Modeling Standards for MAB

You need Simulink Check™ to execute these checks.

Note Some guidelines do not have corresponding Model Advisor checks:

• No check — Indicates that the guideline can be checked by using a Model Advisor check, however,
the check does not currently exist.
• Not checkable — Indicates that it is not possible to verify compliance to this guideline by using a
Model Advisor check.

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
ar_0001: Usable characters for “Check file names” (Simulink mathworks.jmaab.ar_0001
file names Check)
ar_0002: Usable characters for “Check folder names” (Simulink mathworks.jmaab_v6.ar_00
folder names Check) 02
db_0032: Signal line “Check signal line connections” mathworks.jmaab_v6.db_00
connections (Simulink Check) 32
db_0042: Usage of Inport and “Check position of Inport and mathworks.jmaab.db_0042
Outport blocks Outport blocks” (Simulink
Check)
db_0043: Model font and font “Check model font settings” mathworks.jmaab.db_0043
size (Simulink Check)
db_0081: Unconnected signals “Check for unconnected signal mathworks.jmaab.db_0081
and blocks lines and blocks” (Simulink
Check)
db_0097: Position of labels for “Check position of signal labels” mathworks.jmaab_v6.db_00
signals and buses (Simulink Check) 97
db_0110: Block parameters “Check usage of tunable mathworks.maab.db_0110
parameters in blocks” (Simulink
Check)
db_0112: Usage of index “Check Indexing Mode” mathworks.jmaab.db_0112
(Simulink Check)

1-6
Model Advisor Checks for MAB Modeling Guidelines

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
db_0123: Stateflow port names “Check for names of Stateflow mathworks.maab.db_0123
ports and associated signals”
(Simulink Check)
db_0125: Stateflow local data “Check definition of Stateflow mathworks.jmaab_v6.db_01
data” (Simulink Check) 25
db_0126: Defining Stateflow “Check definition of Stateflow mathworks.jmaab.db_0126
events events” (Simulink Check)
db_0127: Limitation on MATLAB “Check for MATLAB expressions mathworks.jmaab_v6.db_01
commands in Stateflow blocks in Stateflow charts” (Simulink 27
Check)
db_0129: Stateflow transition “Check for Stateflow transition mathworks.jmaab_v6.db_01
appearance appearance” (Simulink Check) 29
db_0132: Transitions in flow “Check transitions in Stateflow mathworks.jmaab.db_0132
charts Flow charts” (Simulink Check)
db_0137: States in state “Check for state in state mathworks.jmaab.db_0137
machines machines” (Simulink Check)
db_0140: Display of block “Check for display of block mathworks.maab.db_0140
parameters parameter” (Simulink Check)
db_0141: Signal flow in “Check signal flow in model” mathworks.maab.db_0141
Simulink models (Simulink Check)
db_0142: Position of block “Check whether block names mathworks.maab.db_0142
names appear below blocks” (Simulink
Check)
db_0143: Usable block types in “Check for mixing basic blocks mathworks.maab.db_0143
model hierarchy and subsystems” (Simulink
Check)
db_0144: Use of subsystems Not checkable
db_0146: Block layout in “Check position of conditional mathworks.jmaab.db_0146
conditional subsystems blocks and iterator blocks”
(Simulink Check)
hd_0001: Prohibited Simulink “Check for prohibited sink mathworks.maab.hd_0001
sinks blocks” (Simulink Check)
jc_0008: Definition of signal “Check definition of signal mathworks.jmaab.jc_0008
names labels” (Simulink Check)
jc_0009: Signal name “Check signal name mathworks.jmaab_v6.jc_00
propagation propagation” (Simulink Check) 09
jc_0011: Optimization “Check Implement logic signals mathworks.maab.jc_0011
parameters for Boolean data as Boolean data (vs. double)”
types (Simulink Check)
jc_0021: Model diagnostic “Check model diagnostic mathworks.maab.jc_0021
settings parameters” (Simulink Check)

1-7
1 Introduction

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
jc_0061: Display of block names “Check the display attributes of mathworks.maab.jc_0061
block names” (Simulink Check)
jc_0081: Inport and Outport “Check display for port blocks” mathworks.maab.jc_0081
block icon display (Simulink Check)
jc_0110: Direction of block “Check block orientation” mathworks.jmaab.jc_0110
(Simulink Check)
jc_0121: Usage of add and “Check usage of Sum blocks” mathworks.jmaab.jc_0121
subtraction blocks (Simulink Check)
jc_0131: Usage of Relational “Check usage of Relational mathworks.maab.jc_0131
Operator blocks Operator blocks” (Simulink
Check)
jc_0141: Usage of the Switch “Check usage of Switch blocks” mathworks.maab.jc_0141
blocks (Simulink Check)
jc_0161: Definition of Data Store “Check for usage of Data Store mathworks.jmaab.jc_0161
Memory blocks Memory blocks” (Simulink
Check)
jc_0171: Clarification of “Check connections between mathworks.jmaab.jc_0171
connections between structural structural subsystems”
subsystems (Simulink Check)
jc_0201: Usable characters for “Check subsystem names” mathworks.jmaab.jc_0201
subsystem names (Simulink Check)
jc_0211: Usable characters for “Check port block names” mathworks.jmaab.jc_0211
Inport blocks and Outport block (Simulink Check)
jc_0222: Usable characters for “Check usable characters for mathworks.jmaab.jc_0222
signal and bus names signal names and bus names”
(Simulink Check)
jc_0231: Usable characters for “Check character usage in block mathworks.jmaab.jc_0231
block names names” (Simulink Check)
jc_0232: Usable characters for “Check usable characters for mathworks.jmaab_v6.jc_02
parameter names parameter names” (Simulink 32
Check)
jc_0241: Length restriction for “Check length of model file mathworks.jmaab.jc_0241
model file names name” (Simulink Check)
jc_0242: Length restriction for “Check length of folder name at mathworks.jmaab.jc_0242
folder names every level of model path”
(Simulink Check)
jc_0243: Length restriction for “Check length of subsystem mathworks.jmaab.jc_0243
subsystem names names” (Simulink Check)
jc_0244: Length restriction for “Check length of Inport and mathworks.jmaab.jc_0244
Inport and Outport names Outport names” (Simulink
Check)

1-8
Model Advisor Checks for MAB Modeling Guidelines

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
jc_0245: Length restriction for “Check length of signal and bus mathworks.jmaab.jc_0245
signal and bus names names” (Simulink Check)
jc_0246: Length restriction for “Check length of parameter mathworks.jmaab.jc_0246
parameter name names” (Simulink Check)
jc_0247: Length restriction for “Check length of block names” mathworks.jmaab.jc_0247
block names (Simulink Check)
jc_0281: Trigger signal names “Check trigger signal names” mathworks.jmaab.jc_0281
(Simulink Check)
jc_0451: Use of unary minus on “Check usage of unary minus mathworks.jmaab.jc_0451
unsigned integers operations in Stateflow charts”
(Simulink Check)
jc_0481: Use of hard equality “Check usage of floating-point mathworks.jmaab_v6.jc_04
comparisons for floating point expressions in Stateflow charts” 81
numbers in Stateflow (Simulink Check)
jc_0491: Reuse of Stateflow data Not checkable
jc_0501: Format of entries in a “Check entry formatting in mathworks.jmaab.jc_0501
State block State blocks in Stateflow charts”
(Simulink Check)
jc_0511: Return values from a “Check return value mathworks.maab.jc_0511
graphical function assignments in Stateflow
graphical functions” (Simulink
Check)
jc_0531: Default transition “Check default transition mathworks.jmaab.jc_0531
placement in Stateflow charts”
(Simulink Check)
jc_0602: Consistency in model “Check for consistency in model mathworks.jmaab.jc_0602
element names element names” (Simulink
Check)
jc_0603: Model description “Check Model Description” mathworks.jmaab.jc_0603
(Simulink Check)
jc_0604: Using block shadow “Check if blocks are shaded in mathworks.jmaab.jc_0604
the model” (Simulink Check)
jc_0610: Operator order for “Check operator order of mathworks.jmaab.jc_0610
multiplication and division block Product blocks” (Simulink
Check)
jc_0611: Input sign for “Check signs of input signals in mathworks.jmaab.jc_0611
multiplication and division product blocks” (Simulink
blocks Check)
jc_0621: Usage of Logical “Check icon shape of Logical mathworks.jmaab.jc_0621
Operator blocks Operator blocks” (Simulink
Check)

1-9
1 Introduction

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
jc_0622: Usage of Fcn blocks “Check for parentheses in Fcn mathworks.jmaab.jc_0622
block expressions” (Simulink
Check)
jc_0623: Usage of continuous- “Check usage of Memory and mathworks.jmaab.jc_0623
time Delay blocks and discrete- Unit Delay blocks” (Simulink
time Delay blocks Check)
jc_0624: Usage of Tapped Delay “Check for cascaded Unit Delay mathworks.jmaab.jc_0624
blocks/Delay blocks blocks” (Simulink Check)
jc_0626: Usage of Lookup Table “Check usage of Lookup Tables” mathworks.jmaab.jc_0626
blocks (Simulink Check)
jc_0627: Usage of Discrete-Time “Check usage of Discrete-Time mathworks.jmaab_v6.jc_06
Integrator blocks Integrator block” (Simulink 27
Check)
jc_0628: Usage of Saturation “Check usage of the Saturation mathworks.jmaab.jc_0628
blocks blocks” (Simulink Check)
jc_0630: Usage of Multiport “Check settings for data ports in mathworks.jmaab_v6.jc_06
Switch blocks Multiport Switch blocks” 30
(Simulink Check)
jc_0640: Initial value settings “Check undefined initial output mathworks.jmaab.jc_0640
for Outport blocks in conditional for conditional subsystems”
subsystems (Simulink Check)
jc_0641: Sample time setting “Check for sample time setting” mathworks.jmaab.jc_0641
(Simulink Check)
jc_0642: Integer rounding mode “Check Signed Integer Division mathworks.jmaab.jc_0642
setting Rounding mode” (Simulink
Check)
jc_0643: Fixed-point setting “Check usage of fixed-point data mathworks.jmaab.jc_0643
type with non-zero bias”
(Simulink Check)
jc_0644: Type setting “Check type setting by data mathworks.jmaab_v6.jc_06
objects” (Simulink Check) 44
jc_0645: Parameter definition “Check if tunable block mathworks.jmaab.jc_0645
for calibration parameters are defined as
named constants” (Simulink
Check)
jc_0650: Block input/output data “Check input and output mathworks.jmaab.jc_0650
type with switching function datatype for Switch blocks”
(Simulink Check)
jc_0651: Implementing a type “Check Output data type of mathworks.jmaab_v6.jc_06
conversion operation blocks” (Simulink 51
Check)

1-10
Model Advisor Checks for MAB Modeling Guidelines

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
jc_0653: Delay block layout in “Check for avoiding algebraic mathworks.jmaab.jc_0653
feedback loops loops between subsystems”
(Simulink Check)
jc_0655: Prohibition of logical “Check prohibited comparison mathworks.jmaab.jc_0655
value comparison in Stateflow operation of logical type
signals” (Simulink Check)
jc_0656: Usage of Conditional “Check default/else case in mathworks.jmaab.jc_0656
Control blocks Switch Case blocks and If
blocks” (Simulink Check)
jc_0657: Retention of output Not checkable
value based on conditional
control flow blocks and Merge
blocks
jc_0659: Usage restrictions of “Check usage of Merge block” mathworks.jmaab.jc_0659
signal lines input to Merge (Simulink Check)
blocks
jc_0700: Unused data in “Check for unused data in mathworks.jmaab.jc_0700
Stateflow block Stateflow Charts” (Simulink
Check)
jc_0701: Usable number for first “Check usable number for first mathworks.jmaab.jc_0701
index index” (Simulink Check)
jc_0702: Use of named Stateflow “Check usage of numeric literals mathworks.jmaab.jc_0702
parameters and constants in Stateflow” (Simulink Check)
jc_0711: Division in Stateflow Not checkable
jc_0712: Execution timing for “Check execution timing for mathworks.jmaab.jc_0712
default transition path default transition path”
(Simulink Check)
jc_0721: Usage of parallel states “Check usage of parallel states” mathworks.jmaab.jc_0721
(Simulink Check)
jc_0722: Local data definition in “Check scope of data in parallel mathworks.jmaab.jc_0722
parallel states states” (Simulink Check)
jc_0723: Prohibited direct “Check usage of transitions to mathworks.jmaab.jc_0723
transition from external state to external states” (Simulink
child state Check)
jc_0730: Unique state name in “Check uniqueness of State mathworks.jmaab.jc_0730
Stateflow blocks names” (Simulink Check)
jc_0731: State name format “Check usage of State names” mathworks.jmaab.jc_0731
(Simulink Check)
jc_0732: Distinction between “Check uniqueness of Stateflow mathworks.jmaab.jc_0732
state names, data names, and state, data and event names”
event names (Simulink Check)

1-11
1 Introduction

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
jc_0733: Order of state action “Check order of state action mathworks.jmaab.jc_0733
types types” (Simulink Check)
jc_0734: Number of state action “Check repetition of action mathworks.jmaab.jc_0734
types types” (Simulink Check)
jc_0736: Uniform indentations “Check indentation of code in mathworks.jmaab.jc_0736
in Stateflow blocks Stateflow states” (Simulink
Check)
jc_0738: Usage of Stateflow “Check usage of Stateflow mathworks.jmaab.jc_0738
comments comments” (Simulink Check)
jc_0740: Limitation on use of “Check if state action type 'exit' mathworks.jmaab.jc_0740
exit state action is used in the model” (Simulink
Check)
jc_0741: Timing to update data “Check updates to variables mathworks.jmaab_v6.jc_07
used in state chart transition used in state transition 41
conditions conditions” (Simulink Check)
jc_0751: Backtracking “Check for unexpected mathworks.jmaab.jc_0751
prevention in state transition backtracking in state
transitions” (Simulink Check)
jc_0752: Condition action in “Check usage of parentheses in mathworks.jmaab.jc_0752
transition label Stateflow transitions” (Simulink
Check)
jc_0753: Condition actions and “Check condition actions and mathworks.jmaab_v6.jc_07
transition actions in Stateflow transition actions in Stateflow” 53
(Simulink Check)
jc_0760: Starting point of “Check starting point of internal mathworks.jmaab.jc_0760
internal transition transition in Stateflow”
(Simulink Check)
jc_0762: Prohibition of state “Check prohibited combination mathworks.jmaab.jc_0762
action and flow chart of state action and flow chart”
combination (Simulink Check)
jc_0763: Usage of multiple “Check usage of internal mathworks.jmaab.jc_0763
internal transitions transitions in Stateflow states”
(Simulink Check)
jc_0770: Position of transition “Check placement of Label mathworks.jmaab_v6.jc_07
label String in Transitions” (Simulink 70
Check)
jc_0771: Comment position in “Check position of comments in mathworks.jmaab.jc_0771
transition labels transition labels” (Simulink
Check)
jc_0772: Execution order and “Check usage of transition mathworks.jmaab.jc_0772
transition conditions of conditions in Stateflow
transition lines transitions” (Simulink Check)

1-12
Model Advisor Checks for MAB Modeling Guidelines

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
jc_0773: Unconditional “Check usage of unconditional mathworks.jmaab.jc_0773
transition of a flow chart transitions in flow charts”
(Simulink Check)
jc_0774: Comments for through “Check for comments in mathworks.jmaab.jc_0774
transition unconditional transitions”
(Simulink Check)
jc_0775: Terminating junctions “Check terminal junctions in mathworks.jmaab.jc_0775
in flow charts Stateflow” (Simulink Check)
jc_0790: Action language of “Check Stateflow chart action mathworks.jmaab.jc_0790
Chart block language” (Simulink Check)
jc_0791: Duplicate data name “Check duplication of Simulink mathworks.jmaab.jc_0791
definitions data names” (Simulink Check)
jc_0792: Unused Data “Check unused data in Simulink mathworks.jmaab.jc_0792
Model” (Simulink Check)
jc_0794: Division in Simulink “Check for division by zero in mathworks.jmaab.jc_0794
Simulink” (Simulink Check)
jc_0795: Usable characters for “Check usable characters for mathworks.jmaab.jc_0795
Stateflow data names Stateflow data names”
(Simulink Check)
jc_0796: Length restriction for “Check length of Stateflow data mathworks.jmaab.jc_0796
Stateflow data names name” (Simulink Check)
jc_0797: Unconnected “Check for unconnected objects mathworks.jmaab.jc_0797
transitions / states / connective in Stateflow Charts” (Simulink
junctions Check)
jc_0800: Comparing floating- “Check comparison of floating mathworks.jmaab.jc_0800
point types in Simulink point types in Simulink”
(Simulink Check)
jc_0801: Prohibited use of the /* “Check for use of C-style mathworks.jmaab.jc_0801
and */ comment symbols comment symbols” (Simulink
Check)
jc_0802: Prohibited use of “Check for implicit type casting mathworks.jmaab.jc_0802
implicit type casting in in Stateflow” (Simulink Check)
Stateflow
jc_0803: Passing values to Not checkable
library functions
jc_0804: Prohibited use of “Check usage of graphical mathworks.jmaab.jc_0804
recursive calls with graphical functions in Stateflow”
functions (Simulink Check)
jc_0805: Numerical operation No check
block inputs

1-13
1 Introduction

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
jc_0806: Detecting incorrect “Check diagnostic settings for mathworks.jmaab.jc_0806
calculation results incorrect calculation results”
(Simulink Check)
jc_0900: Usable characters for “Check bus and enumeration mathworks.jmaab_v6.jc_09
data type definition data type names” (Simulink 00
Check)
jc_0901: Length restriction for “Check length of bus and mathworks.jmaab_v6.jc_09
Bus and Enumeration data type enumeration data type names” 01
names (Simulink Check)
jc_0902: Arrowhead size of “Check arrowhead size of mathworks.jmaab_v6.jc_09
transition lines transition lines” (Simulink 02
Check)
jc_0903: Prohibition of “Check for prohibited mathworks.jmaab_v6.jc_09
overlapping or crossing of overlapping or intersecting 03
blocks and signal lines blocks and signal lines”
(Simulink Check)
jc_0904: Prohibition of overlap/ “Check for prohibited mathworks.jmaab_v6.jc_09
intersection of states and overlapping of states and 04
transition lines transition lines in Stateflow
charts” (Simulink Check)
jc_0905: Usable characters for “Check data names in MATLAB mathworks.jmaab_v6.jc_09
data names in Functions functions” (Simulink Check) 05
jc_0906: Length restriction of “Check the length of data names mathworks.jmaab_v6.jc_09
data names in MATLAB in MATLAB functions” (Simulink 06
Functions Check)
jc_0907: Size of a Junction “Check size of junctions” mathworks.jmaab_v6.jc_09
(Simulink Check) 07
jm_0002: Block resizing No check
jm_0011: Pointers in Stateflow “Check for pointers in Stateflow mathworks.maab.jm_0011
charts” (Simulink Check)
jm_0012: Usage restrictions of “Check for usage of events in mathworks.jmaab_v6.jm_00
events and broadcasting events Stateflow charts” (Simulink 12
Check)
mp_0007: How to describe “Check description of execution mathworks.jmaab_v6.mp_00
executable statements statements” (Simulink Check) 07
mp_0008: Format of “Check for spaces between mathworks.jmaab_v6.mp_00
parentheses function or variable names and 08
left parenthesis symbol”
(Simulink Check)
mp_0010: Precedence of “Check for operator mathworks.jmaab_v6.mp_00
Operators in Arithmetic precedence” (Simulink Check) 10
Expressions

1-14
Model Advisor Checks for MAB Modeling Guidelines

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
mp_0011: Method of inserting a “Check spaces in expressions” mathworks.jmaab_v6.mp_00
single-width space (Simulink Check) 11
mp_0022: Format of Conditional “Check description of mathworks.jmaab_v6.mp_00
Expressions conditional expressions” 22
(Simulink Check)
mp_0023: Format of relational “Check relational operators mathworks.jmaab_v6.mp_00
operations using constants usage” (Simulink Check) 23
mp_0032: Function header “Check function headers” mathworks.jmaab_v6.mp_00
information (Simulink Check) 32
mp_0034: Number of lines in a “Check number of lines of mathworks.jmaab_v6.mp_00
function functions” (Simulink Check) 34
mp_0040: Using the return “Check for utilization of the mathworks.jmaab_v6.mp_00
value of a function return value of functions” 40
(Simulink Check)
mp_0046: Usage of expressions “Check array indices” (Simulink mathworks.jmaab_v6.mp_00
in array indices Check) 46
mp_0047: Conditions that a “Check for usage of nonempty mathworks.jmaab_v6.mp_00
nonempty statement must statements” (Simulink Check) 47
satisfy
na_0001: Standard usage of “Check Stateflow operators” mathworks.jmaab.na_0001
Stateflow operators (Simulink Check)
na_0002: Appropriate usage of “Check fundamental logical and mathworks.jmaab.na_0002
basic logical and numerical numerical operations” (Simulink
operations Check)
na_0003: Usage of If blocks “Check logical expressions in If mathworks.maab.na_0003
blocks” (Simulink Check)
na_0004: Simulink model “Check for Simulink diagrams mathworks.maab.na_0004
appearance settings using nonstandard display
attributes” (Simulink Check)
na_0008: Display of labels on “Check signal line labels” mathworks.maab.na_0008
signals (Simulink Check)
na_0009: Entry versus “Check for propagated signal mathworks.maab.na_0009
propagation of signal labels labels” (Simulink Check)
na_0010: Usage of vector and “Check usage of vector and bus mathworks.jmaab.na_0010
bus signals signals” (Simulink Check)
na_0011: Scope of Goto and “Check scope of From and Goto mathworks.jmaab_v6.na_00
From blocks blocks” (Simulink Check) 11
na_0016: Source lines of “Check lines of code in MATLAB mathworks.jmaab.na_0016
MATLAB Functions Functions” (Simulink Check)
na_0017: Number of called “Check the number of function mathworks.jmaab.na_0017
function levels calls in MATLAB Function
blocks” (Simulink Check)

1-15
1 Introduction

MAB Modeling Guideline Model Advisor Check Check ID

(Version 6.0)
na_0018: Number of nested if/ “Check nested conditions in mathworks.jmaab.na_0018
else and case statement MATLAB Functions” (Simulink
Check)
na_0019: Restricted variable “Check usage of restricted mathworks.maab.na_0019
names variable names” (Simulink
Check)
na_0020: Number of inputs to “Check for missing ports in mathworks.jmaab_v6.na_00
variant subsystems Variant Subsystems” (Simulink 20
Check)
na_0021: Strings in MATLAB “Check usage of character mathworks.maab.na_0021
functions vector inside MATLAB Function
block” (Simulink Check)
na_0022: Recommended “Check usage of recommended mathworks.maab.na_0022
patterns for Switch/Case patterns for Switch/Case
statements statements” (Simulink Check)
na_0024: Shared data in “Check MATLAB code for global mathworks.maab.na_0024
MATLAB functions variables” (Simulink Check)
na_0025: MATLAB Function No check
header
na_0031: Definition of default “Check usage of enumerated mathworks.maab.na_0031
enumerated value values” (Simulink Check)
na_0034: MATLAB Function “Check input and output mathworks.maab.na_0034
block input/output settings settings of MATLAB Functions”
(Simulink Check)
na_0036: Default variant “Check use of default variants” mathworks.maab.na_0036
(Simulink Check)
na_0037: Use of single variable “Check use of single variable mathworks.maab.na_0037
for variant condition variant conditionals” (Simulink
Check)
na_0039: Limitation on Simulink “Check use of Simulink in mathworks.maab.na_0039
functions in Chart blocks Stateflow charts” (Simulink
Check)
na_0042: Usage of Simulink “Check usage of Simulink mathworks.jmaab.na_0042
functions function in Stateflow” (Simulink
Check)

1-16
Model Advisor Checks for JMAAB Modeling Guidelines

Model Advisor Checks for JMAAB Modeling Guidelines


This table identifies the Model Advisor checks that you can use to verify compliance of your model
with Japan MathWorks Automotive Advisor Board (JMAAB) modeling guidelines.

In the Model Advisor, JMAAB checks are organized by guideline version. To access the checks, select:

• By Product > Simulink Check > Modeling Standards and choose:

• JMAAB v5.1 Checks — Checks for version 5.1 of the JMAAB modeling guidelines.
• JMAAB v6.0 Checks — Checks for version 6.0 of the JMAAB modeling guidelines.
• By Task and choose:

• Modeling Standards for JMAAB v5.1 — Checks for version 5.1 of the JMAAB modeling
guidelines.
• Modeling Standards for JMAAB v6.0 — Checks for version 6.0 of the JMAAB modeling
guidelines.

You need Simulink Check to execute the Model Advisor checks.

Several modeling guidelines have changed between versions of publication JMAAB Control Algorithm
Modeling Guidelines - Using MATLAB, Simulink, and Stateflow, resulting in new Model Advisor
checks. New check IDs for version 6.0 are in the format mathworks.jmaab_v6.<guideline ID>.
For all other checks, a single Model Advisor check is applicable for both modeling guideline versions.

Guidelines that do not have corresponding Model Advisor checks are identified by using:

• No check — Indicates that the guideline can be checked by using a Model Advisor check, however,
the check does not currently exist.
• Not checkable — Indicates that it is not possible to verify compliance to this guideline by using a
Model Advisor check.

Use these links to view the version-specific modeling guideline:

• For version 5.1, see Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and
Stateflow
• For version 6.0, see Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and
Stateflow

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
ar_0001: Usable Version 5.1 “Check file names” mathworks.jmaab.ar
characters for file Version 6.0 (Simulink Check) _0001
names
ar_0002: Usable Version 5.1 “Check folder names” mathworks.jmaab.ar
characters for folder (Simulink Check) _0002
names Version 6.0 “Check folder names” mathworks.jmaab_v6
(Simulink Check) .ar_0002

1-17
1 Introduction

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
db_0032: Signal line Version 5.1 “Check signal line mathworks.jmaab.db
connections connections” (Simulink _0032
Check)
Version 6.0 “Check signal line mathworks.jmaab_v6
connections” (Simulink .db_0032
Check)
db_0042: Usage of Version 5.1 “Check position of mathworks.jmaab.db
Inport and Outport Version 6.0 Inport and Outport _0042
blocks blocks” (Simulink
Check)
db_0043: Model font Version 5.1 “Check model font mathworks.jmaab.db
and font size Version 6.0 settings” (Simulink _0043
Check)
db_0081: Unconnected Version 5.1 “Check for unconnected mathworks.jmaab.db
signals and blocks Version 6.0 signal lines and blocks” _0081
(Simulink Check)
db_0097: Position of Version 5.1 “Check position of mathworks.jmaab.db
labels for signals and signal labels” (Simulink _0097
buses Check)
Version 6.0 “Check position of mathworks.jmaab_v6
signal labels” (Simulink .db_0097
Check)
db_0110: Block Version 5.1 “Check usage of tunable mathworks.maab.db_
parameters Version 6.0 parameters in blocks” 0110
(Simulink Check)
db_0112: Usage of Version 5.1 “Check Indexing Mode” mathworks.jmaab.db
index Version 6.0 (Simulink Check) _0112

db_0125: Stateflow local Version 5.1 “Check definition of mathworks.jmaab.db


data Stateflow data” _0125
(Simulink Check)
Version 6.0 “Check definition of mathworks.jmaab_v6
Stateflow data” .db_0125
(Simulink Check)
db_0126: Defining Version 5.1 “Check definition of mathworks.jmaab.db
Stateflow events Version 6.0 Stateflow events” _0126
(Simulink Check)
db_0127: Limitation on Version 5.1 “Check for MATLAB mathworks.jmaab.db
MATLAB commands in expressions in Stateflow _0127
Stateflow blocks charts” (Simulink
Check)
Version 6.0 “Check for MATLAB mathworks.jmaab_v6
expressions in Stateflow .db_0127
charts” (Simulink
Check)

1-18
Model Advisor Checks for JMAAB Modeling Guidelines

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
db_0129: Stateflow Version 5.1 “Check for Stateflow mathworks.jmaab.db
transition appearance transition appearance” _0129
(Simulink Check)
Version 6.0 “Check for Stateflow mathworks.jmaab_v6
transition appearance” .db_0129
(Simulink Check)
db_0132: Transitions in Version 5.1 “Check transitions in mathworks.jmaab.db
flow charts Version 6.0 Stateflow Flow charts” _0132
(Simulink Check)
db_0137: States in state Version 5.1 “Check for state in state mathworks.jmaab.db
machines Version 6.0 machines” (Simulink _0137
Check)
db_0140: Display of Version 5.1 “Check for display of mathworks.maab.db_
block parameters Version 6.0 block parameter” 0140
(Simulink Check)
db_0141: Signal flow in Version 5.1 “Check signal flow in mathworks.maab.db_
Simulink models Version 6.0 model” (Simulink 0141
Check)
db_0142: Position of Version 5.1 “Check whether block mathworks.maab.db_
block names Version 6.0 names appear below 0142
blocks” (Simulink
Check)
db_0143: Usable block Version 5.1 “Check for mixing basic mathworks.maab.db_
types in model Version 6.0 blocks and subsystems” 0143
hierarchy (Simulink Check)
db_0144: Use of Version 5.1 Not checkable
subsystems Version 6.0
db_0146: Block layout Version 5.1 “Check position of mathworks.jmaab.db
in conditional Version 6.0 conditional blocks and _0146
subsystems iterator blocks”
(Simulink Check)
jc_0008: Definition of Version 5.1 “Check definition of mathworks.jmaab.jc
signal names Version 6.0 signal labels” (Simulink _0008
Check)
jc_0009: Signal name Version 5.1 “Check signal name mathworks.jmaab.jc
propagation propagation” (Simulink _0009
Check)
Version 6.0 “Check signal name mathworks.jmaab_v6
propagation” (Simulink .jc_0009
Check)
jc_0011: Optimization Version 5.1 “Check Implement logic mathworks.maab.jc_
parameters for Boolean Version 6.0 signals as Boolean data 0011
data types (vs. double)” (Simulink
Check)

1-19
1 Introduction

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
jc_0061: Display of Version 5.1 “Check the display mathworks.maab.jc_
block names Version 6.0 attributes of block 0061
names” (Simulink
Check)
jc_0081: Inport and Version 5.1 “Check display for port mathworks.maab.jc_
Outport block icon Version 6.0 blocks” (Simulink 0081
display Check)
jc_0110: Direction of Version 5.1 “Check block mathworks.jmaab.jc
block Version 6.0 orientation” (Simulink _0110
Check)
jc_0121: Usage of add Version 5.1 “Check usage of Sum mathworks.jmaab.jc
and subtraction blocks Version 6.0 blocks” (Simulink _0121
Check)
jc_0131: Usage of Version 5.1 “Check usage of mathworks.maab.jc_
Relational Operator Version 6.0 Relational Operator 0131
blocks blocks” (Simulink
Check)
jc_0141: Usage of the Version 5.1 “Check usage of Switch mathworks.maab.jc_
Switch blocks Version 6.0 blocks” (Simulink 0141
Check)
jc_0161: Definition of Version 5.1 “Check for usage of mathworks.jmaab.jc
Data Store Memory Version 6.0 Data Store Memory _0161
blocks blocks” (Simulink
Check)
jc_0171: Clarification of Version 5.1 “Check connections mathworks.jmaab.jc
connections between Version 6.0 between structural _0171
structural subsystems subsystems” (Simulink
Check)
jc_0201: Usable Version 5.1 “Check subsystem mathworks.jmaab.jc
characters for Version 6.0 names” (Simulink _0201
subsystem names Check)
jc_0211: Usable Version 5.1 “Check port block mathworks.jmaab.jc
characters for Inport Version 6.0 names” (Simulink _0211
blocks and Outport Check)
block
jc_0222: Usable Version 5.1 “Check usable mathworks.jmaab.jc
characters for signal Version 6.0 characters for signal _0222
and bus names names and bus names”
(Simulink Check)
jc_0231: Usable Version 5.1 “Check character usage mathworks.jmaab.jc
characters for block Version 6.0 in block names” _0231
names (Simulink Check)

1-20
Model Advisor Checks for JMAAB Modeling Guidelines

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
jc_0232: Usable Version 5.1 “Check usable mathworks.jmaab.jc
characters for characters for _0232
parameter names parameter names”
(Simulink Check)
Version 6.0 “Check usable mathworks.jmaab_v6
characters for .jc_0232
parameter names”
(Simulink Check)
jc_0241: Length Version 5.1 “Check length of model mathworks.jmaab.jc
restriction for model file Version 6.0 file name” (Simulink _0241
names Check)
jc_0242: Length Version 5.1 “Check length of folder mathworks.jmaab.jc
restriction for folder Version 6.0 name at every level of _0242
names model path” (Simulink
Check)
jc_0243: Length Version 5.1 “Check length of mathworks.jmaab.jc
restriction for Version 6.0 subsystem names” _0243
subsystem names (Simulink Check)
jc_0244: Length Version 5.1 “Check length of Inport mathworks.jmaab.jc
restriction for Inport Version 6.0 and Outport names” _0244
and Outport names (Simulink Check)
jc_0245: Length Version 5.1 “Check length of signal mathworks.jmaab.jc
restriction for signal Version 6.0 and bus names” _0245
and bus names (Simulink Check)
jc_0246: Length Version 5.1 “Check length of mathworks.jmaab.jc
restriction for Version 6.0 parameter names” _0246
parameter name (Simulink Check)
jc_0247: Length Version 5.1 “Check length of block mathworks.jmaab.jc
restriction for block Version 6.0 names” (Simulink _0247
names Check)
jc_0281: Trigger signal Version 5.1 “Check trigger signal mathworks.jmaab.jc
names Version 6.0 names” (Simulink _0281
Check)
jc_0451: Use of unary Version 5.1 “Check usage of unary mathworks.jmaab.jc
minus on unsigned Version 6.0 minus operations in _0451
integers Stateflow charts”
(Simulink Check)
jc_0481: Use of hard Version 5.1 “Check usage of mathworks.maab.jc_
equality comparisons Version 6.0 floating-point 0481
for floating point expressions in Stateflow
numbers in Stateflow charts” (Simulink
Check)

1-21
1 Introduction

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
“Check usage of mathworks.jmaab_v6
floating-point .jc_0481
expressions in Stateflow
charts” (Simulink
Check)
jc_0491: Reuse of Version 5.1 Not checkable
Stateflow data Version 6.0
jc_0501: Format of Version 5.1 “Check entry formatting mathworks.jmaab.jc
entries in a State block Version 6.0 in State blocks in _0501
Stateflow charts”
(Simulink Check)
jc_0511: Return values Version 5.1 “Check return value mathworks.maab.jc_
from a graphical Version 6.0 assignments in 0511
function Stateflow graphical
functions” (Simulink
Check)
jc_0531: Default Version 5.1 “Check default mathworks.jmaab.jc
transition Version 6.0 transition placement in _0531
Stateflow charts”
(Simulink Check)
jc_0602: Consistency in Version 5.1 “Check for consistency mathworks.jmaab.jc
model element names Version 6.0 in model element _0602
names” (Simulink
Check)
jc_0603: Model Version 5.1 “Check Model mathworks.jmaab.jc
description Version 6.0 Description” (Simulink _0603
Check)
jc_0604: Using block Version 5.1 “Check if blocks are mathworks.jmaab.jc
shadow Version 6.0 shaded in the model” _0604
(Simulink Check)
jc_0610: Operator order Version 5.1 “Check operator order mathworks.jmaab.jc
for multiplication and Version 6.0 of Product blocks” _0610
division block (Simulink Check)
jc_0611: Input sign for Version 5.1 “Check signs of input mathworks.jmaab.jc
multiplication and Version 6.0 signals in product _0611
division blocks blocks” (Simulink
Check)
jc_0621: Usage of Version 5.1 “Check icon shape of mathworks.jmaab.jc
Logical Operator blocks Version 6.0 Logical Operator _0621
blocks” (Simulink
Check)
jc_0622: Usage of Fcn Version 5.1 “Check for parentheses mathworks.jmaab.jc
blocks in Fcn block _0622
expressions” (Simulink
Check)

1-22
Model Advisor Checks for JMAAB Modeling Guidelines

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
Version 6.0
jc_0623: Usage of Version 5.1 “Check usage of mathworks.jmaab.jc
continuous-time Delay Version 6.0 Memory and Unit Delay _0623
blocks and discrete-time blocks” (Simulink
Delay blocks Check)
jc_0624: Usage of Version 5.1 “Check for cascaded mathworks.jmaab.jc
Tapped Delay blocks/ Version 6.0 Unit Delay blocks” _0624
Delay blocks (Simulink Check)
jc_0626: Usage of Version 5.1 “Check usage of Lookup mathworks.jmaab.jc
Lookup Table blocks Version 6.0 Tables” (Simulink _0626
Check)
jc_0627: Usage of Version 5.1 “Check usage of mathworks.jmaab.jc
Discrete-Time Discrete-Time _0627
Integrator blocks Integrator block”
(Simulink Check)
Version 6.0 “Check usage of mathworks.jmaab_v6
Discrete-Time .jc_0627
Integrator block”
(Simulink Check)
jc_0628: Usage of Version 5.1 “Check usage of the mathworks.jmaab.jc
Saturation blocks Version 6.0 Saturation blocks” _0628
(Simulink Check)
jc_0630: Usage of Version 5.1 “Check settings for data mathworks.jmaab.jc
Multiport Switch blocks ports in Multiport _0630
Switch blocks”
(Simulink Check)
Version 6.0 “Check settings for data mathworks.jmaab_v6
ports in Multiport .jc_0630
Switch blocks”
(Simulink Check)
jc_0640: Initial value Version 5.1 “Check undefined initial mathworks.jmaab.jc
settings for Outport Version 6.0 output for conditional _0640
blocks in conditional subsystems” (Simulink
subsystems Check)
jc_0641: Sample time Version 5.1 “Check for sample time mathworks.jmaab.jc
setting Version 6.0 setting” (Simulink _0641
Check)
jc_0642: Integer Version 5.1 “Check Signed Integer mathworks.jmaab.jc
rounding mode setting Version 6.0 Division Rounding _0642
mode” (Simulink Check)
jc_0643: Fixed-point Version 5.1 “Check usage of fixed- mathworks.jmaab.jc
setting Version 6.0 point data type with _0643
non-zero bias”
(Simulink Check)

1-23
1 Introduction

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
jc_0644: Type setting Version 5.1 “Check type setting by mathworks.jmaab.jc
data objects” (Simulink _0644
Check)
Version 6.0 “Check type setting by mathworks.jmaab_v6
data objects” (Simulink .jc_0644
Check)
jc_0645: Parameter Version 5.1 “Check if tunable block mathworks.jmaab.jc
definition for calibration Version 6.0 parameters are defined _0645
as named constants”
(Simulink Check)
jc_0650: Block input/ Version 5.1 “Check input and output mathworks.jmaab.jc
output data type with Version 6.0 datatype for Switch _0650
switching function blocks” (Simulink
Check)
jc_0651: Implementing Version 5.1 “Check output data type mathworks.jmaab.jc
a type conversion of operation blocks” _0651
(Simulink Check)
Version 6.0 “Check Output data mathworks.jmaab_v6
type of operation .jc_0651
blocks” (Simulink
Check)
jc_0653: Delay block Version 5.1 “Check for avoiding mathworks.jmaab.jc
layout in feedback loops Version 6.0 algebraic loops between _0653
subsystems” (Simulink
Check)
jc_0655: Prohibition of Version 5.1 “Check prohibited mathworks.jmaab.jc
logical value Version 6.0 comparison operation of _0655
comparison in Stateflow logical type signals”
(Simulink Check)
jc_0656: Usage of Version 5.1 “Check default/else case mathworks.jmaab.jc
Conditional Control Version 6.0 in Switch Case blocks _0656
blocks and If blocks” (Simulink
Check)
jc_0657: Retention of Version 5.1 Not checkable
output value based on Version 6.0
conditional control flow
blocks and Merge
blocks
jc_0659: Usage Version 5.1 “Check usage of Merge mathworks.jmaab.jc
restrictions of signal Version 6.0 block” (Simulink Check) _0659
lines input to Merge
blocks
jc_0700: Unused data in Version 5.1 “Check for unused data mathworks.jmaab.jc
Stateflow block Version 6.0 in Stateflow Charts” _0700
(Simulink Check)

1-24
Model Advisor Checks for JMAAB Modeling Guidelines

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
jc_0701: Usable number Version 5.1 “Check usable number mathworks.jmaab.jc
for first index Version 6.0 for first index” _0701
(Simulink Check)
jc_0702: Use of named Version 5.1 “Check usage of mathworks.jmaab.jc
Stateflow parameters Version 6.0 numeric literals in _0702
and constants Stateflow” (Simulink
Check)
jc_0711: Division in Version 5.1 Not checkable
Stateflow Version 6.0
jc_0712: Execution Version 5.1 “Check execution mathworks.jmaab.jc
timing for default Version 6.0 timing for default _0712
transition path transition path”
(Simulink Check)
jc_0721: Usage of Version 5.1 “Check usage of parallel mathworks.jmaab.jc
parallel states Version 6.0 states” (Simulink _0721
Check)
jc_0722: Local data Version 5.1 “Check scope of data in mathworks.jmaab.jc
definition in parallel Version 6.0 parallel states” _0722
states (Simulink Check)
jc_0723: Prohibited Version 5.1 “Check usage of mathworks.jmaab.jc
direct transition from Version 6.0 transitions to external _0723
external state to child states” (Simulink
state Check)
jc_0730: Unique state Version 5.1 “Check uniqueness of mathworks.jmaab.jc
name in Stateflow Version 6.0 State names” (Simulink _0730
blocks Check)
jc_0731: State name Version 5.1 “Check usage of State mathworks.jmaab.jc
format Version 6.0 names” (Simulink _0731
Check)
jc_0732: Distinction Version 5.1 “Check uniqueness of mathworks.jmaab.jc
between state names, Version 6.0 Stateflow state, data _0732
data names, and event and event names”
names (Simulink Check)
jc_0733: Order of state Version 5.1 “Check order of state mathworks.jmaab.jc
action types Version 6.0 action types” (Simulink _0733
Check)
jc_0734: Number of Version 5.1 “Check repetition of mathworks.jmaab.jc
state action types Version 6.0 action types” (Simulink _0734
Check)
jc_0736: Uniform Version 6.0 “Check indentation of mathworks.jmaab.jc
indentations in Version 5.1 code in Stateflow _0736
Stateflow blocks states” (Simulink
Check)

1-25
1 Introduction

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
jc_0738: Usage of Version 6.0 “Check usage of mathworks.jmaab.jc
Stateflow comments Version 5.1 Stateflow comments” _0738
(Simulink Check)
jc_0739: Describing text Version 5.1 “Check for usage of text mathworks.jmaab.jc
inside states inside states” (Simulink _0739
Check)
jc_0740: Limitation on Version 5.1 “Check if state action mathworks.jmaab.jc
use of exit state action Version 6.0 type 'exit' is used in the _0740
model” (Simulink
Check)
jc_0741: Timing to Version 5.1 “Check updates to mathworks.jmaab.jc
update data used in variables used in state _0741
state chart transition transition conditions”
conditions (Simulink Check)
Version 6.0 “Check updates to mathworks.jmaab_v6
variables used in state .jc_0741
transition conditions”
(Simulink Check)
jc_0751: Backtracking Version 5.1 “Check for unexpected mathworks.jmaab.jc
prevention in state Version 6.0 backtracking in state _0751
transition transitions” (Simulink
Check)
jc_0752: Condition Version 5.1 “Check usage of mathworks.jmaab.jc
action in transition label Version 6.0 parentheses in _0752
Stateflow transitions”
(Simulink Check)
jc_0753: Condition Version 5.1 “Check condition mathworks.jmaab.jc
actions and transition actions and transition _0753
actions in Stateflow actions in Stateflow”
(Simulink Check)
Version 6.0 “Check condition mathworks.jmaab_v6
actions and transition .jc_0753
actions in Stateflow”
(Simulink Check)
jc_0760: Starting point Version 5.1 “Check starting point of mathworks.jmaab.jc
of internal transition Version 6.0 internal transition in _0760
Stateflow” (Simulink
Check)
jc_0762: Prohibition of Version 5.1 “Check prohibited mathworks.jmaab.jc
state action and flow Version 6.0 combination of state _0762
chart combination action and flow chart”
(Simulink Check)
jc_0763: Usage of Version 5.1 “Check usage of mathworks.jmaab.jc
multiple internal internal transitions in _0763
transitions

1-26
Model Advisor Checks for JMAAB Modeling Guidelines

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
Version 6.0 Stateflow states”
(Simulink Check)
jc_0770: Position of Version 5.1 “Check placement of mathworks.jmaab.jc
transition label Label String in _0770
Transitions” (Simulink
Check)
Version 6.0 “Check placement of mathworks.jmaab_v6
Label String in .jc_0770
Transitions” (Simulink
Check)
jc_0771: Comment Version 5.1 “Check position of mathworks.jmaab.jc
position in transition Version 6.0 comments in transition _0771
labels labels” (Simulink
Check)
jc_0772: Execution Version 5.1 “Check usage of mathworks.jmaab.jc
order and transition Version 6.0 transition conditions in _0772
conditions of transition Stateflow transitions”
lines (Simulink Check)
jc_0773: Unconditional Version 5.1 “Check usage of mathworks.jmaab.jc
transition of a flow Version 6.0 unconditional _0773
chart transitions in flow
charts” (Simulink
Check)
jc_0774: Comments for Version 5.1 “Check for comments in mathworks.jmaab.jc
through transition Version 6.0 unconditional _0774
transitions” (Simulink
Check)
jc_0775: Terminating Version 5.1 “Check terminal mathworks.jmaab.jc
junctions in flow charts Version 6.0 junctions in Stateflow” _0775
(Simulink Check)
jc_0790: Action Version 5.1 “Check Stateflow chart mathworks.jmaab.jc
language of Chart block Version 6.0 action language” _0790
(Simulink Check)
jc_0791: Duplicate data Version 5.1 “Check duplication of mathworks.jmaab.jc
name definitions Version 6.0 Simulink data names” _0791
(Simulink Check)
jc_0792: Unused Data Version 5.1 “Check unused data in mathworks.jmaab.jc
Version 6.0 Simulink Model” _0792
(Simulink Check)
jc_0794: Division in Version 5.1 “Check for division by mathworks.jmaab.jc
Simulink Version 6.0 zero in Simulink” _0794
(Simulink Check)
jc_0795: Usable Version 5.1 “Check usable mathworks.jmaab.jc
characters for Stateflow characters for Stateflow _0795
data names

1-27
1 Introduction

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
Version 6.0 data names” (Simulink
Check)
jc_0796: Length Version 5.1 “Check length of mathworks.jmaab.jc
restriction for Stateflow Version 6.0 Stateflow data name” _0796
data names (Simulink Check)
jc_0797: Unconnected Version 5.1 “Check for unconnected mathworks.jmaab.jc
transitions / states / Version 6.0 objects in Stateflow _0797
connective junctions Charts” (Simulink
Check)
jc_0800: Comparing Version 5.1 “Check comparison of mathworks.jmaab.jc
floating-point types in Version 6.0 floating point types in _0800
Simulink Simulink” (Simulink
Check)
jc_0801: Prohibited use Version 5.1 “Check for use of C- mathworks.jmaab.jc
of the /* and 8/ Version 6.0 style comment symbols” _0801
comment symbols (Simulink Check)
jc_0802: Prohibited use Version 5.1 “Check for implicit type mathworks.jmaab.jc
of implicit type casting Version 6.0 casting in Stateflow” _0802
in Stateflow (Simulink Check)
jc_0803: Passing values Version 5.1 Not checkable
to library functions Version 6.0
jc_0804: Prohibited use Version 5.1 “Check usage of mathworks.jmaab.jc
of recursive calls with Version 6.0 graphical functions in _0804
graphical functions Stateflow” (Simulink
Check)
jc_0805: Numerical Version 5.1 No check
operation block inputs Version 6.0
jc_0806: Detecting Version 5.1 “Check diagnostic mathworks.jmaab.jc
incorrect calculation settings for incorrect _0806
results calculation results”
(Simulink Check)
jc_0900: Usable Version 6.0 “Check bus and mathworks.jmaab_v6
characters for Data enumeration data type .jc_0900
Type definition names” (Simulink
Check)
jc_0901: Length Version 6.0 “Check length of bus mathworks.jmaab_v6
restriction for Data and enumeration data .jc_0901
Type definition type names” (Simulink
Check)
jc_0902: Arrowhead size Version 6.0 “Check arrowhead size mathworks.jmaab_v6
of transition lines of transition lines” .jc_0902
(Simulink Check)

1-28
Model Advisor Checks for JMAAB Modeling Guidelines

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
jc_0903: Prohibition of Version 6.0 “Check for prohibited mathworks.jmaab_v6
overlapping/crossing of overlapping or .jc_0903
blocks and signal line intersecting blocks and
signal lines” (Simulink
Check)
jc_0904: Prohibition of Version 6.0 “Check for prohibited mathworks.jmaab_v6
overlap/intersection of overlapping of states .jc_0904
states and transition and transition lines in
lines Stateflow charts”
(Simulink Check)
jc_0905: Usable Version 6.0 “Check data names in mathworks.jmaab_v6
characters for data MATLAB functions” .jc_0905
names in MATLAB (Simulink Check)
function
jc_0906: Length Version 6.0 “Check the length of mathworks.jmaab_v6
restriction for data data names in MATLAB .jc_0906
names in MATLAB functions” (Simulink
function Check)
jc_0907: Size of Version 6.0 “Check size of mathworks.jmaab_v6
junctions junctions” (Simulink .jc_0907
Check)
jm_0002: Block resizing Version 5.1 No check
Version 6.0
jm_0011: Pointers in Version 5.1 “Check for pointers in mathworks.maab.jm_
Stateflow Version 6.0 Stateflow charts” 0011
(Simulink Check)
jm_0012: Usage Version 5.1 “Check for usage of mathworks.jmaab.jm
restrictions of events events in Stateflow _0012
and broadcasting events charts” (Simulink
Check)
Version 6.0 “Check for usage of mathworks.jmaab_v6
events in Stateflow .jm_0012
charts” (Simulink
Check)
na_0001: Standard Version 5.1 “Check Stateflow mathworks.jmaab.na
usage of Stateflow Version 6.0 operators” (Simulink _0001
operators Check)
na_0002: Appropriate Version 5.1 “Check fundamental mathworks.jmaab.na
usage of basic logical Version 6.0 logical and numerical _0002
and numerical operations” (Simulink
operations Check)
na_0003: Usage of If Version 5.1 “Check logical mathworks.maab.na_
blocks Version 6.0 expressions in If blocks” 0003
(Simulink Check)

1-29
1 Introduction

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
na_0004: Simulink Version 5.1 “Check for Simulink mathworks.maab.na_
model appearance Version 6.0 diagrams using 0004
settings nonstandard display
attributes” (Simulink
Check)
na_0010: Usage of Version 5.1 “Check usage of vector mathworks.jmaab.na
vector and bus signals Version 6.0 and bus signals” _0010
(Simulink Check)
na_0011: Scope of Goto Version 5.1 “Check scope of From mathworks.maab.na_
and From blocks and Goto blocks” 0011
(Simulink Check)
Version 6.0 “Check scope of From mathworks.jmaab_v6
and Goto blocks” .na_0011
(Simulink Check)
na_0020: Number of Version 5.1 “Check for missing mathworks.jmaab.na
inputs to variant ports in Variant _0020
subsystems Subsystems” (Simulink
Check)
Version 6.0 “Check for missing mathworks.jmaab_v6
ports in Variant .na_0020
Subsystems” (Simulink
Check)
na_0021: Strings in Version 5.1 “Check usage of mathworks.maab.na_
MATLAB functions Version 6.0 character vector inside 0021
MATLAB Function
block” (Simulink Check)
na_0024: Shared data in Version 5.1 “Check MATLAB code mathworks.maab.na_
MATLAB functions Version 6.0 for global variables” 0024
(Simulink Check)
na_0031: Definition of Version 5.1 “Check usage of mathworks.maab.na_
default enumerated Version 6.0 enumerated values” 0031
value (Simulink Check)
na_0034: MATLAB Version 5.1 “Check input and output mathworks.maab.na_
Function block input/ Version 6.0 settings of MATLAB 0034
output settings Functions” (Simulink
Check)
na_0036: Default Version 5.1 “Check use of default mathworks.maab.na_
variant Version 6.0 variants” (Simulink 0036
Check)
na_0037: Use of single Version 5.1 “Check use of single mathworks.maab.na_
variable for variant Version 6.0 variable variant 0037
condition conditionals” (Simulink
Check)

1-30
Model Advisor Checks for JMAAB Modeling Guidelines

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
na_0039: Limitation on Version 5.1 “Check use of Simulink mathworks.maab.na_
Simulink functions in Version 6.0 in Stateflow charts” 0039
Chart blocks (Simulink Check)
na_0042: Usage of Version 5.1 “Check usage of mathworks.jmaab.na
Simulink functions Version 6.0 Simulink function in _0042
Stateflow” (Simulink
Check)
mp_0007: How to Version 6.0 “Check description of mathworks.jmaab_v6
describe execution execution statements” .mp_0007
statements (Simulink Check)
mp_0008: Format of Version 6.0 “Check for spaces mathworks.jmaab_v6
parenthesis between function or .mp_0008
variable names and left
parenthesis symbol”
(Simulink Check)
mp_0010: How to Version 6.0 “Check for operator mathworks.jmaab_v6
describe the priority of precedence” (Simulink .mp_0010
operators Check)
mp_0011: How to insert Version 6.0 “Check spaces in mathworks.jmaab_v6
one single-byte space expressions” (Simulink .mp_0011
Check)
mp_0016: Nesting levels Version 6.0 “Check nested mathworks.jmaab.na
of control statements conditions in MATLAB _0018
Functions” (Simulink
Check)
mp_0020: How to Version 6.0 “Check usage of mathworks.maab.na_
describe Switch/Case recommended patterns 0022
statements for Switch/Case
statements” (Simulink
Check)
mp_0022: How to Version 6.0 “Check description of mathworks.jmaab_v6
describe conditional conditional expressions” .mp_0022
expression (Simulink Check)
mp_0023: How to Version 6.0 “Check relational mathworks.jmaab_v6
describe relational operators usage” .mp_0023
operators (Simulink Check)
mp_0025: How to call Version 6.0 “Check the number of mathworks.maab.na_
functions function calls in 0017
MATLAB Function
blocks” (Simulink
Check)
mp_0032: Function Version 6.0 “Check function mathworks.jmaab_v6
headers headers” (Simulink .mp_0032
Check)

1-31
1 Introduction

JMAAB Modeling Guideline Publication Model Advisor Check Check ID


Guideline Version
mp_0034: Number of Version 6.0 “Check number of lines mathworks.jmaab_v6
lines of functions of functions” (Simulink .mp_0034
Check)
mp_0040: Utilizing the Version 6.0 “Check for utilization of mathworks.jmaab_v6
return value of the return value of .mp_0040
functions functions” (Simulink
Check)
mp_0046: How to Version 6.0 “Check array indices” mathworks.jmaab_v6
describe array indexes (Simulink Check) .mp_0046
mp_0047: The Version 6.0 “Check for usage of mathworks.jmaab_v6
conditions for non- nonempty statements” .mp_0047
empty statements to be (Simulink Check)
satisfied

See Also
• For more information on Reserved MATLAB words, Built-in MATLAB functions and MATLAB
keywords, refer Appendix C.

1-32
2

Naming Conventions

• “General Conventions” on page 2-2


• “Content Conventions” on page 2-11
2 Naming Conventions

General Conventions

2-2
ar_0001: Usable characters for file names

ar_0001: Usable characters for file names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d, e, f, g
• JMAAB — a, b, c, d, e, f, g

MATLAB Versions
All

Rule
Sub ID a

Only these character types shall be used in file names:

• Single-byte alphanumeric characters (a-z, A-Z, 0-9)


• Single-byte underscore (_)

Line breaks, single-byte spaces, double-byte characters, and control characters shall not be used. File
types that are checked for model and MATLAB files shall be set in the project settings.
Custom Parameter

File (extension)
Example — Incorrect

MAB Model.slx — Single-byte spaces are used

JMAAB 設定.m or NA-MAABModel.p — Double-byte characters are used.

JMAAB(Model).mdl — Symbol characters are used.

Sub ID b

The file name shall not use numbers at the beginning.


Custom Parameter

File (extension)

2-3
2 Naming Conventions

Example — Incorrect

001_JMAABModel.slx

Sub ID c

The file name shall not use underscores at the beginning.


Custom Parameter

File (extension)
Example — Incorrect

_JMAABModel.slx

Sub ID d

The file name shall not use an underscore at the end.


Custom Parameter

File (extension)
Example — Incorrect

MABModel_.slx

Sub ID e

The file name shall not use consecutive underscores.


Custom Parameter

File (extension)
Example — Incorrect

JMAAB__Model.slx

Sub ID f

The file name shall not consist solely of a single reserved MATLAB word.
Custom Parameter

File (extension)
Example — Incorrect

ans.slx, double.slx

Sub ID g

File names on the MATLAB path shall not be identical.


Custom Parameter

File (extension)

2-4
ar_0001: Usable characters for file names

Example — Incorrect

Files with the same name are saved to the folder that goes through the MATLAB path.

Rationale
Sub IDs a, b, c, f:

• Readability is impaired.
• Deviation from the rule can cause unexpected issues.

Sub IDs d, e

• Readability is impaired.

Sub ID g:

• If there are multiple files with the same name, the one higher on the path is loaded. As a result,
unnecessary files might be included.
• Readability is impaired.
• Deviation from the rule can cause unexpected issues.

Verification
Model Advisor check: “Check file names” (Simulink Check)

Last Changed
R2020a

See Also
• “Reserved Keywords” (Embedded Coder)
• “Reserved Identifiers and Code Replacement” (Embedded Coder)

Version History
Introduced in R2020a

2-5
2 Naming Conventions

ar_0002: Usable characters for folder names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d, e, f
• JMAAB — a, b, c, d, e, f

MATLAB Versions
All

Rule
Sub ID a

Only these character types shall be used in folder names:

• Single-byte alphanumeric characters (a-z, A-Z, 0-9)


• Single-byte underscore (_)

Line breaks, single-byte spaces, double-byte characters, and control characters shall not be used.
Custom Parameter

Applicable folder for the rule


Example — Incorrect

Sub ID b

The folder name shall not use numbers at the beginning.


Custom Parameter

Applicable folder for the rule

2-6
ar_0002: Usable characters for folder names

Example — Incorrect

Sub ID c

The folder name shall not use underscores at the beginning.


Custom Parameter

Applicable folder for the rule


Example — Incorrect

Sub ID d

The folder name shall not use underscores at the end.


Custom Parameter

Applicable folder for the rule


Example — Incorrect

Sub ID e

The folder name shall not use consecutive underscores.


Custom Parameter

Applicable folder for the rule


Example — Incorrect

Sub ID f

The folder name shall not consist solely of a single reserved MATLAB word.
Custom Parameter

Applicable folder for the rule

2-7
2 Naming Conventions

Example — Incorrect

Rationale
Sub IDs a, b, c, d, e, f:

• Readability is impaired.
• Deviation from the rule can cause unexpected issues.

Verification
Model Advisor check: “Check folder names” (Simulink Check)

Last Changed
R2024b

See Also
• “Reserved Keywords” (Embedded Coder)
• “Reserved Identifiers and Code Replacement” (Embedded Coder)

Version History
Introduced in R2020a

2-8
jc_0241: Length restriction for model file names

jc_0241: Length restriction for model file names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Model file name length shall be a maximum of 63 characters (not including dots and extension).
Custom Parameter

Maximum model file name length

Rationale
Sub ID a:

• Possible that a long file name cannot be referred to in the model reference.

Verification
Model Advisor check: “Check length of model file name” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

2-9
2 Naming Conventions

jc_0242: Length restriction for folder names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Folder name length shall be a maximum of 63 characters.


Custom Parameter

Maximum folder name

Rationale
Sub ID a:

• Possible that the full path name cannot be display in the user interface.

Verification
Model Advisor check: “Check length of folder name at every level of model path” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

2-10
Content Conventions

Content Conventions

2-11
2 Naming Conventions

jc_0201: Usable characters for subsystem names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d, e, f
• JMAAB — a, b, c, d, e, f

MATLAB Versions
All

Rule
Sub ID a

Only these character types shall be used in structural subsystem names:

• Single-byte alphanumeric characters (a-z, A-Z, 0-9)


• Single-byte underscore (_)

Line breaks, single-byte spaces, double-byte characters, and control characters shall not be used.
Custom Parameter

Not Applicable
Example — Incorrect

Single-byte spaces, double-byte, and symbol characters are used.

2-12
jc_0201: Usable characters for subsystem names

Sub ID b

A structural subsystem name shall not use numbers at the beginning.


Custom Parameter

Not Applicable
Example — Incorrect

Sub ID c

A structural subsystem name shall not use an underscore at the beginning.


Custom Parameter

Not Applicable
Example — Incorrect

Sub ID d

A structural subsystem name shall not use an underscore at the end.


Custom Parameter

Not Applicable

2-13
2 Naming Conventions

Example — Incorrect

Sub ID e

A structural subsystem name shall not use consecutive underscores.


Custom Parameter

Not Applicable
Example — Incorrect

Sub ID f

A structural subsystem shall not consist solely of a single reserved MATLAB word.
Custom Parameter

Not Applicable
Example — Incorrect

Rationale
Sub IDs a, b, f:

• Cannot generate code using the configured structural subsystem name.

Sub IDs c, d, e:

• May not be able to generate code using the configured structural subsystem name.

Verification
Model Advisor check: “Check subsystem names” (Simulink Check)

2-14
jc_0201: Usable characters for subsystem names

Last Changed
R2020a

See Also
• “Explore Types of Subsystems”

Version History
Introduced in R2020a

2-15
2 Naming Conventions

jc_0231: Usable characters for block names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d, e, f
• JMAAB — a, b, c, d, e, f

MATLAB Versions
All

Rule
Sub ID a

Only these character types shall be used for basic block names:

• Single-byte alphanumeric characters (a-z, A-Z, 0-9)


• Single-byte underscore (_)

Line breaks and single-byte spaces shall not be permitted when adding a new block name. However,
they shall be permitted when used initially as a block name that is saved in the Simulink library.

Double-byte characters and control characters shall not be used.


Exception

Inport and Outport blocks


Custom Parameter

Not Applicable
Example — Correct

Block names are registered in the Simulink library.

2-16
jc_0231: Usable characters for block names

Example — Incorrect

Single-byte spaces, double-byte characters, and symbol characters are used.

Sub ID b

Basic block names shall not use numbers at the beginning.


Exception

Inport and Outport blocks


Custom Parameter

Not Applicable
Example — Incorrect

Sub ID c

Basic block names shall not use underscores at the beginning.


Exception

Inport and Outport blocks


Custom Parameter

Not Applicable

2-17
2 Naming Conventions

Example — Incorrect

Sub ID d

Basic block names shall not use underscores at the end.


Exception

Inport and Outport blocks


Custom Parameter

Not Applicable
Example — Incorrect

Sub ID e

Basic block names shall not use consecutive underscores.


Exception

Inport and Outport blocks


Custom Parameter

Not Applicable
Example — Incorrect

Sub ID f

Basic block names shall not consist solely of a single reserved MATLAB word.
Exception

Inport and Outport blocks


Custom Parameter

Not Applicable

2-18
jc_0231: Usable characters for block names

Example — Incorrect

Rationale
Sub IDs a, b:

• Deviation from the rule can make it difficult to maintain the integrity of the model and code.

Sub IDs c, e:

• Readability is impaired.

Sub IDs d:

• Readability is impaired.
• Underscores can be used to separate words. However, they are typically used as word breaks and
can cause misunderstanding in the description.

Sub IDs f:

• Readability is impaired.
• Deviation from the rule can cause unexpected issues.

Verification
Model Advisor check: “Check character usage in block names” (Simulink Check)

Last Changed
R2020a

See Also
• “Reserved Keywords” (Embedded Coder)
• “Reserved Identifiers and Code Replacement” (Embedded Coder)

Version History
Introduced in R2020a

2-19
2 Naming Conventions

jc_0211: Usable characters for Inport blocks and


Outport block

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d, e, f
• JMAAB — a, b, c, d, e, f

MATLAB Versions
All

Rule
Sub ID a

Only these character types shall be used in Inport and Outport block names:

• Single-byte alphanumeric characters (a-z, A-Z, 0-9)


• Single-byte underscore (_)

Line breaks, single-byte spaces, double-byte characters, and control characters shall not be used.
Custom Parameter

Not Applicable
Example — Incorrect

2-20
jc_0211: Usable characters for Inport blocks and Outport block

Sub ID b

[Inport] and [Outport] block names shall not use numbers at the beginning.
Custom Parameter

Not Applicable
Example — Incorrect

Sub ID c

[Inport] and [Outport] block names shall not use underscores at the beginning.
Custom Parameter

Not Applicable
Example — Incorrect

Sub ID d

[Inport] and [Outport] block names shall not use underscores at the end.
Custom Parameter

Not Applicable
Example — Incorrect

Sub ID e

[Inport] and [Outport] block names shall not use consecutive underscores.
Custom Parameter

Not Applicable
Example — Incorrect

2-21
2 Naming Conventions

Sub ID f

[Inport] and [Outport] block names shall not consist solely of a single reserved MATLAB word.
Custom Parameter

Not Applicable
Example — Incorrect

Rationale
Sub IDs a, b:

• Deviation from the rule can make it difficult to maintain the integrity of the model and code.

Sub IDs c, e:

• Readability is impaired.

Sub IDs d:

• Readability is impaired.
• Underscores can be used to separate words. However, they are typically used as word breaks and
can cause misunderstanding in the description.

Sub IDs f:

• Readability is impaired.
• Deviation from the rule can cause unexpected issues.

Verification
Model Advisor check: “Check port block names” (Simulink Check)

Last Changed
R2020a

See Also
• “Reserved Keywords” (Embedded Coder)
• “Reserved Identifiers and Code Replacement” (Embedded Coder)

Version History
Introduced in R2020a

2-22
jc_0243: Length restriction for subsystem names

jc_0243: Length restriction for subsystem names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Structural subsystem name length shall be a maximum of 63 characters.


Custom Parameter

Maximum subsystem name length

Rationale
Sub ID a:

• Code generation may not be possible.

Verification
Model Advisor check: “Check length of subsystem names” (Simulink Check)

Last Changed
R2020a

See Also
• “Explore Types of Subsystems”

2-23
2 Naming Conventions

Version History
Introduced in R2020a

2-24
jc_0247: Length restriction for block names

jc_0247: Length restriction for block names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Basic block name length shall be a maximum of 63 characters.


Exception

Inport and Outport blocks


Custom Parameter

Maximum block name length

Rationale
Sub ID a:

• Code generation may not be possible.

Verification
Model Advisor check: “Check length of block names” (Simulink Check)

Last Changed
R2020a

2-25
2 Naming Conventions

Version History
Introduced in R2020a

2-26
jc_0244: Length restriction for Inport and Outport names

jc_0244: Length restriction for Inport and Outport


names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Inport and Outport block name length shall be a maximum of 63 characters.


Custom Parameter

Maximum Inport block name length

Maximum Outport block name length

Rationale
Sub ID a:

• Code generation may not be possible.

Verification
Model Advisor check: “Check length of Inport and Outport names” (Simulink Check)

Last Changed
R2020a

2-27
2 Naming Conventions

Version History
Introduced in R2020a

2-28
jc_0222: Usable characters for signal and bus names

jc_0222: Usable characters for signal and bus


names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d, e, f
• JMAAB — a, b, c, d, e, f

MATLAB Versions
All

Rule
Sub ID a

Only these character types shall be used in signal and bus names:

• Single-byte alphanumeric characters (a-z, A-Z, 0-9)


• Single-byte underscore (_)

Line breaks, single-byte spaces, double-byte characters, and control characters shall not be used.
Custom Parameter

Not Applicable

Sub ID b

Signal and bus names shall not use numbers at the beginning.
Custom Parameter

Not Applicable

Sub ID c

The signal or bus name shall not use underscores at the beginning.
Custom Parameter

Not Applicable

2-29
2 Naming Conventions

Sub ID d

Signal and bus names shall not use underscores at the end.
Custom Parameter

Not Applicable

Sub ID e

Signal and bus names shall not use consecutive underscores.


Custom Parameter

Not Applicable

Sub ID f

Signal and bus names shall not consist solely of a single reserved MATLAB word.
Custom Parameter

Not Applicable

Rationale
Sub IDs a, b:

• Deviation from the rule can make it difficult to maintain the integrity of the model and code.

Sub IDs c, e:

• Readability is impaired.

Sub IDs d:

• Readability is impaired.
• Underscores can be used to separate words. However, they are typically used as word breaks and
can cause misunderstanding in the description.

Sub IDs f:

• Readability is impaired.
• Deviation from the rule can cause unexpected issues.

Verification
Model Advisor check: “Check usable characters for signal names and bus names” (Simulink Check)

Last Changed
R2020a

2-30
jc_0222: Usable characters for signal and bus names

See Also
• “Reserved Keywords” (Embedded Coder)
• “Reserved Identifiers and Code Replacement” (Embedded Coder)
• “Signal Basics”
• “Simulink Bus Capabilities”

Version History
Introduced in R2020a

2-31
2 Naming Conventions

jc_0232: Usable characters for parameter names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

The parameter name shall not use underscores at the end.


Custom Parameter

Not Applicable

Sub ID b

The parameter name shall not use consecutive underscores.


Custom Parameter

Not Applicable

Sub ID c

The parameter name shall not consist solely of a single reserved MATLAB word.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Readability is impaired.
• Underscores can be used to separate words. However, they are typically used as word breaks and
can cause misunderstanding in the description.

2-32
jc_0232: Usable characters for parameter names

Sub ID b:

• Readability is impaired.

Sub ID c:

• Readability is impaired. Deviation from the rule can cause unexpected issues.

Verification
Model Advisor check: “Check usable characters for parameter names” (Simulink Check)

Last Changed
R2024b

See Also
• “Reserved Keywords” (Embedded Coder)
• “Reserved Identifiers and Code Replacement” (Embedded Coder)

Version History
Introduced in R2020a

2-33
2 Naming Conventions

jc_0245: Length restriction for signal and bus


names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Signal and bus name length shall be a maximum of 63 characters.


Custom Parameter

Maximum signal name length

Maximum bus name length


Example — Correct

Signal name length is less than 63 characters.

The length of the hierarchical signal name (full path)


bus_all.bus_name_finla.bus_name2.abcdefghijklmn is less than or equal to 63 characters.

2-34
jc_0245: Length restriction for signal and bus names

Rationale
Sub ID a:

• Code generation may not be possible.

Verification
Model Advisor check: “Check length of signal and bus names” (Simulink Check)

Last Changed
R2020a

See Also
• “Model Configuration Parameters”
• “Signal Basics”
• “Simulink Bus Capabilities”

Version History
Introduced in R2020a

2-35
2 Naming Conventions

jc_0246: Length restriction for parameter name

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Parameter name length shall be a maximum of 63 characters.


Custom Parameter

Maximum parameter name length

Rationale
Sub ID a:

• Code generation may not be possible.

Verification
Model Advisor check: “Check length of parameter names” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

2-36
jc_0795: Usable characters for Stateflow data names

jc_0795: Usable characters for Stateflow data


names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d
• JMAAB — a, b, c, d

MATLAB Versions
All

Rule
Sub ID a

Stateflow data {name} shall not use underscores at the beginning.


Custom Parameter

Not Applicable

Sub ID b

Stateflow data {name} shall not use underscores at the end.


Custom Parameter

Not Applicable

Sub ID c

Stateflow data {name} shall not use consecutive underscores.


Custom Parameter

Not Applicable

Sub ID d

Stateflow data {name} shall not consist solely of a single reserved MATLAB word.

2-37
2 Naming Conventions

Custom Parameter

Not Applicable

Rationale
Sub IDs a, b, c, d:

• Readability is impaired.
• Deviation from the rule may result in unintended code behavior.

Verification
Model Advisor check: “Check usable characters for Stateflow data names” (Simulink Check)

Last Changed
R2020a

See Also
• “Add Stateflow Data” (Stateflow)
• “Set Data Properties” (Stateflow)

Version History
Introduced in R2020a

2-38
jc_0796: Length restriction for Stateflow data names

jc_0796: Length restriction for Stateflow data


names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d
• JMAAB — a, b, c, d

MATLAB Versions
All

Rule
Sub ID a

Stateflow data {name} shall be a maximum of 63 characters.

Custom Parameter

Stateflow data name character limit

Rationale
Sub ID a:

• Readability is impaired.
• Deviation from the rule can result in unintended code behavior

Verification
Model Advisor check: “Check length of Stateflow data name” (Simulink Check)

Last Changed
R2020a

2-39
2 Naming Conventions

See Also
• “Add Stateflow Data” (Stateflow)
• “Set Data Properties” (Stateflow)

Version History
Introduced in R2020a

2-40
jc_0791: Duplicate data name definitions

jc_0791: Duplicate data name definitions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

Data name definitions shall not be duplicated in the base workspace and model workspace.
Custom Parameter

Not Applicable

Sub ID b

Data names shall not be duplicated in the base workspace and data dictionary (sldd).
Custom Parameter

Types of data dictionary

Sub ID c

Data name definitions shall not be duplicated in the model workspace and data dictionary (sldd).
Custom Parameter

Types of data dictionary

Rationale
Sub IDs a, b, c:

• Duplicated data name can cause unintended model behavior.

2-41
2 Naming Conventions

Verification
Model Advisor check: “Check duplication of Simulink data names” (Simulink Check)

Last Changed
R2020a

See Also
• “Set Data Properties” (Stateflow)
• “Add Stateflow Data” (Stateflow)
• “Model Reference Data Storage”

Version History
Introduced in R2020a

2-42
jc_0792: Unused Data

jc_0792: Unused Data

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

The data dictionary (sldd) shall define only the data that is used in the Simulink or Stateflow Coder™
model.
Custom Parameter

Types of data dictionary

Sub ID b

The model workspace shall define only the data that is used in the Simulink or Stateflow model.
Custom Parameter

Not Applicable

Rationale
Sub IDs a, b:

• Unused data can affect maintainability and operability.

Verification
Model Advisor check: “Check unused data in Simulink Model” (Simulink Check)

2-43
2 Naming Conventions

Last Changed
R2020a

See Also
• “Model Reference Data Storage”

Version History
Introduced in R2020a

2-44
jc_0700: Unused data in Stateflow block

jc_0700: Unused data in Stateflow block

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Configuration parameter Unused data, events, messages, and functions shall be set to Warning
or Error to prevent unused Stateflow data, events, and messages in the Stateflow block.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Unused data is defined.

2-45
2 Naming Conventions

Rationale
Sub ID a:

• Unused data and events in the Stateflow block can affect maintainability and reusability.
• Affects code as a declarative statement concerning unused data is inserted into the generated
code.

Verification
Model Advisor check: “Check for unused data in Stateflow Charts” (Simulink Check)

Last Changed
R2020a

See Also
• “Data, Events, and Messages” (Stateflow)
• “View Differences Between Stateflow Messages, Events, and Data” (Stateflow)
• “Manage Symbols in the Stateflow Editor” (Stateflow)

Version History
Introduced in R2020a

2-46
na_0019: Restricted variable names

na_0019: Restricted variable names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

Reserved C variable names shall not be used as variable names in MATLAB code. For example, avoid
using const, TRUE, FALSE, infinity, nil, double, single, or enum in MATLAB code.
Custom Parameter

Not Applicable

Sub ID b

Variable names that conflict with MATLAB functions, such as conv, shall not be used.
Custom Parameter

Not Applicable

Rationale
Sub IDs a, b:

• Improves readability of the code


• Code generation may not be possible.

Verification
Model Advisor check: “Check usage of restricted variable names” (Simulink Check)

2-47
2 Naming Conventions

Last Changed
R2020a

See Also
• “Reserved Keywords” (Embedded Coder)
• “Reserved Identifiers and Code Replacement” (Embedded Coder)
• “Integrate MATLAB Functions in a Stateflow Charts” (Stateflow)
• “Implement MATLAB Functions in Simulink with MATLAB Function Blocks”

Version History
Introduced in R2020a

2-48
3

Simulink

• “Configuration Parameters” on page 3-2


• “Diagram Appearance” on page 3-12
• “Signal” on page 3-68
• “Conditional Subsystem Relations” on page 3-103
• “Operation Blocks” on page 3-125
• “Other Blocks” on page 3-174
3 Simulink

Configuration Parameters

3-2
jc_0011: Optimization parameters for Boolean data types

jc_0011: Optimization parameters for Boolean data


types

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Configuration parameter Implement logic signals as Boolean data (vs. double) shall be selected
so that optimization parameters are activated for logic signals.

Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Using Boolean data can reduce RAM capacity when using C code.

Verification
Model Advisor check: “Check Implement logic signals as Boolean data (vs. double)” (Simulink Check)

Last Changed
R2020a

3-3
3 Simulink

See Also
• “Signal Basics”

Version History
Introduced in R2020a

3-4
jc_0642: Integer rounding mode setting

jc_0642: Integer rounding mode setting

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When block parameter Integer rounding mode is set to Simplest, configuration parameter
Production hardware signed integer division rounds to shall be set to Floor or Zero.
Custom Parameter

Not Applicable
Example — Correct

Block parameter Integer rounding mode is set to Simplest and configuration parameter
Production hardware signed integer division rounds to is set to Zero.

3-5
3 Simulink

Example — Incorrect

Configuration parameter Production hardware signed integer division rounds to is set to


Undefined when block parameter Integer rounding mode is set to Simplest.

3-6
jc_0642: Integer rounding mode setting

Rationale
Sub ID a:

• Prevents unintended rounding of divided signed integers.

Verification
Model Advisor check: “Check Signed Integer Division Rounding mode” (Simulink Check)

Last Changed
R2024b

See Also
• Signed integer division rounds to

Version History
Introduced in R2020a

3-7
3 Simulink

jc_0806: Detecting incorrect calculation results

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

Configuration parameter Division by singular matrix shall be set to Error.


Custom Parameter

Not Applicable

Sub ID b

Configuration parameter Inf or NaN block output shall be set to Error.


Custom Parameter

Not Applicable

Sub ID c

(R2014b and later) These configuration parameters shall be set to Error:

• Wrap on overflow
• Saturate on overflow

(R2010b to R2014a) Configuration parameter Detect overflow shall be set to Error.


Custom Parameter

Not Applicable

3-8
jc_0806: Detecting incorrect calculation results

Rationale
Sub IDs a, b, c:

• Allows detection of operations with invalid values.

Verification
Model Advisor check: “Check diagnostic settings for incorrect calculation results” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-9
3 Simulink

jc_0021: Model diagnostic settings

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

These configuration parameters shall be set to warning or error:

• Algebraic loop
• Minimize algebraic loop
• “Multitask data transfer”
• “Inf or NaN block output”
• “Duplicate data store names”
• Unconnected block input ports
• Unconnected block output ports
• Unconnected line
• Unspecified bus object at root Outport block
• Element name mismatch
• (R2017a and earlier) Mux blocks used to create bus signals
• (R2012a and earlier) Invalid function-call connection

Custom Parameter

Not Applicable

Rationale
Sub ID a:

3-10
jc_0021: Model diagnostic settings

• Improves model workflow.


• Code generation may not be possible

Verification
Model Advisor check “Check model diagnostic parameters” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-11
3 Simulink

Diagram Appearance

3-12
na_0004: Simulink model appearance settings

na_0004: Simulink model appearance settings

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Simulink model appearance settings shall conform with the project settings.
Custom Parameter

Display option
Example — View Options

On the Simulink toolstrip, these parameters are available in the Modeling tab, under Environment.

Parameter Setting
Model Browser Deselect Model Browser.
Status Bar Select Status Bar.
Toolstrip Select Toolstrip.
Zoom Select Zoom (Normal View 100%).

Example — Block Display Options

On the Simulink toolstrip, these parameters are available in the Debug tab, under Information
Overlays.

Parameter Setting
Library Links Select Hide All Links.
Linearization Indicators Select Linearization Indicators.

3-13
3 Simulink

Parameter Setting
Ref. Model I/O Mismatch Deselect Ref. Model I/O Mismatch.
Ref. Model Version Deselect Ref. Model Version.
Sample Time Colors Deselect Colors.
Execution Order Deselect Execution Order.

Example — Block Color Options

On the Simulink toolstrip, these parameters are available in the Format tab.

Parameter Setting
Background color Select white option from the Background list.
Foreground color Select black option from the Foreground list.

Example — Storage Class Indicators

To access the parameter below, On the Simulink toolstrip, open Simulink Coder from Apps, select C
Code tab and choose Code Interface.

Parameter Setting
Storage Class Indicator Deselect Storage Class Indicator.

Example — Signal Display Options

On the Simulink toolstrip, these parameters are available in the Debug tab, under Information
Overlays.

Parameter Setting
Base Data Types Deselect Base Data Types.
Alias Data Types Deselect Alias Data Types.
Signal Dimensions Deselect Signal Dimensions.
Testpoint Select Test Point.
Logging and Viewer indicators Select Logging & Viewers.
Nonscalar Signals Select Nonscalar Signals.

Rationale
Sub ID a:

• Standard model appearance improves readability.

Verification
Model Advisor check: “Check for Simulink diagrams using nonstandard display attributes” (Simulink
Check)

3-14
na_0004: Simulink model appearance settings

Last Changed
R2020a

See Also
• MISRA AC SLSF 023A
• “Mapping from Simulink Editor to the Simulink Toolstrip”

Version History
Introduced in R2020a

3-15
3 Simulink

db_0043: Model font and font size

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d
• JMAAB — a, b, c, d

MATLAB Versions
All

Rule
Sub ID a

Block name font and font style shall conform with the project settings.

Signal name font and font style shall conform with the project settings.
Custom Parameter

Font

Font style

Sub ID b

Block name font size shall conform with the project settings.

Signal name font size shall conform with the project settings
Custom Parameter

Font size

Sub ID c

State labels and box name font and font style shall conform with the project settings.

Transition labels and comment font and font style shall conform with the project settings.
Custom Parameter

Font

3-16
db_0043: Model font and font size

Font style

Sub ID d

State labels and box name font size shall conform with the project settings.

Transition labels and comment font size shall conform with the project settings.
Custom Parameter

Font size

Rationale
Sub IDs a, c:

• Standard fonts improve readability.

Sub IDs b, d:

• Standard font size improves readability.

Verification
Model Advisor check: “Check model font settings” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-17
3 Simulink

jm_0002: Block resizing

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Blocks shall be sized so that the block icon is visible and recognizable.

Custom Parameter

Not Applicable

Example — Correct

The block icon is visible and recognizable.

Example — Incorrect

The block is too small so the icon is neither visible nor recognizable.

3-18
jm_0002: Block resizing

Rationale
Sub ID a:

• When a block is too small, the text and symbol displayed by the icon can be difficult to see, which
impairs readability.

Verification
Adherence to this modeling guideline cannot be verified by using a Model Advisor check.

Last Changed
R2020a

See Also
• “Configure Model Layout”

Version History
Introduced in R2020a

3-19
3 Simulink

db_0142: Position of block names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The block name shall be positioned below the block.


Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

3-20
db_0142: Position of block names

Rationale
Sub ID a:

• Consistent placement of the block name improves model readability because it is easier to
determine which name corresponds to the block.

Verification
Model Advisor check: “Check whether block names appear below blocks” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-21
3 Simulink

jc_0061: Display of block names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Block names shall be hidden for blocks that meet either of these criteria:

• Block type is evident from its visual appearance


• Uses the default block name (including instances where only a number has been added at the end)

For blocks that do not meet the criteria, their name shall be displayed.
Custom Parameter

Blocks with a clear type due their appearance


Example — Displayed block names

3-22
jc_0061: Display of block names

Example — Hidden block names

Rationale
Sub ID a:

• Improves model readability.

Verification
Model Advisor check: “Check the display attributes of block names” (Simulink Check)

Last Changed
R2020a

See Also
• MISRA AC SLSF 026A

Version History
Introduced in R2020a

3-23
3 Simulink

db_0140: Display of block parameters

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Block annotation shall display block parameters that are defined by the project.
Custom Parameter

Block parameters
Example — Correct

Example — Incorrect

3-24
db_0140: Display of block parameters

Rationale
Sub ID a:

• Readability improves when block parameters are displayed.

Verification
Model Advisor check: “Check for display of block parameter” (Simulink Check)

Last Changed
R2020a

See Also
• MISRA AC SLSF 026E
• “Set Block Annotation Properties”

Version History
Introduced in R2020a

3-25
3 Simulink

jc_0603: Model description

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

The model layer shall include a description of the layer.

Layers that require a description are defined (by function and layer type) in the project.
Custom Parameter

Description object (block type, etc.)

Layer being described


Example — Correct

Model layer includes description [Requirement].

Sub ID b

The format of the layer description shall be consistent in the model.

3-26
jc_0603: Model description

Custom Parameter

Model description format

Rationale
Sub ID a:

• When a description is not included, the readability of the control specifications is reduced.
Usability, maintainability, and portability also decreases.

Sub ID b:

• Readability is impaired when the description format is not consistent.

Verification
Model Advisor check: “Check Model Description” (Simulink Check)

Last Changed
R2020a

See Also
• Sub ID a and b, see MISRA AC SLSF 022

Version History
Introduced in R2020a

3-27
3 Simulink

jc_0604: Using block shadow

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Block format property Shadow (DropShadow) shall not be selected.


Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Blocks have a drop shadow.

3-28
jc_0604: Using block shadow

Rationale
Sub ID a:

• Difficult to determine if a port exists because it is hidden by the shading, which impairs
readability.

Verification
Model Advisor check: “Check if blocks are shaded in the model” (Simulink Check)

Last Changed
R2020a

See Also
• “Common Block Properties”
• “Set Block Parameter Values”

Version History
Introduced in R2020a

3-29
3 Simulink

db_0081: Unconnected signals and blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

The model shall not have signal lines that are not connected.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

3-30
db_0081: Unconnected signals and blocks

Sub ID b

The model shall not have subsystems or basic blocks that are not connected.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Rationale
Sub IDs a, b:

• Unconnected lines can have adverse effects, such as simulation errors or failure to generate code.

Verification
Model Advisor check: “Check for unconnected signal lines and blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Signal Basics”
• “Explore Types of Subsystems”

3-31
3 Simulink

Version History
Introduced in R2020a

3-32
db_0032: Signal line connections

db_0032: Signal line connections

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

Signal lines shall not split into more than two sub lines at a single branching point.
Custom Parameter

Not Applicable
Example — Correct

3-33
3 Simulink

Example — Incorrect

Sub ID b

Signal lines shall be resized vertically or horizontally as required for the model layout.

Custom Parameter

Not Applicable

Sub ID c

Signal lines shall not bend multiple times unnecessarily.

Custom Parameter

Not Applicable

Example — Correct

3-34
db_0032: Signal line connections

Example — Incorrect

Rationale
Sub ID a:

• Difficult to understand the relationships between blocks.

Sub ID b:

• Consistent application of signal lines improves readability.

Sub ID c:

• Deviation from the rules can impair readability.

Verification
Model Advisor check: “Check signal line connections” (Simulink Check)

Last Changed
R2024b

See Also
• “Signal Basics”

3-35
3 Simulink

Version History
Introduced in R2020a

3-36
db_0141: Signal flow in Simulink models

db_0141: Signal flow in Simulink models

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Signals shall flow from left to right.


Exception

Feedback loops can flow from right to left.


Custom Parameter

Not Applicable

3-37
3 Simulink

Example — Correct

3-38
db_0141: Signal flow in Simulink models

Example — Incorrect

Sub ID b

Parallel blocks or subsystems shall be arranged from top to bottom.


Custom Parameter

Not Applicable

3-39
3 Simulink

Example — Correct

Example — Incorrect

Rationale
Sub IDs a, b:

• Deviation from the rules can impair readability.

Verification
Model Advisor check: “Check signal flow in model” (Simulink Check)

Last Changed
R2024b

3-40
db_0141: Signal flow in Simulink models

See Also
• “Signal Basics”
• “Explore Types of Subsystems”

Version History
Introduced in R2020a

3-41
3 Simulink

jc_0110: Direction of block

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Blocks shall be arranged so the output is to the right.


Exception

When a Delay is used in a feedback loop, the output can be to the left.
Custom Parameter

Not Applicable
Example — Correct

The model is arranged so that the output is to the right. The output of the Delay block is to the left.

3-42
jc_0110: Direction of block

Example — Incorrect

The block is arranged so the output is to the left.

Rationale
Sub ID a:

• Signal flow can be difficult to understand if the direction of the signals is not consistent.

Verification
Model Advisor check: “Check block orientation” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-43
3 Simulink

jc_0171: Clarification of connections between


structural subsystems

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

A minimum of one signal line shall connect two structural subsystems.

When a two-way signal connection exists between two structural subsystems (A and B), each
direction shall be connected to at least one signal line.
Exception

Using Goto and From blocks to create buses or connect signals to a Merge block.
Custom Parameter

Not Applicable

3-44
jc_0171: Clarification of connections between structural subsystems

Example — Correct

Example — Incorrect

Sub ID b

Signals that are not used within a structural subsystem shall be input to a structural subsystem.
These signals shall not be output to other structural subsystems or basic blocks.

Custom Parameter

Not Applicable

3-45
3 Simulink

Example — Correct

Example — Incorrect

Signals that are not used in the subsystem are connected to avoid crossing of signal lines.

3-46
jc_0171: Clarification of connections between structural subsystems

Rationale
Sub ID a:

• Clarifies structural subsystem connections and execution order.

Sub ID b:

• Eliminating unnecessary connections clarifies the relationship between connections.


• Deviation from the rule can cause to confusion due to unused input/output signals.

Verification
Model Advisor check: “Check connections between structural subsystems” (Simulink Check)

Last Changed
R2020a

3-47
3 Simulink

See Also
• “Signal Basics”
• “Explore Types of Subsystems”

Version History
Introduced in R2020a

3-48
jc_0602: Consistency in model element names

jc_0602: Consistency in model element names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

These names shall match when they are directly connected by using signal lines.

• Inport block name


• Outport block name
• Structural subsystem input port label name
• Structural subsystem output port label name
• From block tag name
• Goto block tag name
• Signal line signal name

Exceptions

A signal line that connects to one of the following subsystem types can have a name that differs from
that of the subsystem port label:

• Subsystems linked to a library


• Reusable subsystems

When a combination of Inport, Outport, and other blocks have the same name, use a suffix or prefix
for the Inport and Outport blocks. Any prefix or suffix can be used for ports, but they must be
consistent. For example, the Inport block uses “in” and Outport block uses “out”.

Note Inport and Outport blocks must have different names and signal names.

3-49
3 Simulink

Custom Parameter

Not Applicable
Example — Correct

Names of model elements that connect directly to signal lines are consistent.

Example — Incorrect

Inconsistent names for model elements that connect directly to signal lines.

Rationale
Sub ID a:

• Prevent misconnected signal lines.


• Readability is impaired.
• Deviation from the rule can make it difficult to maintain the integrity of the model and code.

Verification
Model Advisor check: “Check for consistency in model element names” (Simulink Check)

Last Changed
R2020a

See Also
• “Manage Signal Lines”

3-50
jc_0602: Consistency in model element names

• “Explore Types of Subsystems”

Version History
Introduced in R2020a

3-51
3 Simulink

jc_0281: Trigger signal names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a1/a2/a3/a4, b1/b2/b3/b4

MATLAB Versions
All

Rule
Sub ID a1

The name of the conditional input block at the destination shall include the name of the block at the
origin of the trigger signal
Custom Parameter

Not Applicable
Example — Correct

3-52
jc_0281: Trigger signal names

Example — Incorrect

Sub ID a2

The name of the conditional subsystem at the destination shall include the name of the block at the
origin of the trigger signal.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Sub ID a3

The name of the conditional input block at the destination shall include the name of the trigger
signal.
Custom Parameter

Not Applicable

3-53
3 Simulink

Example — Correct

Example — Incorrect

Sub ID a4

The name of the conditional subsystem at the destination shall include the name of the trigger signal.
Custom Parameter

Not Applicable
Example — Correct

3-54
jc_0281: Trigger signal names

Example — Incorrect

Sub ID b1

The name of the Stateflow block event at the destination shall include the name of the block at the
origin of the trigger signal.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

3-55
3 Simulink

Sub ID b2

The name of Stateflow Chart at the destination shall include the name of the block at the origin of the
trigger signal.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Sub ID b3

The name of the Stateflow block event at the destination shall include the name of the trigger signal.
Custom Parameter

Not Applicable

3-56
jc_0281: Trigger signal names

Example — Correct

Example — Incorrect

Sub ID b4

The name of the trigger signal and the Stateflow Chart name at the destination must include the
same name. The name of the Chart block at the destination shall include the name of the trigger
signal.
Custom Parameter

Not Applicable
Example — Correct

3-57
3 Simulink

Example — Incorrect

Rationale
Sub ID a1, a2, a3, a4, b1, b2, b3, b4:

• Reduces connection mistakes.


• Increases understanding of the relationship between the origin of the trigger signal and the
destination.

Verification
Model Advisor check: “Check trigger signal names” (Simulink Check)

Last Changed
R2020a

See Also
• Sub ID a1, a2, a3, a4, see MISRA AC SLSF 026C
• “Signal Basics”
• “Use Events to Execute Charts” (Stateflow)
• “Explore Types of Subsystems”

Version History
Introduced in R2020a

3-58
db_0143: Usable block types in model hierarchy

db_0143: Usable block types in model hierarchy

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Model levels shall use only the block types that are defined for the layer type. Clearly defined layer
types restrict the number of blocks that can be used.

Block restrictions:

• (R2011a and earlier) Enable block cannot be used at the root level of the model.
• Action ports are not permitted at the root level of a model.

Layer restrictions:

• Data flow layers that are used for basic blocks only.
• Other than data flow layers, layers can include blocks that are used for structural subsystems and
all other layers.

Blocks that can be used for all layers include:

• Inport
• Outport
• Mux
• Demux
• Bus Selector
• Bus Creator
• Selector
• Ground

3-59
3 Simulink

• Terminator
• From
• Goto
• Merge
• Unit Delay
• Rate Transition
• Data Type Conversion
• Data Store Memory
• If
• Switch Case
• Function-Call Generator
• Function-Call Split
• Inport Shadow

Custom Parameter

Layer type

Block type

Rationale
Sub ID a:

• Readability is impaired when subsystems and basic blocks are used in the same layer.

Verification
Model Advisor check: “Check for mixing basic blocks and subsystems” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-60
db_0144: Use of subsystems

db_0144: Use of subsystems

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Blocks in a Simulink diagram shall be grouped together into subsystems based on functional
decomposition of the algorithm, or portion thereof, represented in the diagram. Blocks can also be
grouped together based on behavioral variants or timing.

Avoid grouping blocks into subsystems primarily for the purpose of saving space in the diagram. Each
subsystem in the diagram should represent a unit of functionality that is required to accomplish the
purpose of the model or submodel.

When implementing a subsystem to alleviate readability issues, use a virtual subsystem.


Custom Parameter

Not Applicable
Example — Correct

Subsystems are divided by functional unit.

3-61
3 Simulink

Example — Incorrect

Subsystems are not divided by functional unit.

Sub ID b

A virtual subsystem shall be used when processing order and code generation does not need to be
taken into consideration.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

3-62
db_0144: Use of subsystems

• Avoid grouping blocks into subsystems primarily for the purpose of saving space in the diagram.
• It can be difficult to reuse the subsystem.

Sub ID b:

• As atomic subsystems are considered a single process that influences processing order and code
optimization, they can be misinterpreted when used other than as intended.

Verification
Adherence to this modeling guideline cannot be verified by using a Model Advisor check.

Last Changed
R2020a

See Also
• Subsystem

Version History
Introduced in R2020a

3-63
3 Simulink

jc_0653: Delay block layout in feedback loops

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Delay block in feedback loops across subsystems shall reside in the hierarchy that describes the
feedback loop.
Custom Parameter

Not Applicable
Example — Correct

Delay block resides in the hierarchy that describes the feedback loop.

3-64
jc_0653: Delay block layout in feedback loops

Example — Incorrect

Delay block resides in a subsystem that is nested within the hierarchy which describes the feedback
loop.

Rationale
Sub ID a:

• Prevents double placement of the Delay block.


• Clarifying the extent of diversion improves reusability.
• Improves testability; it is difficult to test a subsystem that contains a Delay block on its own
because past values cannot be entered directly.

Verification
Model Advisor check: “Check for avoiding algebraic loops between subsystems” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-65
3 Simulink

hd_0001: Prohibited Simulink sinks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

Control algorithm models shall be designed from discrete blocks.

Scope and Display blocks can be used in the model diagram.

These sink blocks shall not be used:

• To File
• To Workspace
• Stop Simulation

Consider using signal logging and the Viewers and Generators Manager for data logging and viewing
requirements. (R2019b and later) To log and manage the signal, click the Simulation tab and, under
the Prepare gallery, select the appropriate tool.
Custom Parameter

Not Applicable

Rationale
Sub ID a

• Improves readability and model simulation.


• Code generation may not be possible.

3-66
hd_0001: Prohibited Simulink sinks

Verification
Model Advisor check: “Check for prohibited sink blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Viewers and Generators Manager”

Version History
Introduced in R2020a

3-67
3 Simulink

Signal

3-68
na_0010: Usage of vector and bus signals

na_0010: Usage of vector and bus signals

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a, b, c, d

MATLAB Versions
All

Rule
Sub ID a

Mux and Demux blocks shall be used when generating and decomposing vectors.
Custom Parameter

Not Applicable

Sub ID b

Mux block inputs shall be scalars and vectors.


Custom Parameter

Not Applicable

Sub ID c

Bus Creator and Bus Selector blocks shall be used when generating and decomposing buses.
Custom Parameter

Not Applicable

Sub ID d

Buses shall connect to blocks that support buses.


Custom Parameter

Not Applicable

3-69
3 Simulink

Rationale
Sub IDs a, b, c, d:

• Prevents issues that are caused by combining vector and bus signals.

Verification
Model Advisor check: “Check usage of vector and bus signals” (Simulink Check)

Last Changed
R2021a

See Also
• “Signal Basics”
• “Signal Types”
• “Specify Bus Properties with Bus Objects”
• “Bus-Capable Blocks”

Version History
Introduced in R2020a

3-70
jc_0008: Definition of signal names

jc_0008: Definition of signal names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Signal names shall be defined for signal lines that output from important blocks. The signal name
shall be provided once, at the origin of the signal line.

A label shall be used to display defined signal names.

Note An important block is defined by the system input and output of meaningful results, not by its
type.

Custom Parameter

Definition of an important block


Example — Correct

3-71
3 Simulink

Example — Incorrect

Rationale
Sub ID a:

• Defining the signal name and displaying the label for the output of meaningful results from
important blocks improves the readability of the model.

Verification
Model Advisor check: “Check definition of signal labels” (Simulink Check)

Last Changed
R2020a

See Also
• “Signal Basics”
• “Explore Types of Subsystems”

Version History
Introduced in R2020a

3-72
jc_0009: Signal name propagation

jc_0009: Signal name propagation

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

When defining the signal name for a signal that extends across a hierarchy, signal property Show
propagated signals shall be selected so that propagated signal names are displayed.

However, when one of the following conditions is met, do not select Show propagated signals:

• In a subsystem with a library


• In subsystems where reusable functions are set

Custom Parameter

Not Applicable
Example — Correct

Propagated signal names are displayed.

3-73
3 Simulink

Example — Incorrect

Show propagated signals is not selected, therefore signal names are not displayed.

Signals that connect to Bus Creator and Outport blocks do not have names, but Show propagated
signals is selected for signals that connect to Subsystem and Outport blocks.

3-74
jc_0009: Signal name propagation

Signals that connect to Bus Creator and Outport blocks have names, but signals that connect to
Subsystem and Outport blocks also have names.

Sub ID b

Signal property Show propagated signals shall be selected for these blocks so that propagated
signal names of the signal output are displayed:

• From
• Signal Specification
• Function-Call Split[

Custom Parameter

Not Applicable
Example — Correct

Propagated signal names are displayed.

3-75
3 Simulink

Signals that connect to Inport and Goto blocks do not have names, therefore Show propagated
signals does not need to be selected.

3-76
jc_0009: Signal name propagation

Signals that connect to Inport and Goto blocks do not have names, therefore signals that connect to
From and Gain blocks can be left unnamed.

Example — Incorrect

Signals that connect to Inport and Goto blocks do not have names, but Show propagated signals is
selected for signals that connect to From and Gain blocks.

Regardless of whether signals are propagated, Show propagated signals is not selected

Signals that connect to Inport and Goto blocks have names, but signals that connect to From and
Gain blocks are named.

3-77
3 Simulink

Signals that connect to Gain and Signal Specification blocks do not have names, but Show
propagated signals is selected for signals that connect to Signal Specification and Outport blocks.

Regardless of whether signals are propagated, Show propagated signals is not selected.

Signals that connect to Gain and Signal Specification blocks have names, but signals that connect to
Signal Specification and Outport blocks also have names.

Signals that connect to Function-Call Generator and Function-Call Split blocks do not have names,
but Show propagated signals is selected for signals that connect to Function-Call Split and
Function-Call Subsystem blocks.

Regardless of whether signals are propagated, Show propagated signals is not selected.

3-78
jc_0009: Signal name propagation

Signals that connect to Function-Call Generator and Function-Call Split blocks have names and
signals that connect to Function-Call Split and Function-Call Subsystem blocks are also named.

Sub ID c

When propagated signal names does not exist Show propagated signals shall not be selected.
Example — Incorrect

Signals that connect to Bus Creator and Outport blocks do not have names, but Show propagated
signals is selected for signals that connect to Subsystem and Outport blocks.

The Subsystem block is propagated empty.

Rationale
Sub IDs a, b:

3-79
3 Simulink

• Prevents signal line connection errors.


• Prevents incorrect naming of signal lines.

Sub ID c:

• Standardizing the style of writing enhances readability.

Verification
Model Advisor check: “Check signal name propagation” (Simulink Check)

Last Changed
R2024b

See Also
• “Signal Basics”
• “Explore Types of Subsystems”

Version History
Introduced in R2020a

3-80
db_0097: Position of labels for signals and buses

db_0097: Position of labels for signals and buses

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Signal line labels and bus labels shall be positioned below signal lines.

Custom Parameter

Not Applicable

Example — Correct

Signal line labels and bus labels are below signal lines.

Example — Incorrect

Signal line labels and bus labels are above the signal line.

3-81
3 Simulink

Sub ID b

Signal line labels and bus labels shall be positioned at the origin of the connection.
Custom Parameter

Not Applicable
Example — Correct

Signal line labels and bus labels are positioned at the origin of the signal line connection.

Example — Incorrect

Signal line labels and bus labels are positioned at the destination of the signal line connection.

Rationale
Sub ID a, b:

3-82
db_0097: Position of labels for signals and buses

• Consistent label position prevents confusion with corresponding labels, signal lines, and buses,
which improves the readability of the model.

Verification
Model Advisor check: “Check position of signal labels” (Simulink Check)

Last Changed
R2024b

See Also
• “Signal Basics”
• “Signal Lines”
• “Simulink Bus Capabilities”

Version History
Introduced in R2020a

3-83
3 Simulink

na_0008: Display of labels on signals

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

A label shall be displayed on the signal line originating from these blocks:

• Inport
• From (see exception)
• Subsystem or Stateflow Chart (see exception)
• Bus Selector (the tool forces this to happen)
• Demux
• Selector
• Data Store Read (see exception)
• Constant (see exception)

Exception

When the signal label is visible in the originating block icon display, the signal does not need not to
have the label displayed unless the signal label is needed elsewhere due to a destination-based rule.
Custom Parameter

Not Applicable

Sub ID b

A label shall be displayed on a signal line that connects (either directly or by way of a basic block that
performs a non-transformative operation) to these destination blocks:

3-84
na_0008: Display of labels on signals

• Outport
• Goto
• Data Store Write
• Bus Creator
• Mux
• Subsystem
• Stateflow Chart

Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Improves readability, model simulation, and workflow.


• Code generation may not be possible.

Sub ID b:

• Improves readability, model simulation, and workflow.

Verification
Model Advisor check: “Check signal line labels” (Simulink Check)

Last Changed
R2020a

See Also
• “Signal Basics”
• “Manage Signal Lines”
• “Explore Types of Subsystems”

Version History
Introduced in R2020a

3-85
3 Simulink

na_0009: Entry versus propagation of signal labels

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

When a label is displayed for a signal, the following rules define whether that label is created there
(entered directly on the signal) or propagated from its true source (inherited from elsewhere in the
model by using the < character).

Signal labels shall be entered for signals that originate from:

• The Inport block at the root (top) level of a model


• Basic blocks that perform a transformative operation (For the purpose of interpreting this rule
only, the Bus Creator, Mux, and Selector blocks also perform transformative operations.)

Signal labels shall be propagated for signals that originate from:

• Inport block in a nested subsystem


• Basic blocks that perform a non-transformative operation
• Subsystem block or Stateflow Chart block.

Exceptions

When the nested subsystem is a library subsystem, a label can be entered on the signal coming from
the Inport block to accommodate reuse of the library block.

When the connection originates from the output of a library subsystem block, a new label can be
entered on the signal to accommodate readability.
Custom Parameter

Not Applicable

3-86
na_0009: Entry versus propagation of signal labels

Rationale
Sub ID a:

• The result of executing a MATLAB command is reflected in the code, which makes consistency
between the model and code difficult to maintain.

Verification
Model Advisor check: “Check for propagated signal labels” (Simulink Check)

Last Changed
R2020a

See Also
• “Signal Basics”
• “Manage Signal Lines”
• “Signal Label Propagation”
• “Explore Types of Subsystems”

Version History
Introduced in R2020a

3-87
3 Simulink

db_0110: Block parameters

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Block parameters shall not be used to describe:

• Operation expressions
• Data type conversion
• Selection of rows or columns
• MATLAB commands
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Operation expressions, data type conversion, or row or column selection become a magic number
in generated code, which makes consistency between the model and code difficult to maintain.
Adjusting parameters also becomes difficult.
• Describing the calculation formula within the block decreases readability.
• The result of executing a MATLAB command is reflected in the code, which makes consistency
between the model and code difficult to maintain.

Verification
Model Advisor check: “Check usage of tunable parameters in blocks” (Simulink Check)

3-88
db_0110: Block parameters

Last Changed
R2020a

Version History
Introduced in R2020a

3-89
3 Simulink

db_0112: Usage of index

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

Sub ID Recommendations
• NA-MAAB — a1/a2
• JMAAB — a1/a2

MATLAB Versions
All

Rule
Sub ID a1

A vector signal shall use a zero-based index mode.


Custom Parameter

Not Applicable
Example — Correct

A uniform zero-based index mode is used.

3-90
db_0112: Usage of index

Example — Incorrect

A uniform index mode is not used.

Sub ID a2

A vector signal shall use a one-based index mode.


Custom Parameter

Not Applicable
Example — Correct

A uniform one-based index mode is used.

Example — Incorrect

A uniform index mode is not used (same as the incorrect example for sub ID a1).

3-91
3 Simulink

Rationale
Sub IDs a1, a2

• Logic is easier to understand when using a uniform index mode.

Verification
Model Advisor check: “Check Indexing Mode” (Simulink Check)

Last Changed
R2020a

See Also
• Index Vector

Version History
Introduced in R2020a

3-92
jc_0645: Parameter definition for calibration

jc_0645: Parameter definition for calibration

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Block parameters that are targets of calibration shall be defined as named constants. Examples of
parameters that are outside of the calibration target include:

• Initial value parameter 0


• Increment, decrement 1
• Arithmetic expressions
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

3-93
3 Simulink

Rationale
Sub ID a:

• A literal constant in the model will propagate as a literal constant in the generated code, making
calibration impossible.

Verification
Model Advisor check: “Check if tunable block parameters are defined as named constants” (Simulink
Check)

Last Changed
R2020a

See Also
• “Set Block Parameter Values”

Version History
Introduced in R2020a

3-94
jc_0641: Sample time setting

jc_0641: Sample time setting

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Block parameter Sample time shall be set to -1 (inherited).


Exceptions

• Inport block
• Outport block
• Atomic subsystem
• Blocks with state variables, such as Unit Delay and Memory
• Signal conversion blocks, such as Data Type Conversion and Rate Transition
• Blocks that do not have external inputs, such as Constant
• Stateflow charts

Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Discrepancies can occur in the processing of the model because of different simulation times.
• Maintainability of the model deteriorates when a specific sample time is set for each block
individually.

3-95
3 Simulink

Verification
Model Advisor check: “Check for sample time setting” (Simulink Check)

Last Changed
R2020a

See Also
• “What Is Sample Time?”
• “Explore Types of Subsystems”
• “Construct and Run a Stateflow Chart” (Stateflow)

Version History
Introduced in R2020a

3-96
jc_0643: Fixed-point setting

jc_0643: Fixed-point setting

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When block parameter Data type is a set to fixdt (fixed-point) and Scaling is set to Slope and
bias, parameter Bias shall be set to 0.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• When the bias in a model is not uniform:

• Behavior of the model is impossible to determine by its appearance.


• Unintended overflows and underflows occur.
• Results in wasteful operation and deterioration of code efficiency/computing load.

Verification
Model Advisor check: “Check usage of fixed-point data type with non-zero bias” (Simulink Check)

Last Changed
R2020a

3-97
3 Simulink

See Also
• “Specify Fixed-Point Data Types”
• “Specify Data Types Using Data Type Assistant”
• “Scaling, Precision, and Range”

Version History
Introduced in R2020a

3-98
jc_0644: Type setting

jc_0644: Type setting

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The data type shall not be set by using a block or Stateflow data when the data type is set by a data
object.
Exceptions

• Inside a reusable function


• Data Type Conversion block
• Data types set by using fixdt
• Boolean or double types

Custom Parameter

Not Applicable
Example — Correct

Type is set on the data object.

3-99
3 Simulink

Rationale
Sub ID a:

• When the data type is set in a block and it differs from the type setting in the data object, it can be
difficult to determine which setting is correct. This can impair readability.
• When the type is set in the block, maintainability is affected when the signal line type changes.

Exceptions

• When block structures are identical, differences between input/output data type can result in
different C source code that is not reusable. For reusable functions, data types of input/output
blocks should be specified at the subsystem level.
• The Data Type Conversion block is used to explicitly set the data type.
• When the data type is fixdt (fixed-point), data type must be set individually because each block
can have different data points. In this scenario, it is impossible to use only the data object to set
the data type.

3-100
jc_0644: Type setting

• A block with a specific type set by default.

For example, Output data type is set to boolean by default. It is generally expected that the
result of a logical operation boolean, eliminating the need to adjust inheritance settings. Given
that the expected type is preconfigured in blocks set by default in this manner, readability and
maintainability are not compromised.

Example — Correct

Type is set for the data object but not the block.

Example — Incorrect

Type is set for both the data object and the block.

Verification
Model Advisor check: “Check type setting by data objects” (Simulink Check)

Last Changed
R2024b

3-101
3 Simulink

See Also
• “About Data Types in Simulink”
• “Simulink Functions Overview”

Version History
Introduced in R2020a

3-102
Conditional Subsystem Relations

Conditional Subsystem Relations

3-103
3 Simulink

db_0146: Block layout in conditional subsystems

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Conditional input blocks shall be positioned at the top of the subsystem.

Custom Parameter

Not Applicable

Example — Correct

3-104
db_0146: Block layout in conditional subsystems

Example — Incorrect

Sub ID b

The position of these blocks shall be defined by the project:

• For Each
• For Iterator
• While Iterator

Custom Parameter

Location layout

Rationale
Sub IDs a, b:

• Unifying the internal and external layout of the conditional subsystem improves readability of the
model.

Verification
Model Advisor check: “Check position of conditional blocks and iterator blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Conditionally Executed Subsystems Overview”

3-105
3 Simulink

• “Explore Types of Subsystems”

Version History
Introduced in R2020a

3-106
jc_0640: Initial value settings for Outport blocks in conditional subsystems

jc_0640: Initial value settings for Outport blocks in


conditional subsystems

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The initial condition shall be defined on an Outport block when both of these conditions are met for a
conditional subsystem:

• Includes a block with initial conditions (i.e. Constant and Delay blocks)
• Connects to Outport block

When the output signal from a conditional subsystem is connected to a Merge block, the initial
condition shall be defined on the Merge block.
Custom Parameter

Not Applicable
Example — Correct

The initial condition is defined.

3-107
3 Simulink

Example — Incorrect

The initial condition is not defined.

3-108
jc_0640: Initial value settings for Outport blocks in conditional subsystems

Rationale
Sub ID a:

• The model may not behave as intended when the initial condition is unclear.

3-109
3 Simulink

Verification
Model Advisor check: “Check undefined initial output for conditional subsystems” (Simulink Check)

Last Changed
R2020a

See Also
• “Explore Types of Subsystems”
• “Conditionally Executed Subsystems and Models”

Version History
Introduced in R2020a

3-110
jc_0659: Usage restrictions of signal lines input to Merge blocks

jc_0659: Usage restrictions of signal lines input to


Merge blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Only conditional subsystem output signals shall input to Merge blocks.


Custom Parameter

Not Applicable
Example — Correct

3-111
3 Simulink

Example — Incorrect

A Gain block output signal is input to Merge.

Rationale
Sub ID a:

• Prevents the simulation from proceeding as intended.

Verification
Model Advisor check: “Check usage of Merge block” (Simulink Check)

Last Changed
R2020a

See Also
• “Explore Types of Subsystems”
• “Conditionally Executed Subsystems Overview”

Version History
Introduced in R2020a

3-112
na_0003: Usage of If blocks

na_0003: Usage of If blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

For the If block, the if expression and elseif expression shall be used only to define input signals.
Custom Parameter

Not Applicable
Example — Correct

The if expression only defines the input variables.

Example — Incorrect

The if expression defines a comparison operation.

3-113
3 Simulink

Rationale
Sub ID a:

• Visual comprehension of control conditions is easier when logical operations are described outside
of the If block.
• Describing logical operations outside of the If block allows verification to focus on the logical
operation.

Verification
Model Advisor check: “Check logical expressions in If blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Loops and Conditional Statements”

Version History
Introduced in R2020a

3-114
jc_0656: Usage of Conditional Control blocks

jc_0656: Usage of Conditional Control blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

To make all actions in the conditions explicit, these block parameters shall be set as follows :

• For If blocks, select Show else condition


• For Switch Case blocks, select Show default case
Custom Parameter

Not Applicable
Example — Correct

Using default behavior in the Switch Case block.

3-115
3 Simulink

Example — Incorrect

Not using default behavior in the Switch Case block.

Rationale
Sub ID a:

• Determining whether there is pointless processing or if something is missing from the design
(such as a missing description) is easier when the processing of exceptions (else, default) is
explicitly set in the model.

Verification
Model Advisor check: “Check default/else case in Switch Case blocks and If blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Conditionally Executed Subsystems Overview”
• “Edit Block Parameters”
• “Select Subsystem Execution”

Version History
Introduced in R2020a

3-116
jc_0657: Retention of output value based on conditional control flow blocks and Merge blocks

jc_0657: Retention of output value based on


conditional control flow blocks and Merge blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a2
• JMAAB — a1/a2

MATLAB Versions
All

Rule
Sub ID a1

Unused action ports shall connect to Terminator block when these conditions are met:

• Past value is retained


• Merge block and a conditional flow block, such as an If or Switch Case block, are used to switch
functions.

Custom Parameter

Not Applicable
Example — Correct

If block example

3-117
3 Simulink

Switch Case block example

3-118
jc_0657: Retention of output value based on conditional control flow blocks and Merge blocks

Example — Incorrect

If block example

Switch Case block example

3-119
3 Simulink

Sub ID a2

A feedback loop using a Delay block shall be implemented when these conditions are met:

• Past value is retained


• Merge block and a conditional flow block, such as an If or Switch Case block, are used to switch
functions.

Custom Parameter

Not Applicable
Example — Correct

If block example

3-120
jc_0657: Retention of output value based on conditional control flow blocks and Merge blocks

Switch Case block example

3-121
3 Simulink

Example — Incorrect

If block example

3-122
jc_0657: Retention of output value based on conditional control flow blocks and Merge blocks

Switch Case block example

3-123
3 Simulink

Rationale
Sub ID a1:

• Improves code efficiency.


• Connections to Terminator block can be used when past values are held other than by the default
(else).

Sub ID a2:

• Retaining past values is explicit.

Verification
Adherence to this modeling guideline cannot be verified by using a Model Advisor check.

Last Changed
R2020a

Version History
Introduced in R2020a

3-124
Operation Blocks

Operation Blocks

3-125
3 Simulink

na_0002: Appropriate usage of basic logical and


numerical operations

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Logical signals shall not connect to blocks that operate on numerical signals.
Custom Parameter

Blocks receiving numerical signals


Example — Correct

Numerical values are compared to determine if they are equal.

Example — Incorrect

A logical output is connected directly to the input of blocks that process numerical inputs.

3-126
na_0002: Appropriate usage of basic logical and numerical operations

A logical signal is compared with a numerical value.

Sub ID b

Numerical signals shall not connect to blocks that operate on logical signals.
Custom Parameter

Blocks receiving logical signals


Example — Correct

Logical signal is inverted by using a logical operation.

Logical signal is evaluated by using a logical operation.

Example — Incorrect

Logical signal is inverted by using a logical operation.

3-127
3 Simulink

A block that is used to perform logical operations is being used to perform numerical operations. A
numerical output is connected to the input of blocks that process logical inputs.

A block that is used to perform numerical operations is being used to perform logical operations.
Inputs other than logical values can be provided to the block. However, the Enable port block can
receive only logical signals that have On/Off. The Product block performs logical operations when it
connects the numerical operations result to a block that receives the logical value Enable port.

Rationale
Sub IDs a, b:

• When numerical and logical values are treated the same, the original intention becomes unclear
and the next operation in the model can be incorrectly interpreted, further compounding the error.

Verification
Model Advisor check: “Check fundamental logical and numerical operations” (Simulink Check)

Last Changed
R2020a

See Also
• “Signal Basics”

Version History
Introduced in R2020a

3-128
jc_0121: Usage of add and subtraction blocks

jc_0121: Usage of add and subtraction blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

The icon shape of the add and subtraction Sum block shall be rectangular.

When used in a feedback loop, the icon shape can be round.


Custom Parameter

Not Applicable
Example — Correct

The icon shape of the add and subtraction Sum block shall be rectangular.

The second input to the add and subtraction Sum block is a feedback loop, so the icon shape is
round.

3-129
3 Simulink

Example — Incorrect

This is not a feedback loop, but the icon shape of the add and subtractionSum block is round.

Sub ID b

The + mark shall be used for the first input to the add and subtraction Sum block.

For a feedback loop, the first input can be set by using the - mark.
Custom Parameter

Not Applicable
Example — Correct

The + mark is used for the first input to the add and subtraction Sum block.

The second input to the add and subtraction Sum block is a feedback loop, so the - mark is used.

Example — Incorrect

The sign for the first input to the add and subtraction Sum block is the - mark.

Sub ID c

The add and subtraction Sum block shall not have more than two inputs.

3-130
jc_0121: Usage of add and subtraction blocks

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

The add and subtraction Sum block has three inputs.

Rationale
Sub ID a:

• Adherence to the guideline improves readability of the model.

Sub ID b:

• Readability of the control specification improves when the sign for the first input is consistent.

Sub ID c:

• The order of operations is clearly defined.

Verification
Model Advisor check: “Check usage of Sum blocks” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-131
3 Simulink

jc_0610: Operator order for multiplication and


division block

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

The * mark shall be used for the first input to a multiplication and division Product block.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

The / mark is used for the first input.

3-132
jc_0610: Operator order for multiplication and division block

Sub ID b

The multiplication and division Product block shall not have more than two inputs.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

The block has three inputs.

Rationale
Sub ID a:

• When checking the block, the input order of the expression and block is reversed, which impairs
readability.
• For floating point numbers, the code is generated according to the operation order in the block --
((1÷1st input)) × 2nd input. However, if division is performed later, then the number of
operations can be reduced.

Sub ID b:

3-133
3 Simulink

• The order of operations is clearly defined.

Verification
Model Advisor check: “Check operator order of Product blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Multiply and Divide Inputs Using the Product Block”

Version History
Introduced in R2020a

3-134
jc_0611: Input sign for multiplication and division blocks

jc_0611: Input sign for multiplication and division


blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When using fixed-point values as the input to the multiplication and division Product block, the sign
of the data type shall be the same for all input signals.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• A utility function is created for each least significant bit (LSB) when fixed-point code is generated.
Unification of data type signs can reduce the number of utility functions.

Verification
Model Advisor check: “Check signs of input signals in product blocks” (Simulink Check)

Last Changed
R2020a

3-135
3 Simulink

See Also
• “Multiply and Divide Inputs Using the Product Block”

Version History
Introduced in R2020a

3-136
jc_0794: Division in Simulink

jc_0794: Division in Simulink

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When using division, implementation of the algorithm shall avoid division by zero.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Deviation from the rule can cause unintended operation and code generation results.

Model Advisor Check


“Check for division by zero in Simulink” (Simulink Check)

Last Changed
R2021a

See Also
• Multiply “Multiply and Divide Inputs Using the Product Block”

3-137
3 Simulink

Version History
Introduced in R2020a

3-138
jc_0805: Numerical operation block inputs

jc_0805: Numerical operation block inputs

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a1/a2, b, c1/c2, d, e, f1/f2, g, h, i, j
• JMAAB — a1/a2, b, c1/c2, d, e, f1/f2, g, h, i, j

MATLAB Versions
All

Rule
Sub ID a1

When using and Abs block with signed integer types, the input shall not be the most negative value.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

3-139
3 Simulink

Sub ID a2

Abs block parameter Saturation on Integer Overflow shall be selected.


Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Sub ID b

Input to the Abs block shall not be unsigned integer types or fixed-point types.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

3-140
jc_0805: Numerical operation block inputs

Sub ID c1

Input to the Sqrt block shall not be a negative value.


Custom Parameter

Not Applicable
Example — Correct

Negative number is saturated with 0.

Simulation result

Example — Incorrect

Sub ID c2

Sqrt block parameter Output Signal Type shall be set to complex.


Custom Parameter

Not Applicable

3-141
3 Simulink

Example — Correct

Example — Incorrect

Sub ID d

Input to the Reciprocal Sqrt block shall not be less than zero.
Custom Parameter

Not Applicable
Example — Correct

Less than eps saturated with eps.

Simulation result: Plot as Y=log10(Z)

3-142
jc_0805: Numerical operation block inputs

Example — Incorrect

Sub ID e

When Math Function block parameter Function is set to log or log10, the input to the block shall
not be zero.
Custom Parameter

Not Applicable
Example — Correct

Replace within ±eps with ±eps

Simulation result: Plot as Y = |Z|

3-143
3 Simulink

Example — Incorrect

Sub ID f1

When Math Function block parameter Function is set to log or log10, the input to the block shall
not be a negative number.
Custom Parameter

Not Applicable
Example — Correct

When the input is less than eps, the value is saturated to eps. Less than eps saturated with eps.

Simulation result

3-144
jc_0805: Numerical operation block inputs

Example — Incorrect

Sub ID f2

When Math Function block parameter Function is set to log or log10, block parameter Output
Signal Type shall be set to complex.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Sub ID g

When Math Function block parameter Function is set to mod or rem, the second argument input
shall not be zero.

3-145
3 Simulink

Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Sub ID h

When Math Function block parameter Function is set to reciprocal, the input to the block shall
not be zero.
Custom Parameter

Not Applicable
Example — Correct

Replace within ±eps with ±eps

3-146
jc_0805: Numerical operation block inputs

Simulation result: Simulation results is not inf, but since it is close to zero, the change in the output
value is significant.

Example — Incorrect

Sub ID i

When Product block parameter Multiplication is set to Element-wise(.*), the divisor input shall
not be zero.

Note To specify a divisor input, set Product block parameter Number of inputs to */.

Custom Parameter

Not Applicable

3-147
3 Simulink

Example — Correct

Example — Incorrect

Sub ID j

When Product block parameter Multiplication is set to Matrix(*), the divisor input shall not be set
to a singular matrix.

Note To specify a divisor input, set Product block parameter Number of inputs to */.

Custom Parameter

Not Applicable

3-148
jc_0805: Numerical operation block inputs

Example — Correct

Example — Incorrect

Rationale
Sub IDs a1, c1, d, e, f1, g, h, i, j:

• The result of entering an invalid value is implementation dependent. Deviation from the rules can
result in unintended behavior.

Sub ID a2:

• Correct settings prevent unintended behavior that can result from using invalid values.

Sub ID b:

• The block can become optimized out of the generated code, resulting in a block that you cannot
trace to the generated code.

Sub IDs c2, f2:

• Correct settings prevent unintended behavior that can result from using negative values.

Verification
Adherence to this modeling guideline cannot be verified by using a Model Advisor check.

3-149
3 Simulink

Last Changed
R2020a

See Also
• “Specify Block Properties”
• “Control Data Types of Signals”

Version History
Introduced in R2020a

3-150
jc_0622: Usage of Fcn blocks

jc_0622: Usage of Fcn blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When a Fcn block has operators with different priorities, parentheses shall be used to specify the
priority order.

Custom Parameter

Not Applicable

Rationale
Sub ID a:

• When operators have different priorities and the computation order is not clearly specified by
using parentheses, readability is impaired and can be misinterpreted. This can result in
unintended behavior.

Verification
Model Advisor check: “Check for parentheses in Fcn block expressions” (Simulink Check)

Last Changed
R2020a

3-151
3 Simulink

See Also
• “Algebraic Loop Concepts”

Version History
Introduced in R2020a

3-152
jc_0621: Usage of Logical Operator blocks

jc_0621: Usage of Logical Operator blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The icon shape for the Logical Operator block shall be set to rectangular.

Custom Parameter

Not Applicable

Example — Correct

3-153
3 Simulink

Example — Incorrect

Rationale
Sub ID a:

• When describing the same function, using a consistent expression improves readability. Since
"characteristics” shapes are similar, the risk of misinterpretation is greater than with
rectangular shapes.

Verification
Model Advisor check: “Check icon shape of Logical Operator blocks” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-154
jc_0131: Usage of Relational Operator blocks

jc_0131: Usage of Relational Operator blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When using a Relational Operator block for comparison of signals and constants, the second (bottom)
input shall be used as the constant input.
Custom Parameter

Not Applicable
Example — Correct

3-155
3 Simulink

Example — Incorrect

Rationale
Sub ID a:

• Using constant values and the same comparison method reduces misinterpretation of the model.

Verification
Model Advisor check: “Check usage of Relational Operator blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Relational and Logical Operators” (Embedded Coder)

Version History
Introduced in R2020a

3-156
jc_0800: Comparing floating-point types in Simulink

jc_0800: Comparing floating-point types in


Simulink

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Equivalence comparison operators (==, ~=) shall not be used on floating-point data types.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Uses equivalence comparison operators == and ~= on the floating-point data type.

3-157
3 Simulink

Rationale
Sub ID a:

• Due to the characteristics of the floating-point, since the error is included in the value, the result
of the equivalence comparison operation may be false when it was expected to be true.

Verification
Model Advisor check: “Check comparison of floating point types in Simulink” (Simulink Check)

Last Changed
R2020a

See Also
• “Validate a Floating-Point Embedded Model”

Version History
Introduced in R2020a

3-158
jc_0626: Usage of Lookup Table blocks

jc_0626: Usage of Lookup Table blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

The Lookup Table Dynamic block parameter Lookup Method shall be set to Interpolation – Use
End Values.
Custom Parameter

Not Applicable

Sub ID b

These n-D Lookup Table block parameters shall be set as follows:

• Set Interpolation Method to Linear point-slope or Linear Lagrange.


• Set Extrapolation Method to Clip.
• Select Use last table value for inputs at or above last breakpoint.

Custom Parameter

Not Applicable

Rationale
Sub IDs a, b:

• When an unexpected value is entered for the Lookup Table block, the output is determined by
using the extrapolation method and can become an impossible value or cause the Lookup Table
output to overflow.

3-159
3 Simulink

Verification
Model Advisor check: “Check usage of Lookup Tables” (Simulink Check)

Last Changed
R2020a

See Also
• “Methods for Approximating Function Values”

Version History
Introduced in R2020a

3-160
jc_0623: Usage of continuous-time Delay blocks and discrete-time Delay blocks

jc_0623: Usage of continuous-time Delay blocks


and discrete-time Delay blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Unit Delay or Delay blocks shall be used in a discrete model or subsystem.

A Memory block shall be used in a continuous type model or subsystem.


Custom Parameter

Not Applicable
Example — Correct

A Unit Delay block is used in the discrete type model.

3-161
3 Simulink

Example — Incorrect

A Memory block is used in the discrete type model.

Rationale
Sub ID a:

3-162
jc_0623: Usage of continuous-time Delay blocks and discrete-time Delay blocks

• Adherence to the rule improves readability of the model.

Verification
Model Advisor check: “Check usage of Memory and Unit Delay blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Explore Types of Subsystems”
• “Model a Continuous System”
• “Discrete and Continuous Resettable Subsystems”

Version History
Introduced in R2020a

3-163
3 Simulink

jc_0624: Usage of Tapped Delay blocks/Delay


blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

When holding previous past values, Tapped Delay block shall be used to create a vector signal from
all held values.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

The Tapped Delay block is not used.

3-164
jc_0624: Usage of Tapped Delay blocks/Delay blocks

Sub ID b

When holding past values, Delay block shall be used to obtain the oldest value only
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

The Delay block is not used.

3-165
3 Simulink

Rationale
Sub ID a:

• Tapped Delay is set with arrays that hold past values, which improves code readability to assist
code efficiency.

Sub ID b:

• Improves model readability and code efficiency.

Verification
Model Advisor check: “Check for cascaded Unit Delay blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Signal Lines”

Version History
Introduced in R2020a

3-166
jc_0627: Usage of Discrete-Time Integrator blocks

jc_0627: Usage of Discrete-Time Integrator blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Discrete-Time Integrator block parameters Upper saturation limit and Lower saturation limit
shall be defined.
Custom Parameter

Not Applicable
Example — Correct

3-167
3 Simulink

Example — Incorrect

Note When Discrete-Time Integrator block parameters Upper saturation limit and Lower
saturation limit, are defined with parameter objects such as Simulink.Parameter, the parameter,
Data type should be set to auto. Simulation errors occur when Data type is set to a value other
than auto, single, or double.

Rationale
Sub ID a:

• Avoids block output overflow and prevents other computation blocks that use the output of this
block from producing unexpected results.

Verification
Model Advisor check: “Check usage of Discrete-Time Integrator block” (Simulink Check)

Last Changed
R2024b

See Also
• Simulink.Parameter

3-168
jc_0627: Usage of Discrete-Time Integrator blocks

Version History
Introduced in R2020a

3-169
3 Simulink

jc_0628: Usage of Saturation blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Saturation and Saturation Dynamic blocks shall be used to limit physical quantity.

Type conversion shall not be used. Block parameters Upper limit and Lower limit shall not be set.
Custom Parameter

Not Applicable
Example — Correct

The Saturation Dynamic block is limiting physical quality.

3-170
jc_0628: Usage of Saturation blocks

Example — Incorrect

The Saturation Dynamic block is not being used to limit physical quantity. Type conversion is being
used. The upper and lower limits for the data type maximum and minimum values are set.

Rationale
Sub ID a:

• Consistent use of Saturation blocks improve maintainability of the model.

Verification
Model Advisor check: “Check usage of the Saturation blocks” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-171
3 Simulink

jc_0651: Implementing a type conversion

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The Output data type parameter of the output signal of a numerical operation block shall be set to
Inherit:. A Data Type Conversion shall be used when changing the data type of the block output
signal.
Custom Parameter

Not Applicable
Example — Correct

The Output data type parameter of the Divide block is set to Inherit: Inherit via internal
rule.

3-172
jc_0651: Implementing a type conversion

Example — Incorrect

The Output data type parameter of the Divide block is set to int16.

Rationale
Sub ID a:

• Dividing the math operations and type cast can help to clarify the order of execution and data type
for each expression.

Verification
Model Advisor check: “Check Output data type of operation blocks” (Simulink Check)

Last Changed
R2024b

Version History
Introduced in R2020a

3-173
3 Simulink

Other Blocks

3-174
db_0042: Usage of Inport and Outport blocks

db_0042: Usage of Inport and Outport blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

The Inport block shall be positioned on the left side of the diagram, but can be moved to prevent the
crossing of signals.
Custom Parameter

Not Applicable
Example — Correct

Inport block is positioned on the left side of the diagram.

3-175
3 Simulink

Example — Incorrect

Inport block is not positioned on the left side of the diagram.

Sub ID b

The Outport block shall be positioned on the right side of the diagram, but can be moved to prevent
the crossing of signals.

Custom Parameter

Not Applicable

Example — Correct

Outport block is positioned on the right side of the diagram.

3-176
db_0042: Usage of Inport and Outport blocks

Example — Incorrect

Outport block is not positioned on the right side of the diagram.

Sub ID c

Duplicate Inport blocks shall be prohibited.


Custom Parameter

Not Applicable
Example — Correct

One Inport block is used.

Example — Incorrect

Inport blocks is duplicated.

3-177
3 Simulink

Rationale
Sub IDs a, b, c:

• Defined operation rules improve readability.

Verification
Model Advisor check: “Check position of Inport and Outport blocks” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-178
jc_0081: Inport and Outport block icon display

jc_0081: Inport and Outport block icon display

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

For Inport and Outport blocks, parameter Icon Display shall be set to Port number.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

3-179
3 Simulink

Rationale
Sub ID a:

• Improves readability by displaying the port number of Inport and Outport blocks.
• Allows for easy identification of port numbers that are within a subsystem.
• Prevents misconnections to hierarchized subsystems by displaying the block names and making
the names of signal lines to the Inport and Outport blocks the same as the block names.

Verification
Model Advisor check: “Check display for port blocks” (Simulink Check)

Last Changed
R2020a

See Also
• “Set Block Parameter Values”
• “Signal Basics”
• “Simulink Bus Capabilities”

Version History
Introduced in R2020a

3-180
na_0011: Scope of Goto and From blocks

na_0011: Scope of Goto and From blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

Goto block parameter tag visibility shall be set to Local.


Custom Parameter

Not Applicable

Sub ID b

The output signal of Inport block shall not exclusively connect to Goto block.
Custom Parameter

Not Applicable
Example — Correct

The output signal of Inport block connects to something other than Goto block.

3-181
3 Simulink

Example — Incorrect

The output signal of Inport block connects exclusively to Goto block.

Sub ID c

The output signal of a From block shall not connect to an Outport block.

Custom Parameter

Not Applicable

Example — Correct

The output signal of a From block does not connect to an Outport block.

Example — Incorrect

The output signal of a From block connects to an Outport block.

3-182
na_0011: Scope of Goto and From blocks

Rationale
Sub ID a:

• When the hierarchies of the Goto block and the corresponding From block are different, the
relationships between the blocks can be difficult to understand.
• Simulation errors can occur when hierarchies of the Goto block and the corresponding From block
are different and a virtual subsystem changes to an Atomic subsystem.

Sub ID b:

• When connecting the output signal of an Inport block to a Goto block, at least one branched signal
connects to blocks other than the Goto block.

Verification
Model Advisor check: “Check scope of From and Goto blocks” (Simulink Check)

Last Changed
R2024b

See Also
• “Programmatically Specify Block Parameters and Properties”
• “Explore Types of Subsystems”
• “Simulink Subsystem Semantics”

Version History
Introduced in R2020a

3-183
3 Simulink

jc_0161: Definition of Data Store Memory blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

The smallest scope level shall be used to define the Data Store Memory block.
Custom Parameter

Not Applicable

Sub ID b

Only data required for execution and code generation shall be defined in the Data Store Memory
block.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Readability improves when usage is limited.

Sub ID b:

• Unused data can affect maintenance and operability.

Verification
Model Advisor check: “Check for usage of Data Store Memory blocks” (Simulink Check)

3-184
jc_0161: Definition of Data Store Memory blocks

Last Changed
R2020a

See Also
• “Data Store Basics”

Version History
Introduced in R2020a

3-185
3 Simulink

jc_0141: Usage of the Switch blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The second Switch block input condition shall be a logical type. Switchblock parameter Criteria for
passing first input shall be set to u2~=0.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• It is easier to understand specifications when the configuration is applied by using Simulink blocks
rather than by writing operation expressions in blocks.

Verification
Model Advisor check: “Check usage of Switch blocks” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-186
jc_0650: Block input/output data type with switching function

jc_0650: Block input/output data type with


switching function

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

For blocks with switching functions (Switch, Multiport Switch, and Index Vector), the same data type
shall be used for data ports and output ports.
Custom Parameter

Not Applicable
Example — Correct

The data type for the data port and output port is the same.

3-187
3 Simulink

Example — Incorrect

The data port and output port have different data types.

3-188
jc_0650: Block input/output data type with switching function

Rationale
Sub ID a:

• Prevents implicit data conversion.

Verification
Model Advisor check: “Check input and output datatype for Switch blocks” (Simulink Check)

Last Changed
R2020a

Version History
Introduced in R2020a

3-189
3 Simulink

jc_0630: Usage of Multiport Switch blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

Multiport Switch block parameter Number of data ports shall be two or more.
Custom Parameter

Not Applicable
Example — Correct

3-190
jc_0630: Usage of Multiport Switch blocks

Example — Incorrect

Sub ID b

The data type of the input signal to the control port of Multiport Switch shall be:

• uint8, uint16, or uint32


• enum (avoid using negative values for literals)
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Sub ID c

When Multiport Switch block parameter Data port order is set to Specify indices, these block
parameters shall be set as follows:

• Set Data port for default case to Additional data port.


• Set Diagnostic for default case to None.
Custom Parameter

Not Applicable

3-191
3 Simulink

Example — Correct

Example — Incorrect

Rationale
Sub ID a:

• Unintended output can occur when there is only one data port because the block changes to
extract scalars from vectors.

Sub ID b:

• The control port is an input range that expects an integer value of zero or greater. When a signed
or non-integer signal is connected to the control port, it can appear as a misconnection.

3-192
jc_0630: Usage of Multiport Switch blocks

• There is a possibility of data ports being unintentionally selected when negative or non-integer
values are input.

Sub ID c:

• When block parameter Data port order is set to Specify indices, a value that inputs to the
Multiport Switch block, other than the index specified for the control port, is treated the same as
the last value of the specified index. As a result, an unintended data port can be selected.

Verification
Model Advisor check: “Check settings for data ports in Multiport Switch blocks” (Simulink Check)

Last Changed
R2024b

Version History
Introduced in R2020a

3-193
3 Simulink

na_0020: Number of inputs to variant subsystems

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

The number of inputs/outputs for a Variant Subsystem block and its child structured subsystem or
model reference shall be the same.
Custom Parameter

Not Applicable
Example — Correct

3-194
na_0020: Number of inputs to variant subsystems

Example — Incorrect

The number of inputs to the child subsystem is different.

Sub ID b

The number of inputs/outputs for a Variant Model block shall be the same as its referenced model.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

The number of inputs to the referenced model is different than the inputs to the Variant Model block.

3-195
3 Simulink

Rationale
Sub IDs a, b:

• Unconnected signals can be unintentionally overlooked when the number of inputs/outputs is


different.

Verification
Model Advisor check: “Check for missing ports in Variant Subsystems” (Simulink Check)

Last Changed
R2024b

See Also
• “Explore Types of Subsystems”
• “Model Reference Basics”
• “Create a Simple Variant Model”

Version History
Introduced in R2020a

3-196
na_0036: Default variant

na_0036: Default variant

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Variant subsystems shall be configured so that one subsystem is always selected. This is achieved by
using one of these methods:

• Use the default variant for the variant.


• Define conditions that exhaustively cover all possible values of the conditional variables. For
example, define conditions for true and false values of a Boolean.

Custom Parameter

Not Applicable
Example — Correct

A default variant is used.

FUNC is a logical type.

3-197
3 Simulink

Example — Incorrect

An active subsystem will not exist when FUNC is not 1 or 2.

Sub ID b

Model variant conditions shall be set so all values that can be applied to conditional variable signals
are configured so one subsystem is always selected. For example, a condition is prepared for the
variable signal value being true, as well as false.

Custom Parameter

Not Applicable

Example — Correct

The condition is set so that all values for the conditional variable are covered.

Example — Incorrect

An active subsystem will not exist when FUNC is not 1 or 2.

3-198
na_0036: Default variant

Rationale
Sub IDs a, b:

• Prevents the omission of conditions.


• There may not be an active subsystem when conditions are omitted.

Verification
Model Advisor check: “Check use of default variants” (Simulink Check)

Last Changed
R2020a

See Also
• “Implement Variations in Separate Hierarchy Using Variant Subsystems”
• “Propagate Variant Conditions to Define Variant Regions in Virtual and Nonvirtual Subsystems”

Version History
Introduced in R2020a

3-199
3 Simulink

na_0037: Use of single variable for variant


condition

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Variant conditions shall be used to prohibit compound conditions that are formed from multiple
variables.
Exception

Conditional expressions that are formed from multiple variables can be used when using default
variants.
Custom Parameter

Not Applicable
Example — Correct

The variant condition is set by a single condition that is formed from multiple variables.

The usage of enumerated type variables is recommended in a condition equation. This example uses
numerical values to improve readability.

3-200
na_0037: Use of single variable for variant condition

Example — Incorrect

The variant condition is set by a compound condition that is formed from multiple variables.

Rationale
Sub ID a:

• Complicates the conditions, which makes it difficult to determine which subsystem will become
active. This can result in conditions being omitted.
• When conditions are omitted, there is a risk that there may not be an active subsystem.

Verification
Model Advisor check: “Check use of single variable variant conditionals” (Simulink Check)

Last Changed
R2020a

See Also
• “What Are Variants and When to Use Them”
• “Introduction to Variant Controls”

Version History
Introduced in R2020a

3-201
3 Simulink

jc_0900: Usable characters for data type definition

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

Underscores shall not be used at the end of bus object names, enumeration class names, or
enumeration member names.
Custom Parameter

Not Applicable
Example — Incorrect

An underscore is used at the end of the bus object name.

An underscore is used at the end of the enumeration member name.

3-202
jc_0900: Usable characters for data type definition

Sub ID b

Consecutive underscores shall not be used in bus object names, enumeration class names, or
enumeration member names.
Custom Parameter

Not Applicable
Example — Incorrect

Consecutive underscores are used in the bus object name.

Consecutive underscores are used in the enumeration class name.

Consecutive underscores are used in the enumeration member name.

Sub ID c

Bus object names, enumeration class names and enumeration member names shall not be the same
as reserved MATLAB words.
Custom Parameter

Not Applicable
Example — Incorrect

A bus object has the same name as a reserved MATLAB word.

A reserved MATLAB word that exactly matches the enumeration class name is used.

3-203
3 Simulink

A reserved MATLAB word that exactly matches the enumeration member name is used.

Rationale
Sub ID a:

• Deviation reduces readability. Since underscores are commonly used as word separators, it may
look like a typographical error.

Sub ID b:

• Deviation reduces readability.

Sub ID c:

• Deviation reduces readability. Deviating from common practices may lead to unexpected
problems.

Verification
Model Advisor check: “Check bus and enumeration data type names” (Simulink Check)

Last Changed
R2024b

See Also
“Specify Bus Properties with Bus Objects”

Version History
Introduced in R2024b

3-204
jc_0901: Length restriction for Bus and Enumeration data type names

jc_0901: Length restriction for Bus and


Enumeration data type names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The number of characters in a bus object name, enumeration class name, or enumeration member
name shall be less than or equal to the configured limit. The default is 63.
Custom Parameter

• Maximum number of characters for bus object names


• Maximum number of characters for enumeration class names
• Maximum number of characters for enumeration member names
Example — Incorrect

When the maximum number of characters is set to 31. The bus object, enumeration class, and
enumeration member names are longer than 31 characters.

3-205
3 Simulink

Rationale
Sub ID a:

• Deviation reduces readability.


• Deviation makes it difficult to maintain the integrity of the model and code.

Verification
Model Advisor check: “Check length of bus and enumeration data type names” (Simulink Check)

Last Changed
R2024b

See Also
“Specify Bus Properties with Bus Objects”

Version History
Introduced in R2024b

3-206
jc_0902: Arrowhead size of transition lines

jc_0902: Arrowhead size of transition lines

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The arrowhead {size} of transition lines shall be set to the value defined in the project.

Custom Parameter

Arrowhead {size} of transition lines.

Example — Correct

Example — Incorrect

The arrowhead {size} of transition lines are inconsistent.

3-207
3 Simulink

Rationale
Sub ID a:

• Maintaining a consistent arrowhead {size} of transition lines improves readability.

Verification
Model Advisor check: “Check arrowhead size of transition lines” (Simulink Check)

Last Changed
R2024b

See Also
“Transition Between Operating Modes” (Stateflow)

Version History
Introduced in R2024b

3-208
jc_0903: Prohibition of overlapping or crossing of blocks and signal lines

jc_0903: Prohibition of overlapping or crossing of


blocks and signal lines

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b1/b2
• JMAAB — a, b1/b2

MATLAB Versions
All

Rule
Sub ID a

Blocks, block names, block annotations, annotations, and signal labels shall not overlap.
Exception

When modeling within an annotation frame by treating the frame as a subsystem boundary, only the
lines of the annotation frame, not the entire frame, are subject to this rule.
Custom Parameter

Not Applicable
Example — Correct

Blocks, block names, and signal lines do not overlap.

3-209
3 Simulink

Example — Incorrect

Blocks, block names, annotations, and signal labels overlap.

Sub ID b1

• Signal lines shall not overlap with blocks, block names, block annotations, annotations, signal
lines, or signal labels.
• Signal lines shall not intersect with other signal lines.

Custom Parameter

Not Applicable
Exception

Intersection of annotation frames and signal lines when modeling within an annotation frame by
considering the frame as a subsystem boundary.
Example — Incorrect

Signal lines overlap with blocks and block names, and also and intersect with other signal lines.

Sub ID b2

• The Line crossing style shall be set to Line Hop option.


• Signal lines shall not overlap with blocks, block names, block annotations, annotations, signal
lines, or signal labels.

Custom Parameter

Not Applicable

3-210
jc_0903: Prohibition of overlapping or crossing of blocks and signal lines

Exception

Intersection of annotation frames and signal lines when modeling within an annotation frame by
considering the frame as a subsystem boundary.

Example — Correct

Signal lines are not overlapped with blocks or block names.

Example — Incorrect

Signal lines are overlapped with blocks and block names.

Rationale
Sub IDs a, b1, b2:

• Overlapping elements in a block diagram can reduce readability.

Verification
Model Advisor check: “Check for prohibited overlapping or intersecting blocks and signal lines”
(Simulink Check)

3-211
3 Simulink

Last Changed
R2024b

See Also
“Signal Basics”

Version History
Introduced in R2024b

3-212
jc_0904: Prohibition of overlap/intersection of states and transition lines

jc_0904: Prohibition of overlap/intersection of


states and transition lines

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

States, graphical functions, Simulink functions, MATLAB functions, truth tables, boxes, junctions,
annotations, or text labels shall not overlap.
Custom Parameter

Not Applicable
Exceptions

Exceptions apply in any of the following cases:

• Overlapping of parent and child in hierarchical modeling, provided that the child is contained
within the parent's frame.

• Modeling with hierarchical states (overlap with superstates)


• Modeling with graphical functions overlap with graphical function frames

• States and their labels must fit within the state frame. Likewise for graphical functions, Simulink
functions, MATLAB functions, truth tables, and boxes.

Supplement

Some combinations, such as the overlap of states, may result in errors.


Example — Correct

State labels do not overlap.

3-213
3 Simulink

Example — Incorrect

State labels, etc. are overlapping.

Sub ID b

Transition lines shall not overlap or intersect with states, graphical functions, Simulink functions,
MATLAB functions, truth tables, boxes, junctions, annotations, text labels, or other transition lines.
Custom Parameter

Not Applicable
Exceptions

Exceptions apply in any of the following cases:

• Overlapping of parent and child in hierarchical modeling, provided that the child is contained
within the parent's frame.

• Modeling with hierarchical states (overlap with superstates)

3-214
jc_0904: Prohibition of overlap/intersection of states and transition lines

• Modeling with graphical functions overlap with graphical function frames

Example — Correct

Since this is an intersection for crossing state hierarchies, it does not violate the rules.

Example — Incorrect

This transition line intersects with the state.

Rationale
Sub IDs a, b:

• Deviation reduces readability.

3-215
3 Simulink

Verification
Model Advisor check: “Check for prohibited overlapping of states and transition lines in Stateflow
charts” (Simulink Check)

Last Changed
R2024b

See Also
• “Signal Basics”
• “Transition Between Operating Modes” (Stateflow)

Version History
Introduced in R2024b

3-216
jc_0905: Usable characters for data names in Functions

jc_0905: Usable characters for data names in


Functions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Data names defined within MATLAB functions shall not use underscores at the end.
Custom Parameter

Not Applicable

Sub ID b

Consecutive underscores shall not be used in data names defined within MATLAB functions.
Custom Parameter

Not Applicable

Sub ID c

Data names defined within a MATLAB functions shall not be the same as reserved MATLABwords.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

3-217
3 Simulink

• Deviation reduces readability. Since underscores are commonly used as word separators, it may
look like a typographical error.

Sub ID b:

• Deviation reduces readability.

Sub ID c:

• Deviation reduces readability.


• Deviating from common practices may lead to unexpected problems.

Verification
Model Advisor check: “Check data names in MATLAB functions” (Simulink Check)

Last Changed
R2024b

See Also
“Model Reference Data Storage”

Version History
Introduced in R2024b

3-218
jc_0906: Length restriction of data names in MATLAB Functions

jc_0906: Length restriction of data names in


MATLAB Functions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The number of characters for data names defined within a MATLAB function shall be less than or
equal to configured limit. The default is 63.
Custom Parameter

The maximum number of characters for data names in MATLAB function is 63.

Rationale
Sub ID a:

• Deviation reduces readability.


• Deviation makes it difficult to maintain the integrity of the model and code.

Verification
Model Advisor check: “Check the length of data names in MATLAB functions” (Simulink Check)

Last Changed
R2024b

3-219
3 Simulink

See Also
“Reserved Keywords” (Embedded Coder)

Version History
Introduced in R2024b

3-220
jc_0907: Size of a Junction

jc_0907: Size of a Junction

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The size of junctions shall be set to the value defined in the project.
Custom Parameter

Size of junctions
Example — Correct

The sizes of the junctions are the same.

Example — Incorrect

The sizes of the junctions are not same.

3-221
3 Simulink

Rationale
Sub ID a:

• Using junctions of the same size improves readability.

Verification
Model Advisor check: “Check size of junctions” (Simulink Check)

Last Changed
R2024b

See Also
“Represent Multiple Paths by Using Connective Junctions” (Stateflow)

Version History
Introduced in R2024b

3-222
mp_0007: How to describe executable statements

mp_0007: How to describe executable statements

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Multiple execution statements shall not be written in a single line.


Example — Correct

if foo > 0
bar = 10;
end

Example — Incorrect

if foo > 0;bar = 10;


end

Sub ID b

Executable statements shall end with a semicolon.


Example — Correct

foo = 1 + 2;

Example — Incorrect

foo = 1 + 2

Rationale
Sub IDs a:

3-223
3 Simulink

• Readability is improved by standardizing the way to write statements according to common


practices.

Sub ID b:

• Readability is improved by standardizing the way to write statements according to common


practices.
• If you execute a statement without a semicolon, the results are displayed in the Command
Window, and you might miss important warnings.

Verification
Model Advisor check: “Check description of execution statements” (Simulink Check)

Last Changed
R2024b

Version History
Introduced in R2024b

3-224
mp_0008: Format of parentheses

mp_0008: Format of parentheses

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Single-byte spaces shall not be inserted between function/variable names and left parentheses.
Example — Correct

fcnc(arg)
foo(bar)

Example — Incorrect

fcnc (arg)
foo (bar)

Rationale
Sub ID a:

• Readability is improved by standardizing the way to write statements according to common


practices.

Verification
Model Advisor check: “Check for spaces between function or variable names and left parenthesis
symbol” (Simulink Check)

Last Changed
R2024b

3-225
3 Simulink

Version History
Introduced in R2024b

3-226
mp_0010: Precedence of Operators in Arithmetic Expressions

mp_0010: Precedence of Operators in Arithmetic


Expressions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When an expression contains operators with different precedence levels, parentheses shall be used to
clarify the order of operations.
Example — Correct

foo = (bar * baz) + qux;


foo = bar + (baz * qux);
(bar && baz) || (qux && quux);

When the operators have the same precedence, parentheses are unnecessary.

foo = bar + baz - qux;

Example — Incorrect

foo = bar * baz + qux;


foo = bar + baz * qux;
bar && baz || qux && quux;

Rationale
Sub ID a:

• Readability could lead to unintended functionality.

3-227
3 Simulink

Verification
Model Advisor check: “Check for operator precedence” (Simulink Check)

Last Changed
R2024b

See Also
“Operator Precedence”

Version History
Introduced in R2024b

3-228
mp_0011: Method of inserting a single-width space

mp_0011: Method of inserting a single-width space

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

At least one space shall be inserted before and after operators and after commas.

Single-byte spaces shall not be inserted between unary operators and operands.
Example — Correct

foo = bar + baz;


strcmp(qux, 'AEIOU')

x = -baz;

Example — Incorrect

foo=bar+baz;
strcmp(qux, 'AEIOU')

x = - baz;

Rationale
Sub ID a:

• The proper use of spaces around operators and commas can improve readability.

Verification
Model Advisor check: “Check spaces in expressions” (Simulink Check)

3-229
3 Simulink

Last Changed
R2024b

Version History
Introduced in R2024b

3-230
mp_0022: Format of Conditional Expressions

mp_0022: Format of Conditional Expressions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c1/c2
• JMAAB — a, b, c1/c2

MATLAB Versions
All

Rule
Sub ID a

Conditional expressions shall be written as expressions that evaluate to a single logical value (true or
false).
Example — Correct

% foo
・・・ a non-logical variable
if (foo ~= 0)

Example — Incorrect

% foo
・・・ a non-logical variable
if foo

Sub ID b

The number of binary operators per line in a conditional expression shall be defined.
Example — Correct

% If up to 3 is allowed
if (foo1 && foo2) ...
|| (foo3 && foo4 && foo5)

Example — Incorrect

% If up to 3 is allowed
if (foo1 && foo2) || (foo3 && foo4 && foo5)

3-231
3 Simulink

Custom Parameter

The number of binary operators per line in a conditional expression.

Sub ID c1

When dividing a conditional expression into multiple lines, line breaks shall be inserted immediately
after a logical operator, and the subsequent lines shall be indented.
Example — Correct

if foo1 || ...
foo2 || ...
foo3
end

Example — Incorrect

if foo1 ...
|| foo2 ...
|| foo3
end

Sub ID c2

When dividing a conditional expression into multiple lines, line breaks shall be inserted immediately
before a logical operator, and the subsequent lines shall have aligned indentation.
Example — Correct

if foo1 ...
|| foo2 ...
|| foo3
end

Example — Incorrect

if foo1 || ...
foo2 || ...
foo3
end

Rationale
Sub ID a:

• The conditions for true and false are clarified.

Sub ID b:

• Limiting the number of operators makes it easy to understand the relationships between each
condition.

Sub ID b:

• Limiting the number of operators makes it easy to understand the relationships between each
condition.

Sub IDs c1, c2:

3-232
mp_0022: Format of Conditional Expressions

• The relationships between each condition become easier to understand.

Verification
Model Advisor check: “Check description of conditional expressions” (Simulink Check)

Last Changed
R2024b

See Also
“Operator Precedence”

Version History
Introduced in R2024b

3-233
3 Simulink

mp_0023: Format of relational operations using


constants

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a1, a2
• JMAAB — a1, a2

MATLAB Versions
All

Rule
Sub ID a1

When you are using relational operators with variables and constants, the constants shall be placed
on the right-hand side.
Example — Correct

foo = 10;
if bar >= foo
ret1 = 1;
end

Example — Incorrect

foo = 10;
if foo <= bar
ret1 = 1;
end

Sub ID a2

When you are using relational operators with variables and constants, the constants shall be placed
on the left-hand side.
Example — Correct

foo = 10;
if foo <= bar
ret1 = 1;
end

3-234
mp_0023: Format of relational operations using constants

Example — Incorrect

foo = 10;
if bar >= foo
ret1 = 1;
end

Rationale
Sub IDs a1, a2:

• Readability is improved by standardizing the way to write statements.

Verification
Model Advisor check: “Check relational operators usage” (Simulink Check)

Last Changed
R2024b

Version History
Introduced in R2024b

3-235
3 Simulink

mp_0032: Function header information

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Necessary information shall be described in the function header.


Supplementary Information

The descriptive items can include an overview, processing details, input and output arguments,
management information and other relevant information. The combination of descriptive items shall
be adjusted for main functions and sub-functions as needed.
Example — Correct

function ret = sample(arg1)


% Overview
% sample program
% Processing details
% Adds arg1 and foo and returns the value
% Arguments
% arg1 : First term
% Return Value
% ret : Result of addition
% Change History
% -------------------------------
% 2018/3/14 Created
% -------------------------------
% 2018/3/30 Added comments

foo = 3;
ret = arg1 + foo;
end

Custom Parameter

Descriptive items for the function header.

3-236
mp_0032: Function header information

Rationale
Sub ID a:

• Readability and maintainability is improved by clearly specifying the information to be shared.

Verification
Model Advisor check: “Check function headers” (Simulink Check)

Last Changed
R2024b

See Also
• na_0025: MATLAB Function header

Version History
Introduced in R2024b

3-237
3 Simulink

mp_0034: Number of lines in a function

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The number of lines in a function shall be kept below the limit.

Example — Correct

• Lines of the range that can be collapsed at the function line in the editor are counted.
• The help text just below the function line should be collapsed and counted.
• The number of lines in the libinfo function is 88 in the following example.

3-238
mp_0034: Number of lines in a function

Custom Parameter

• Number of lines

Rationale
Sub ID a:

• When a function has too many lines, it can be difficult to understand and maintain the function.
Separating it by each feature deepens understanding of the functions and can limit the range
affected by changes.

Verification
Model Advisor check: “Check number of lines of functions” (Simulink Check)

Last Changed
R2024b

See Also
• “Integrate MATLAB Functions in a Stateflow Charts” (Stateflow)
• “Implement MATLAB Functions in Simulink with MATLAB Function Blocks”

Version History
Introduced in R2024b

3-239
3 Simulink

mp_0040: Using the return value of a function

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The return values of functions shall be assigned to variables before use.


Example — Correct

ret1 = func1(arg1);
ret2 = func2(arg2);
ret = ret1 + ret2;

Example — Incorrect

ret = func1(arg1) + func2(arg2);

Rationale
Sub ID a:

• Although it is not syntactically incorrect to use the return values of functions directly, the results
may vary depending on the order of the function evaluation.

Readability improves where the return values of functions are assigned to variables before use,
rather than where the return values are used directly in operations.

Verification
Model Advisor check: “Check for utilization of the return value of functions” (Simulink Check)

3-240
mp_0040: Using the return value of a function

Last Changed
R2024b

See Also
• jc_0511: Return values from a graphical function

Version History
Introduced in R2024b

3-241
3 Simulink

mp_0046: Usage of expressions in array indices

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Array indices shall not be used to calculate array numbers. However, arithmetic operations with end
and the colon operator are exceptions.
Example — Correct

foo = rand(1, 10);


k = 1;
m = 2 * k - 1;
foo(m) = 1;
foo(end - 1) = 2;

Example — Incorrect

foo = rand(1, 10);


k = 1;
foo(2 * k - 1) = 1;

Rationale
Sub ID a:

• Calculating values before using them as indices to access array elements reduces readability.

Verification
Model Advisor check: “Check array indices” (Simulink Check)

3-242
mp_0046: Usage of expressions in array indices

Last Changed
R2024b

Version History
Introduced in R2024b

3-243
3 Simulink

mp_0047: Conditions that a nonempty statement


must satisfy

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

A non-empty statement shall meet one of the following criteria:

• Produces at least one side effect, regardless of how it is executed.


• Has the capability to alter the control flow.

Example — Incorrect

foo;
bar == 1;

Rationale
Sub ID a:

• Non-empty statements should be written to change data values or alter control flow, impacting the
execution results in some way. Statements that do not meet these criteria are unnecessary and
may not reflect the designer's intentions.

Verification
Model Advisor check: “Check for usage of nonempty statements” (Simulink Check)

3-244
mp_0047: Conditions that a nonempty statement must satisfy

Last Changed
R2024b

Version History
Introduced in R2024b

3-245
4

Stateflow

• “Stateflow Blocks / Data / Events” on page 4-2


• “Stateflow Diagram” on page 4-29
• “Conditional Transition / Action” on page 4-82
• “Label Description” on page 4-149
• “Miscellaneous” on page 4-176
4 Stateflow

Stateflow Blocks / Data / Events

4-2
db_0123: Stateflow port names

db_0123: Stateflow port names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

The name of a Stateflow input/output shall be the same as the corresponding signal.
Exception

Reusable Stateflow blocks can have different port names.


Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Improves readability.
• Code generation may not be possible.

Verification
Model Advisor check: “Check for names of Stateflow ports and associated signals” (Simulink Check)

Last Changed
R2020a

4-3
4 Stateflow

See Also
• “Set Data Properties” (Stateflow)
• “Reusable Components in Charts” (Stateflow)

Version History
Introduced in R2020a

4-4
db_0125: Stateflow local data

db_0125: Stateflow local data

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d
• JMAAB — a, b, c, d

MATLAB Versions
All

Rule
Sub ID a

Data objects shall not be defined with Scope set to Local at the machine level.
Custom Parameter

Not Applicable

4-5
4 Stateflow

Example — Correct

Example — Incorrect

Scope has set Local local data at the machine level.

4-6
db_0125: Stateflow local data

Sub ID b

Data objects shall not be defined with Scope set to Constant at the machine level.
Custom Parameter

Not Applicable

4-7
4 Stateflow

Example — Correct

Example — Incorrect

Scope has set Constant local data at the machine level.

4-8
db_0125: Stateflow local data

Sub ID c

Data objects shall not be defined with Scope set to Parameter at the machine level.
Custom Parameter

Not Applicable

4-9
4 Stateflow

Example — Correct

Example — Incorrect

Scope has set Parameter local data at the machine level.

4-10
db_0125: Stateflow local data

Sub ID d

A Stateflow block with parent-child relationships shall not include stateflow data with the same name.

Custom Parameter

Not Applicable

Example — Correct

4-11
4 Stateflow

Example — Incorrect

A Stateflow block with parent-child relationships has local data with the same name.

Rationale
Sub ID a:

• When local data is defined at the machine level, it is shared with all blocks in the model. The data
will not behave like a local variable and can be influenced by any operation.
• Adherence to the rules prevent the definition from disappearing when copying a Stateflow block to
another model.

Sub IDs b, c:

• Adherence to the rules prevent the definition from disappearing when copying a Stateflow block to
another model.

Sub ID d:

4-12
db_0125: Stateflow local data

• When a Stateflow block with parent-child relationships includes stateflow data with the same
name, readability decreases due to lack of clarity with regard to the influence of the stateflow
data.

Verification
Model Advisor check: “Check definition of Stateflow data” (Simulink Check)

Last Changed
R2024b

See Also
• “Stateflow Data Properties” (Stateflow)
• “Use the Model Explorer with Stateflow Objects” (Stateflow)
• “Use State Hierarchy to Design Multilevel State Complexity” (Stateflow)

Version History
Introduced in R2020a

4-13
4 Stateflow

db_0126: Defining Stateflow events

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Stateflow events shall be defined by the smallest scope level in the Stateflow block being used.

Custom Parameter

Not Applicable

4-14
db_0126: Defining Stateflow events

Example — Correct

Example — Incorrect

Rationale
Sub ID a:

• Limiting use locations increases reliability.

Verification
Model Advisor check: “Check definition of Stateflow events” (Simulink Check)

4-15
4 Stateflow

Last Changed
R2020a

See Also
• “Synchronize Model Components by Broadcasting Events” (Stateflow)
• “Use the Model Explorer with Stateflow Objects” (Stateflow)

Version History
Introduced in R2020a

4-16
jc_0701: Usable number for first index

jc_0701: Usable number for first index

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a1/a2
• JMAAB — a1/a2

MATLAB Versions
All

Rule
Sub ID a1

When Stateflow Chart property Action language is set to C, Stateflow data property First Index
shall be set to 0.
Custom Parameter

Not Applicable

4-17
4 Stateflow

Example — Correct

Example — Incorrect

First Index is set to a combination of 0, 1, and 2.

4-18
jc_0701: Usable number for first index

Sub ID a2

When Stateflow Chart property Action language is set to C, Stateflow data property First Index
shall be set to 1.
Custom Parameter

Not Applicable

4-19
4 Stateflow

Example — Correct

Example — Incorrect

First Index is set to a combination of 0, 1, and 2.

4-20
jc_0701: Usable number for first index

Rationale
Sub ID a1:

• Logic becomes easier to understand when First Index is uniform.

Sub ID a2:

• Logic becomes easier to understand when First Index is uniform. However, C language is 0-
based, which decreases the readability of the code as the index calculation process is 1-based.
This is reflected in the generated code.

Verification
Model Advisor check: “Check usable number for first index” (Simulink Check)

4-21
4 Stateflow

Last Changed
R2020a

See Also
• “Differences Between MATLAB and C as Action Language Syntax” (Stateflow)
• “Set Data Properties” (Stateflow)

Version History
Introduced in R2020a

4-22
jc_0712: Execution timing for default transition path

jc_0712: Execution timing for default transition


path

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Stateflow Chart property Execute (enter) chart at initialization shall not be selected.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Using the same settings for each Stateflow Chart prevents the model from being misinterpreted.
• Use caution when referencing an input signal using the default transition line when property
Execute (enter) chart at initialization is selected.

Verification
Model Advisor check: “Check execution timing for default transition path” (Simulink Check)

Last Changed
R2020a

4-23
4 Stateflow

See Also
• “Transition Between Operating Modes” (Stateflow)
• “Execution of a Stateflow Chart” (Stateflow)

Version History
Introduced in R2020a

4-24
jc_0722: Local data definition in parallel states

jc_0722: Local data definition in parallel states

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Local variables that are completed in one state shall be defined in that state.
Custom Parameter

Not Applicable
Example — Correct

Local variables are defined in the state being used.

4-25
4 Stateflow

Example — Incorrect

Local variables are not defined in the state being used.

4-26
jc_0722: Local data definition in parallel states

Rationale
Sub ID a:

• Readability and maintainability can be improved by explicitly limiting the valid range of the
variables, thereby avoiding unintended references and changes.

Verification
Model Advisor check: “Check scope of data in parallel states” (Simulink Check)

Last Changed
R2020a

4-27
4 Stateflow

See Also
• “Represent Operating Modes by Using States” (Stateflow)
• “Parallel and Exclusive States” (Stateflow)

Version History
Introduced in R2020a

4-28
Stateflow Diagram

Stateflow Diagram

4-29
4 Stateflow

jc_0797: Unconnected transitions / states /


connective junctions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Stateflow Chart shall not have unconnected transitions.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

There are unconnected transitions.

4-30
jc_0797: Unconnected transitions / states / connective junctions

Sub ID b

Stateflow Chart shall not have unconnected exclusive (OR) states and connective junctions without a
transition source.
Custom Parameter

Not Applicable
Example — Correct

Does not have unconnected exclusive (OR) states or connective junctions without a transition source.

Example — Incorrect

There are unconnected exclusive (OR) states and connective junctions without a transition source.

Rationale
Sub IDs a, b:

4-31
4 Stateflow

• Unconnected transitions can result in adverse effects, such as misinterpretation of simulation


results or failure to generate code.

Verification
Model Advisor check: “Check for unconnected objects in Stateflow Charts” (Simulink Check)

Last Changed
R2020a

See Also
• “Transition Between Operating Modes” (Stateflow)
• “Combine Transitions and Junctions to Create Branching Paths” (Stateflow)
• “Define Exclusive and Parallel Modes by Using State Decomposition” (Stateflow)
• “Transition Between Exclusive States” (Stateflow)
• “Represent Multiple Paths by Using Connective Junctions” (Stateflow)

Version History
Introduced in R2020a

4-32
db_0137: States in state machines

db_0137: States in state machines

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When the Decomposition for the Chart block or State is set to OR (Exclusive), there shall be at
least two states in the hierarchy.
Custom Parameter

Not Applicable
Example — Incorrect

The hierarchy contains only one state when the Decomposition option is set to OR (Exclusive)

4-33
4 Stateflow

Rationale
Sub ID a:

• Redundant descriptions impair readability.


• Generated code includes unnecessary state variables.

Verification
Model Advisor check: “Check for state in state machines” (Simulink Check)

Last Changed
R2020a

See Also
• “Represent Operating Modes by Using States” (Stateflow)
• “Define Exclusive and Parallel Modes by Using State Decomposition” (Stateflow)

Version History
Introduced in R2020a

4-34
jc_0721: Usage of parallel states

jc_0721: Usage of parallel states

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Substates of parallel states shall not be parallel states.


Custom Parameter

Not Applicable

4-35
4 Stateflow

Example — Correct

Example — Incorrect

Substates of parallel states are parallel states.

4-36
jc_0721: Usage of parallel states

Rationale
Sub ID a:

• Behavior is not affected by nesting parallel states in a parent superstate.


• Hierarchization of the parallel state decreases readability.

Verification
Model Advisor check: “Check usage of parallel states” (Simulink Check)

Last Changed
R2020a

4-37
4 Stateflow

See Also
• “Represent Operating Modes by Using States” (Stateflow)
• “Parallel and Exclusive States” (Stateflow)
• “Use State Hierarchy to Design Multilevel State Complexity” (Stateflow)

Version History
Introduced in R2020a

4-38
db_0129: Stateflow transition appearance

db_0129: Stateflow transition appearance

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Transition lines shall be drawn vertically or horizontally.

Diagonal lines can be used for flow charts.


Custom Parameter

Not Applicable
Example — Correct

4-39
4 Stateflow

Example — Incorrect

Sub ID b

Unnecessary connective junctions shall not be used.


Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

4-40
db_0129: Stateflow transition appearance

Rationale
Sub ID a:

• Consistent application of transition lines improves readability.

Sub ID b:

• Transitions can be difficult to understand when unnecessary connective junctions are used.

Verification
Model Advisor check: “Check for Stateflow transition appearance” (Simulink Check)

Last Changed
R2024b

See Also
• “Transition Between Operating Modes” (Stateflow)

Version History
Introduced in R2020a

4-41
4 Stateflow

jc_0531: Default transition

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b, c, d, e, f, g
• JMAAB — a, b, c, d, e, f, g

MATLAB Versions
All

Rule
Sub ID a

When Decomposition of a Stateflow Chart is Exclusive (OR), the default transition shall connect
at the top of the Chart block.

When Decomposition of the state is Exclusive (OR), the default transition shall connect
immediately beneath the state.
Custom Parameter

Not Applicable
Example — Correct

The default transition line is connected at the top.

Example — Incorrect

The default transition line is not connected.

4-42
jc_0531: Default transition

Sub ID b

When Decomposition is set to “Parallel (AND)”, the default transition line shall not be connected.
Custom Parameter

Not Applicable
Example — Correct

Decomposition of the parent object for states AA and AB is set to Parallel (AND), which makes
states AA and AB parallel states. The default transition line is not connected for these parallel states.

Example — Incorrect

A default transition line is connected for parallel state AA.

Sub ID c

A level shall not have multiple default transitions.


Custom Parameter

Not Applicable

4-43
4 Stateflow

Example — Correct

The level does not have multiple default transitions

Example — Incorrect

Multiple default transitions are included in the same level of state A.

4-44
jc_0531: Default transition

Sub ID d

Default transitions shall be connected directly and positioned vertically to the upper part of the state
or connective junction.

Custom Parameter

Not Applicable

Example — Correct

The default transition is connected vertically to the upper part of the state.

Example — Incorrect

The default transition of state A is not connected vertically to the upper part of the state.

4-45
4 Stateflow

Sub ID e

The destination state or destination connective junction for the default transition shall be positioned
to the top left in the same level.

Custom Parameter

Not Applicable

Example — Correct

The default transition is positioned to the top left in the same level.

Example — Incorrect

The default transition of state AB is not positioned to the top left in the same level.

4-46
jc_0531: Default transition

Sub ID f

Default transitions shall not extend beyond the boundaries of the state.
Custom Parameter

Not Applicable
Example — Correct

The default transition is within the boundaries of the state.

Example — Incorrect

The default transition extends beyond the boundaries of the state.

4-47
4 Stateflow

Sub ID g

Configuration parameter No unconditional default transitions shall be set to Error to ensure that
in the transition path for the default transition, the path with the lowest priority is an unconditional
transition.
Custom Parameter

Not Applicable
Example — Correct

The path with the lowest priority in the transition path for the default transition is an unconditional
transition.

Example — Incorrect

The path with the lowest priority in the transition path for the default transition is not an
unconditional transition.

4-48
jc_0531: Default transition

Rationale
Sub ID a:

• Simulation errors can occur when a state chart does not include default transition lines.
• When default transitions are included in a flow chart, it is impossible to determine whether this is
intentional or through failure to insert them.

Sub ID b:

• Readability improves when there are no unnecessary default transitions.

Sub ID c:

• The state may not function as intended and produce a warning when multiple default transitions
are included in the same level.

Sub ID d:

• Readability decreases when there are curves or variations in the angle or position of default
transitions.

Sub ID e:

• Readability decreases when there are variations in the position of the transition destination state
or transition destination connective junction for the default transition.

Sub ID f

• Readability decreases when a default transition extends beyond the boundary of a state and
intersects with state boundaries and expressions.

Sub ID g:

• When there is not an unconditional transition in the transition path of the default transition, the
transition destination disappears if all conditions of the transition path are not met. This can result
in unintended behavior.

4-49
4 Stateflow

Verification
Model Advisor check: “Check default transition placement in Stateflow charts” (Simulink Check)

Last Changed
R2020a

See Also
• “Define Exclusive and Parallel Modes by Using State Decomposition” (Stateflow)
• “Transition Between Operating Modes” (Stateflow)
• “How Stateflow Objects Interact During Execution” (Stateflow)

Version History
Introduced in R2020a

4-50
jc_0723: Prohibited direct transition from external state to child state

jc_0723: Prohibited direct transition from external


state to child state

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Transitions from one state directly to an external child state shall be prohibited.
Custom Parameter

Not Applicable
Example — Correct

Transition from parent state to parent state.

4-51
4 Stateflow

Transition from child state to another parent state.

Example — Incorrect

Direct transition from an external state to a child state in a different state.

4-52
jc_0723: Prohibited direct transition from external state to child state

Direct transition from an external child state to a child state in a different state.

Rationale
Sub ID a:

• Direct transitions between child states can complicate the states and decrease readability.

Verification
Model Advisor check: “Check usage of transitions to external states” (Simulink Check)

4-53
4 Stateflow

Last Changed
R2020a

See Also
• “Transition Between Operating Modes” (Stateflow)

Version History
Introduced in R2020a

4-54
jc_0751: Backtracking prevention in state transition

jc_0751: Backtracking prevention in state


transition

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Connective junctions shall not be used to separate complex conditions.


Custom Parameter

Not Applicable
Example — Correct

Connective junctions are not used to separate complex conditions.

Example — Incorrect

Connective junctions are used to separate complex conditions.

4-55
4 Stateflow

Rationale
Sub ID a:

• Deviation from the rule can cause backtracking, which results in unintended behavior.

Verification
Model Advisor check: “Check for unexpected backtracking in state transitions” (Simulink Check)

Last Changed
R2020a

See Also
• “Transition Between Operating Modes” (Stateflow)
• “Combine Transitions and Junctions to Create Branching Paths” (Stateflow)
• “Evaluate Transitions” (Stateflow)

Version History
Introduced in R2020a

4-56
jc_0760: Starting point of internal transition

jc_0760: Starting point of internal transition

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Internal transition lines shall start from the left edge of the state.
Custom Parameter

Not Applicable
Example — Correct

The inner transition line begins at the left edge of the state.

4-57
4 Stateflow

Example — Incorrect

The inner transition line does not begin at the left edge of the state.

4-58
jc_0760: Starting point of internal transition

Rationale
Sub ID a:

• Adherence to the rule improves readability.

Verification
Model Advisor check: “Check starting point of internal transition in Stateflow” (Simulink Check)

Last Changed
R2020a

See Also
• “Control Chart Execution by Using Inner Transitions” (Stateflow)

Version History
Introduced in R2020a

4-59
4 Stateflow

jc_0763: Usage of multiple internal transitions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a1/a2
• JMAAB — a1/a2

MATLAB Versions
All

Rule
Sub ID a1

Multiple internal transitions shall not be used in a single state.


Custom Parameter

Not Applicable
Example — Correct

4-60
jc_0763: Usage of multiple internal transitions

Example — Incorrect

4-61
4 Stateflow

Sub ID a2

When multiple internal transitions are used in a single state, they shall be listed from top to bottom in
the order of execution.
Custom Parameter

Not Applicable
Example — Correct

4-62
jc_0763: Usage of multiple internal transitions

Example — Incorrect

Rationale
Sub ID a1:

• The number of transition conditions is unclear when multiple internal transitions are used. By
limiting the use of internal transitions to a single use, transitions are clearer and readability
improves.

Sub ID a2:

• Using multiple internal transitions can prevent transition lines from crossing and simplifies state
transitions.
• Arranging internal transitions in execution order improves readability.

Verification
Model Advisor check: “Check usage of internal transitions in Stateflow states” (Simulink Check)

Last Changed
R2020a

See Also
• “Overview of Stateflow Objects” (Stateflow)
• “Transition Between Operating Modes” (Stateflow)
• “Types of Chart Execution” (Stateflow)

Version History
Introduced in R2020a

4-63
4 Stateflow

jc_0762: Prohibition of state action and flow chart


combination

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

A state shall not include state actions (en, du, or ex) and flow charts.
Custom Parameter

Not Applicable
Example — Correct

Within the state, only a state action is described.

4-64
jc_0762: Prohibition of state action and flow chart combination

Example — Incorrect

The state includes state actions en and du and also a flow chart.

4-65
4 Stateflow

Rationale
Sub ID a:

• The execution order becomes difficult to understand, which decreases readability.

Verification
Model Advisor check: “Check prohibited combination of state action and flow chart” (Simulink Check)

Last Changed
R2020a

See Also
• “Create Flow Charts in Stateflow” (Stateflow)
• “Represent Operating Modes by Using States” (Stateflow)

4-66
jc_0762: Prohibition of state action and flow chart combination

Version History
Introduced in R2020a

4-67
4 Stateflow

db_0132: Transitions in flow charts

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Transition actions shall not be used in flow charts.


Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Transition actions are used.

4-68
db_0132: Transitions in flow charts

Sub ID b

In a flow chart, the condition shall be positioned on a horizontal transition line and the condition
action shall be positioned on a vertical transition line.
Exception

Diagonal transition lines in loop constructs.


Custom Parameter

Not Applicable
Example — Correct

The condition is positioned on a horizontal transition line and the condition action is on a vertical
transition line.

Example — Incorrect

The condition is positioned on a vertical transition line and the condition action is on a horizontal
transition line.

Rationale
Sub ID a:

4-69
4 Stateflow

• The transition action in a flow chart is not executed.

Sub ID b:

• Consistent positioning of conditions and condition actions improves readability.

Verification
Model Advisor check: “Check transitions in Stateflow Flow charts” (Simulink Check)

Last Changed
R2020a

See Also
• “Transition Between Operating Modes” (Stateflow)

Version History
Introduced in R2020a

4-70
jc_0773: Unconditional transition of a flow chart

jc_0773: Unconditional transition of a flow chart

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

When a transition line with a transition condition originates from a connective junction, the
unconditional transition line shall also begin from that junction.
Custom Parameter

Not Applicable

4-71
4 Stateflow

Example — Correct

Example — Incorrect

There is not an unconditional transition line.

4-72
jc_0773: Unconditional transition of a flow chart

Sub ID b

The execution order for unconditional transitions shall be set to the last value.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

The execution order for unconditional transitions is not the last value.

4-73
4 Stateflow

Rationale
Sub ID a:

• Prevents unintended behavior that results from backtracking. Setting an unconditional transition
explicitly defines the behavior for when the condition is not met.

Sub ID b:

• Setting the unconditional transition to take precedence can prevent unintended behavior.

Verification
Model Advisor check: “Check usage of unconditional transitions in flow charts” (Simulink Check)

Last Changed
R2020a

See Also
• “Transition Between Operating Modes” (Stateflow)
• “Execution of a Stateflow Chart” (Stateflow)

4-74
jc_0773: Unconditional transition of a flow chart

Version History
Introduced in R2020a

4-75
4 Stateflow

jc_0775: Terminating junctions in flow charts

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a1/a2
• JMAAB — a1/a2

MATLAB Versions
All

Rule
Sub ID a1

Only one terminating junction shall be used.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

There is more than one terminating junction.

4-76
jc_0775: Terminating junctions in flow charts

Sub ID a2

One terminating junction with a single unconditional transition as the input shall be used.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

There is more than one terminating junction and input.

4-77
4 Stateflow

Rationale
Sub IDs a1, a2

• One terminating junction improves understanding of the logic end point.


• Using a consistent style for terminating junction improves readability.

Verification
Model Advisor check: “Check terminal junctions in Stateflow” (Simulink Check)

Last Changed
R2020a

See Also
• “Evaluate Transitions” (Stateflow)
• “Represent Multiple Paths by Using Connective Junctions” (Stateflow)

Version History
Introduced in R2020a

4-78
jc_0738: Usage of Stateflow comments

jc_0738: Usage of Stateflow comments

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

When Chart parameter Action Language is set to C, /*...*/ comment nesting shall not be used.
Custom Parameter

Not Applicable
Example — Correct

4-79
4 Stateflow

Example — Incorrect

Sub ID b

When Chart parameter Action Language is set to C, new line characters for comments /* */ shall
not be used in the middle of a single comment.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Rationale
Sub ID a:

4-80
jc_0738: Usage of Stateflow comments

• The compiler can misinterpret the comments as a program.

Sub ID b:

• A line break in the middle of a comment makes it difficult to determine whether the part being
edited is in the comment. There is also a possibility that the comment is nested.
• When Chart parameter Action Language is set to MATLAB, comments must use %.

Verification
Model Advisor check: “Check usage of Stateflow comments” (Simulink Check)

Last Changed
R2020a

See Also
• “Differences Between MATLAB and C as Action Language Syntax” (Stateflow)
• “Modify the Action Language for a Chart” (Stateflow)

Version History
Introduced in R2020a

4-81
4 Stateflow

Conditional Transition / Action

4-82
jc_0790: Action language of Chart block

jc_0790: Action language of Chart block

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Stateflow Chart property Action Language shall be set to C.


Custom Parameter

Not Applicable
Example — Correct

The Action Language is set to C.

4-83
4 Stateflow

Example — Incorrect

The Action Language is set to MATLAB.

Rationale
Sub ID a:

• Using a consistent action language improves readability because there is not a difference in
syntax.
• Easier to maintain consistency between the model and the generated code when using C as the
action language as compared to MATLAB.
• Easier to understand the model for users who are familiar with the C programming language.

Verification
Model Advisor check: “Check Stateflow chart action language” (Simulink Check)

Last Changed
R2020a

See Also
• “Modify the Action Language for a Chart” (Stateflow)
• “Differences Between MATLAB and C as Action Language Syntax” (Stateflow)

Version History
Introduced in R2020a

4-84
jc_0702: Use of named Stateflow parameters and constants

jc_0702: Use of named Stateflow parameters and


constants

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Stateflow block shall not use numeric literal.


Exceptions

• Initial value is 0
• Increment, decrement 1

Custom Parameter

Not Applicable
Example — Correct

Numeric literals are not used.

4-85
4 Stateflow

Example — Incorrect

Numeric literals are used.

Rationale
Sub ID a:

• Only the modeler will understand the purpose of the value when numeric literals are used to write
constants, which decreases readability.
• Constants that are intended for calibration are generated in the code using numeric literals.

Verification
Model Advisor check: “Check usage of numeric literals in Stateflow” (Simulink Check)

Last Changed
R2020a

See Also
• “Guidelines for Naming Stateflow Objects” (Stateflow)

4-86
jc_0702: Use of named Stateflow parameters and constants

Version History
Introduced in R2020a

4-87
4 Stateflow

jm_0011: Pointers in Stateflow

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Stateflow Chart shall not use pointer variables.


Custom Parameter

Not Applicable

4-88
jm_0011: Pointers in Stateflow

Example — Correct

Example — Incorrect

Pointer variables are used.

4-89
4 Stateflow

Rationale
Sub ID a:

• Readability is impaired when pointer variables are used.


• Code generation may not be possible.

Verification
Model Advisor check: “Check for pointers in Stateflow charts” (Simulink Check)

Last Changed
R2020a

See Also
• “Pointer and Address Operations” (Stateflow)

4-90
jm_0011: Pointers in Stateflow

Version History
Introduced in R2020a

4-91
4 Stateflow

jc_0491: Reuse of Stateflow data

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

A variable shall not have multiple meanings (usages) in a single Stateflow Chart.
Custom Parameter

Not Applicable
Example — Correct

Variable does not have multiple usages.

4-92
jc_0491: Reuse of Stateflow data

Example — Incorrect

Variables k and kk have multiple usages in the Stateflow Chart.

4-93
4 Stateflow

Rationale
Sub ID a:

• Variables can be misinterpreted when the variable name is different than the meaning of the
numerical value that is assigned to the variable.

Verification
Model Advisor check: Adherence to this modeling guideline cannot be verified by using a Model
Advisor check.

4-94
jc_0491: Reuse of Stateflow data

Last Changed
R2020a

See Also
• “Construct and Run a Stateflow Chart” (Stateflow)

Version History
Introduced in R2020a

4-95
4 Stateflow

jm_0012: Usage restrictions of events and


broadcasting events

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a, b1/b2

MATLAB Versions
All

Rule
Sub ID a

Stateflow events shall be used only in Stateflow Chart output.


Custom Parameter

Not Applicable
Example — Correct

Event is used only in the Stateflow Chart output.

4-96
jm_0012: Usage restrictions of events and broadcasting events

Example — Incorrect

Event is used other than in the Stateflow Chart output.

Sub ID b1

The send syntax send(event_name, state_name) shall be used to broadcast Stateflow events.
Custom Parameter

Not Applicable
Example — Correct

Event is broadcast using the send syntax.

4-97
4 Stateflow

Example — Incorrect

The state that receives the broadcast has not been defined in the send syntax.

4-98
jm_0012: Usage restrictions of events and broadcasting events

Sub ID b2

The send syntax send(state_name.event_name) with the qualified event name shall be used to
broadcast Stateflow events.

Custom Parameter

Not Applicable

Example — Correct

The qualified event name is used in the event being broadcast.

Example — Incorrect

The state that receives the broadcast has not been described in the send syntax.

4-99
4 Stateflow

Rationale
Sub ID a:

• Recursive processing in a chart is prevented by using Stateflow events in the Stateflow Chart
output only.

Sub IDs b1, b2:

• Improves readability because transitions that are triggered by events are clearly identified.

Verification
Model Advisor check: “Check for usage of events in Stateflow charts” (Simulink Check)

Last Changed
R2024b

See Also
• “Events” (Stateflow)
• “Use Events to Execute Charts” (Stateflow)
• “Broadcast Local Events to Synchronize Parallel States” (Stateflow)

Version History
Introduced in R2020a

4-100
jc_0733: Order of state action types

jc_0733: Order of state action types

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Basic state action types shall be stated in this order:

entry (en)

during (du)

exit (ex)
Custom Parameter

Not Applicable

4-101
4 Stateflow

Example — Correct

Example — Incorrect

Action types are out of order.

4-102
jc_0733: Order of state action types

Sub ID b

Combined state action types shall be stated in this order:

entry (en)

during (du)

exit (ex)
Custom Parameter

Not Applicable

4-103
4 Stateflow

Example — Correct

Example — Incorrect

Action types are out of order

4-104
jc_0733: Order of state action types

Rationale
Sub ID a:

• Consistent modeling improves readability and maintainability.

Verification
Model Advisor check: “Check order of state action types” (Simulink Check)

Last Changed
R2020a

See Also
• “Represent Operating Modes by Using States” (Stateflow)
• “During Actions” (Stateflow)
• “Exit a State” (Stateflow)

Version History
Introduced in R2020a

4-105
4 Stateflow

jc_0734: Number of state action types

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

State action types shall not be used more than one time in a Stateflow state.
Custom Parameter

Not Applicable
Example — Correct

4-106
jc_0734: Number of state action types

Example — Incorrect

Rationale
Sub ID a:

• The execution order will differ depending on the order in which they are described.
• Execution order can be difficult to understand when the action type is described multiple times.

Verification
Model Advisor check: “Check repetition of action types” (Simulink Check)

Last Changed
R2020a

See Also
• “Represent Operating Modes by Using States” (Stateflow)

Version History
Introduced in R2020a

4-107
4 Stateflow

jc_0740: Limitation on use of exit state action

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

State action type exit(ex) shall not be used.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

This example illustrates how the model behavior in Stateflow Chart is misinterpreted. It appears that
TBD is output when state action type exit(ex) is used, but it is in fact being overwritten by the state
action type entry of the transition destination state. It is not outputted by the Stateflow Chart.

4-108
jc_0740: Limitation on use of exit state action

Rationale
Sub ID a:

• Execution timing can be difficult to understand when state action type exit(ex) is used in
combination with a conditional action, a transition action, or state action type entry(en). This
can result in misinterpretation of the model behavior.

Verification
Model Advisor check: “Check if state action type 'exit' is used in the model” (Simulink Check)

Last Changed
R2020a

See Also
• “Exit a State” (Stateflow)

Version History
Introduced in R2020a

4-109
4 Stateflow

jc_0741: Timing to update data used in state chart


transition conditions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a1, a2, b

MATLAB Versions
All

Rule
Sub ID a1

Variables that are used in a state transition condition shall not use state action du to perform an
update.
Custom Parameter

Not Applicable
Exceptions

This rule applies exclusively to writing in a state chart with a transition source. The update is not
prohibited for parallel states and outside of the chart.

4-110
jc_0741: Timing to update data used in state chart transition conditions

Example — Correct

Example — Correct (for exception)

Example — Incorrect

State action du is used to perform an update.

Sub ID a2

Variables that are used in a state transition condition shall use state action du to perform an update.

4-111
4 Stateflow

Custom Parameter

Not Applicable
Exceptions

This rule applies exclusively to writing in a state chart with a transition source. The update is not
prohibited for parallel states and outside of the chart.
Example — Correct

State action du is used to perform an update.

Example — Correct (for exception)

4-112
jc_0741: Timing to update data used in state chart transition conditions

Example — Incorrect

Sub ID b

When the data referenced in a transition condition is updated to du as its source state, mixing
updated and non-updated data in the same transition condition is prohibited, except for constants and
parameters.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

State action du is used to perform an update. There is a mixture of data to update with State action
du(b) and data not updated in2.

4-113
4 Stateflow

Rationale
Sub ID a1:

• The execution order of the transition condition and implement of during can be difficult to
understand, which increases the risk of errors.

Verification
Model Advisor check: “Check updates to variables used in state transition conditions” (Simulink
Check)

Last Changed
R2024b

See Also
• “Transition Between Operating Modes” (Stateflow)
• “Represent Operating Modes by Using States” (Stateflow)
• “Execution of a Stateflow Chart” (Stateflow)

Version History
Introduced in R2020a

4-114
jc_0772: Execution order and transition conditions of transition lines

jc_0772: Execution order and transition conditions


of transition lines

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

All transition paths shall be executable by setting configuration parameter:

• (R2011b to R2016a) Set Transition shadowing to error.


• (R2016b and later) Set Unreachable execution path to error.

Custom Parameter

Not Applicable
Example — Correct

4-115
4 Stateflow

Example — Incorrect

Execution order 1 is an unconditional transition and conditional expression [C1] is described in


execution condition 2.

Rationale
Sub ID a:

• An unconditional transition that is in a position other than the last in the execution order causes
the subsequent transition to be a dead path, which results in unintended simulation behavior.

Verification
Model Advisor check: “Check usage of transition conditions in Stateflow transitions” (Simulink
Check)

Last Changed
R2020a

See Also
• “Transition Between Operating Modes” (Stateflow)
• “Types of Chart Execution” (Stateflow)
• “Execution of a Stateflow Chart” (Stateflow)

Version History
Introduced in R2020a

4-116
jc_0753: Condition actions and transition actions in Stateflow

jc_0753: Condition actions and transition actions


in Stateflow

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Transition actions shall not be used in a Stateflow Chart.


Custom Parameter

Not Applicable
Example — Correct

Only a condition action is used.

Example — Incorrect

A transition action is used.

4-117
4 Stateflow

Sub ID b

Condition actions and transition actions shall not be combined in the same Stateflow Chart.
Custom Parameter

Not Applicable
Example — Correct

Either a condition action or a transition action can be used. (The following diagram illustrates a
transition action.)

Example — Incorrect

Includes both a condition action and a transition action.

Rationale
Sub ID a:

4-118
jc_0753: Condition actions and transition actions in Stateflow

• Prevents confusion with a condition action, thus improving readability.

Sub ID b:

• A condition action executes upon entering a transition. A transition action executes after
determining whether it can transition to the next state. Adherence to the rule prevents confusion
between a conditional action and a transition action.

Verification
Model Advisor check: “Check condition actions and transition actions in Stateflow” (Simulink Check)

Last Changed
R2024b

See Also
• “Evaluate Outer Transitions with Condition and Transition Actions” (Stateflow)

Version History
Introduced in R2020a

4-119
4 Stateflow

jc_0711: Division in Stateflow

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a1/a2
• JMAAB — a1/a2

MATLAB Versions
All

Rule
Sub ID a1

Variables, constants, or parameters in Stateflow Chart shall not be used to perform division
operations.
Custom Parameter

Not Applicable
Example — Correct

Division is performed outside of the Stateflow Chart.

4-120
jc_0711: Division in Stateflow

Example — Incorrect

Division occurs within the Stateflow Chart.

Sub ID a2

When division occurs in a Stateflow Chart, the process shall prevent division by zero.
Custom Parameter

Not Applicable
Example — Correct

The process is defined to prevent division by zero.

4-121
4 Stateflow

Example — Incorrect

The process does not prevent division by zero.

Rationale
Sub ID a1, a2:

• Deviation from the rule can cause unintended operation and code generation results.

Verification
Model Advisor check: Adherence to this modeling guideline cannot be verified by using a Model
Advisor check.

4-122
jc_0711: Division in Stateflow

Last Changed
R2020a

See Also
• “Fixed-Point Operations in Stateflow Charts” (Stateflow)

Version History
Introduced in R2020a

4-123
4 Stateflow

db_0127: Limitation on MATLAB commands in


Stateflow blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a, b
• JMAAB — a, b

MATLAB Versions
All

Rule
Sub ID a

Built-in MATLAB functions shall not be used in Stateflow blocks.


Supplement

Applicable for C charts


Custom Parameter

Not Applicable
Example — Correct

MATLAB commands are not used in Stateflow blocks.

4-124
db_0127: Limitation on MATLAB commands in Stateflow blocks

Example — Incorrect

A MATLAB command is used in the Stateflow block.

Sub ID b

When a built-in MATLAB function is used in Stateflow blocks, it shall be accessed only by using
MATLAB Function.
Supplement

Applicable for C charts


Custom Parameter

Not Applicable

4-125
4 Stateflow

Example — Correct

The MATLAB command is accessed by using the MATLAB Function block.

Example — Incorrect

A MATLAB Function block is not used for a MATLAB command.

Rationale
Sub ID a:

• Not all built-in MATLAB functions are supported for code generation. As a result, code may not be
generated for these unsupported MATLAB functions.

Sub ID b:

4-126
db_0127: Limitation on MATLAB commands in Stateflow blocks

• Not all built-in MATLAB functions are supported for code generation. As a result, code may not be
generated for these unsupported MATLAB functions.
• Readability improves when C and MATLAB action languages are described separately.

Verification
Model Advisor check: “Check for MATLAB expressions in Stateflow charts” (Simulink Check)

Last Changed
R2024b

See Also
• MATLAB Function
• “Stateflow Programmatic Interface” (Stateflow)
• “Differences Between MATLAB and C as Action Language Syntax” (Stateflow)

Version History
Introduced in R2020a

4-127
4 Stateflow

jc_0481: Use of hard equality comparisons for


floating point numbers in Stateflow

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

These equality comparison operators shall not be used in floating-point operands:

• ==
• !=
• ~=
• <>

Custom Parameter

Not Applicable
Example — Correct

Equality comparison operators are not used in floating-point operands.

4-128
jc_0481: Use of hard equality comparisons for floating point numbers in Stateflow

Example — Incorrect

Equality comparison operator == is used in floating-point operands.

Rationale
Sub ID a:

• Due to the nature of the floating-point data type, as it contains an error, the result of the
equivalence comparison operation may be false when it was expected to be true.

Verification
Model Advisor check: “Check usage of floating-point expressions in Stateflow charts” (Simulink
Check)

Last Changed
R2024b

4-129
4 Stateflow

See Also
• “Fixed-Point Data in Stateflow Charts” (Stateflow)
• “Relational Operations”

Version History
Introduced in R2020a

4-130
na_0001: Standard usage of Stateflow operators

na_0001: Standard usage of Stateflow operators

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a, b1/b2/b3, c

MATLAB Versions
All

Rule
Sub ID a

When Stateflow Chart property Action Language is set to C, operators (&, |, ^, ~) shall be used only
for bit operations.
Custom Parameter

Not Applicable
Example — Correct

Operators (&, |, ^, ~) are used for bit operations.

Example — Incorrect

Operators (&, |, ^, ~) are not used for bit operations.

4-131
4 Stateflow

Sub ID b1

When Stateflow Chart property Action Language is set to C, operator ~= shall be used for inequality
operations.
Custom Parameter

Not Applicable
Example — Correct

Sub ID b2

When Stateflow Chart property Action Language is set to C, operator != shall be used for inequality
operations.
Custom Parameter

Not Applicable

4-132
na_0001: Standard usage of Stateflow operators

Example — Correct

Sub ID b3

When Stateflow Chart property Action Language is set to C, operator <> shall be used for inequality
operations.
Custom Parameter

Not Applicable
Example — Correct

Sub ID c

When Stateflow Chart property Action Language is set to C, operation ! shall be used for logical
negation.
Custom Parameter

Not Applicable
Example — Correct

4-133
4 Stateflow

Example — Incorrect

An operator other than ! should be used for logical negation.

Rationale
Sub ID a:

• When either of these Stateflow Chart properties are set as follows:

• Action Language is set to MATLAB


• Action Language is set to C and Enable C-bit operations is selected

&& and &, || ,and |, have the same calculation function. However, when && and & or || and | are
combined in the same chart, it can be difficult to determine whether these are separate
calculation functions or the same calculation function.

Sub IDs b1, b2, b3:

• Consistent use of equality operators improves readability.

Sub ID c:

• Consistent use of logical negation operators improves readability.


• When C-bit operations are enabled is selected, the function of the ! operator remains the same
and is not affected by logic changes that result from changing the setting.

Verification
Model Advisor check: “Check Stateflow operators” (Simulink Check)

Last Changed
R2020a

See Also
• “Modify the Action Language for a Chart” (Stateflow)
• “Differences Between MATLAB and C as Action Language Syntax” (Stateflow)

Version History
Introduced in R2020a

4-134
jc_0655: Prohibition of logical value comparison in Stateflow

jc_0655: Prohibition of logical value comparison in


Stateflow

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Logical constants shall not be compared to each other.


Custom Parameter

Not Applicable
Example — Correct

Logical constants are not compared to each other.

4-135
4 Stateflow

Example — Incorrect

Logical constants are compared to each other.

Rationale
Sub ID a:

4-136
jc_0655: Prohibition of logical value comparison in Stateflow

• Readability improves with consistent use of boolean-valued signal==true(boolean type


constant) or (boolean-valued signal) for logical signal condition expressions.
• Prevents redundancy in the model.
• Deviation from the rule can cause unexpected issues.

Verification
Model Advisor check: “Check prohibited comparison operation of logical type signals” (Simulink
Check)

Last Changed
R2020a

Version History
Introduced in R2020a

4-137
4 Stateflow

jc_0451: Use of unary minus on unsigned integers

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Unary minus shall not be used on unsigned integers.


Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Negative values cannot be input into 16-bit environments. (Negative values can be input into 32-bit
environments.)

4-138
jc_0451: Use of unary minus on unsigned integers

Rationale
Sub ID a:

• As the results are depend on the execution environment, unintended results can occur.

Verification
Model Advisor check: “Check usage of unary minus operations in Stateflow charts” (Simulink Check)

Last Changed
R2020a

See Also
• “Data Types Supported by Simulink”
• Unary Minus

Version History
Introduced in R2020a

4-139
4 Stateflow

jc_0802: Prohibited use of implicit type casting in


Stateflow

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

All operations, including substitution, comparison, arithmetic, etc., shall be performed between
variables of the same data type.

The data type of the actual arguments and the formal arguments in a function call shall be the same.
Custom Parameter

Not Applicable
Example — Correct

Variables use the same data type for calculations.

Example: Comparison operation

Example: Arithmetic operations and assignment operations (compound expressions)

4-140
jc_0802: Prohibited use of implicit type casting in Stateflow

Variables have different data types but are explicitly typecast before calculation.

Example: Comparison operation

Example: Arithmetic operations and assignment operations (compound expressions)

The data type of actual arguments and formal arguments in the function call are the same.

Example — Incorrect

Variables use different data types for calculations.

Example: Comparison operation

Example: Arithmetic operations and assignment operations (compound expressions)

4-141
4 Stateflow

Calculations are performed between unsigned integer type variables and signed integers.

The data type of actual arguments and formal arguments in the function call are different.

Rationale
Sub ID a:

• Implicit data type conversion can produce unexpected results.

Verification
Model Advisor check: “Check for implicit type casting in Stateflow” (Simulink Check)

Last Changed
R2020a

See Also
• “Type Cast Operations” (Stateflow)
• “Differences Between MATLAB and C as Action Language Syntax” (Stateflow)

4-142
jc_0802: Prohibited use of implicit type casting in Stateflow

Version History
Introduced in R2020a

4-143
4 Stateflow

jc_0803: Passing values to library functions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a1/a2, b1/b2, c1/c2,
• JMAAB — a1/a2, b1/b2, c1/c2, d1/d2

MATLAB Versions
All

Rule
Sub ID a1

A minimum value for the signed integer type shall not be provided when using the abs library
function.
Custom Parameter

Not Applicable
Example — Correct

4-144
jc_0803: Passing values to library functions

Example — Incorrect

Sub ID a2

The abs library function shall not be used.


Custom Parameter

Not Applicable

Sub ID b1

A negative number shall not be entered when using the sqrt library function.
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Sub ID b2

The sqrt library function shall not be used.

4-145
4 Stateflow

Custom Parameter

Not Applicable

Sub ID c1

A negative number shall not be entered when using the log and log10 library functions.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Sub ID c2

The log and log10 library functions shall not be used.

Custom Parameter

Not Applicable

Sub ID d1

Zero shall not be entered for the second argument when using the fmod library function.

Custom Parameter

Not Applicable

4-146
jc_0803: Passing values to library functions

Example — Correct

Example — Incorrect

Sub ID d2

The fmod library function shall not be used.


Custom Parameter

Not Applicable

Rationale
Sub IDs a1, b1, c1, d1:

• The behavior of a library function when an invalid value has been passed is dependent on the
processing system and may result in unintended behavior.

Sub IDs a2, b2, c2, d2:

• To avoid duplicate modeling of the same guard process in Simulink and Stateflow, use Simulink to
perform arithmetic operations

Verification
Model Advisor check: Adherence to this modeling guideline cannot be verified by using a Model
Advisor check.

Last Changed
R2020a

4-147
4 Stateflow

See Also
• “Library Development” (Embedded Coder)

Version History
Introduced in R2020a

4-148
Label Description

Label Description

4-149
4 Stateflow

jc_0732: Distinction between state names, data


names, and event names

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

An identical name shall not be used for states, data (inputs and outputs, local data, constants,
parameters, data store memory), or event names in a single Stateflow Chart.
Custom Parameter

Not Applicable

4-150
jc_0732: Distinction between state names, data names, and event names

Example — Correct

Example — Incorrect

Names are duplicated.

Rationale
Sub ID a:

• Using unique names prevent misunderstanding.

Verification
Model Advisor check: “Check uniqueness of Stateflow state, data and event names” (Simulink Check)

4-151
4 Stateflow

Last Changed
R2020a

Version History
Introduced in R2020a

4-152
jc_0730: Unique state name in Stateflow blocks

jc_0730: Unique state name in Stateflow blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

State names in Stateflow Chart block shall be unique.

The content of linked atomic subcharts can be treated as another Stateflow Chart block.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Readability is impaired.
• Deviation from the rule can cause unintended code behavior.

Verification
Model Advisor check: “Check uniqueness of State names” (Simulink Check)

Last Changed
R2020a

4-153
4 Stateflow

See Also
• “Represent Operating Modes by Using States” (Stateflow)
• “Atomic Subcharts” (Stateflow)

Version History
Introduced in R2020a

4-154
jc_0731: State name format

jc_0731: State name format

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The state name shall be followed by a new line that does not include a slash (/).
Custom Parameter

Not Applicable
Example — Correct

Example — Incorrect

Rationale
Sub ID a:

4-155
4 Stateflow

• Readability improves when state names are described consistently.

Verification
Model Advisor check: “Check usage of State names” (Simulink Check)

Last Changed
R2020a

See Also
• “Represent Operating Modes by Using States” (Stateflow)

Version History
Introduced in R2020a

4-156
jc_0501: Format of entries in a State block

jc_0501: Format of entries in a State block

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

A state action statement shall not be written on the same line as a state action type.

Custom Parameter

Not Applicable

Example — Correct

4-157
4 Stateflow

Example — Incorrect

Rationale
Sub ID a:

• Readability is impaired.

Verification
Model Advisor check: “Check entry formatting in State blocks in Stateflow charts” (Simulink Check)

Last Changed
R2020a

See Also
• “Represent Operating Modes by Using States” (Stateflow)

Version History
Introduced in R2020a

4-158
jc_0736: Uniform indentations in Stateflow blocks

jc_0736: Uniform indentations in Stateflow blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a, b, c

MATLAB Versions
All

Rule
Sub ID a

State action types shall not have blank spaces at the start of a line.

Executable statements shall have one single-byte space at the start of the line.
Custom Parameter

Number of single-byte spaces


Example — Correct

Executable statements use one single-byte space at the start of the line.

4-159
4 Stateflow

Example — Incorrect

Executable statements do not have a single-byte space at the start of the line.

Sub ID b

A blank space shall not be entered before the following:

• [ of a transition condition
• { of a condition action
• / of a transition action

Custom Parameter

Not Applicable
Example — Correct

A blank space is not entered before the [ and { of the transition label condition, condition action, and
transition action.

Example — Incorrect

A blank space is entered before the [ and { of the transition label condition, condition action, and
transition action.

4-160
jc_0736: Uniform indentations in Stateflow blocks

Sub ID c

At least one single-byte space shall be entered after the / of a transition action.
Custom Parameter

Number of single-byte spaces


Example — Correct

Single-byte spaces are entered after the / of the transition action.

Example — Incorrect

There are no single-byte spaces after the / of the transition action.

Rationale
Sub ID a:

• Using uniform indents before the executable statement clarifies the link between the state action
type of a state label and the execution statement, improving readability.

Sub ID b:

• Using uniform indents for transition conditions, condition actions, and transition actions improves
readability.

Sub ID c:

• Consistent use of blank spaces improves readability.

4-161
4 Stateflow

Verification
Model Advisor check: “Check indentation of code in Stateflow states” (Simulink Check)

Last Changed
R2020a

See Also
• “Transition Between Operating Modes” (Stateflow)

Version History
Introduced in R2020a

4-162
jc_0770: Position of transition label

jc_0770: Position of transition label

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a1/a2/a3

MATLAB Versions
All

Rule
Sub ID a1

Transition labels are positioned near the source of the transition line.
Custom Parameter

Not Applicable
Example — Correct

Transition labels are positioned at the point of origin.

4-163
4 Stateflow

Example — Incorrect

The positioning of transition labels is inconsistent and do not correspond to the transition line.

Sub ID a2

Transition labels are positioned near the center of the transition line.
Custom Parameter

Not Applicable
Example — Correct

Transition labels are positioned near the center of the transition line.

4-164
jc_0770: Position of transition label

Example — Incorrect

The positioning of transition labels is inconsistent and do not correspond to the transition line.

Sub ID a3

Transition labels are positioned as follows:

• Transition labels including transition conditions shall be placed near the source of transition lines.
• Transition labels without transition conditions shall be placed near the destination of transition
lines.

4-165
4 Stateflow

Exception

Not applicable for comment-only transition labels.


Custom Parameter

Not Applicable
Example — Correct

Transition labels including transition conditions are placed near sources of transition lines and those
without transition conditions are placed near destinations of transition lines.

Example — Incorrect

Transition labels without transition conditions are not placed near destinations of transition lines.

Rationale
Sub IDs a1, a2:

• Consistent positioning of transition labels makes the correspondence between label and line
easier to understand.

Verification
Model Advisor check: “Check placement of Label String in Transitions” (Simulink Check)

4-166
jc_0770: Position of transition label

Last Changed
R2024b

See Also
• “Transition Between Operating Modes” (Stateflow)

Version History
Introduced in R2020a

4-167
4 Stateflow

jc_0771: Comment position in transition labels

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a1/a2
• JMAAB — a1/a2

MATLAB Versions
All

Rule
Sub ID a1

Comments in transition labels shall be positioned above transition conditions, condition actions,
transition actions, and Stateflow events.
Custom Parameter

Not Applicable
Example — Correct

The position of the comments in the transition label is uniform.

4-168
jc_0771: Comment position in transition labels

Example — Incorrect

The position of the comments in the transition label is inconsistent.

Sub ID a2

Comments in transition labels shall be positioned below transition conditions, condition actions,
transition actions, and Stateflow events.
Custom Parameter

Not Applicable
Example — Correct

The position of the comments in the transition label is uniform.

4-169
4 Stateflow

Example — Incorrect

The position of the comments in the transition label is inconsistent.

Rationale
Sub IDs a1, a2:

• Uniform positioning of comments in transition labels clarifies to which transition condition,


condition action, transition action, or Stateflow event the label corresponds.

Verification
Model Advisor check: “Check position of comments in transition labels” (Simulink Check)

Last Changed
R2020a

See Also
• “Transition Between Operating Modes” (Stateflow)
• “Add Descriptive Comments in a Chart” (Stateflow)

Version History
Introduced in R2020a

4-170
jc_0752: Condition action in transition label

jc_0752: Condition action in transition label

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Parentheses in condition actions shall use only curly brackets on a single line.

A new line shall start before and after curly brackets.


Custom Parameter

Not Applicable
Example — Correct

Note: The example is for a flow chart, but the rule also applies to state transitions.

Example — Incorrect

4-171
4 Stateflow

Rationale
Sub ID a:

• Clarifying condition actions improves readability.

Verification
Model Advisor check: “Check usage of parentheses in Stateflow transitions” (Simulink Check)

Last Changed
R2020a

See Also
• “Transition Between Operating Modes” (Stateflow)

Version History
Introduced in R2020a

4-172
jc_0774: Comments for through transition

jc_0774: Comments for through transition

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When there is no processing within an unconditional transition, a clarifying comment shall be written
on the transition label.
Custom Parameter

Not Applicable
Example — Correct

The clarifying comment /*do nothing*/ is provided.

4-173
4 Stateflow

Example — Incorrect

A clarifying comment is not provided on the condition path, so it is difficult to determine whether the
lack of action is intentional.

4-174
jc_0774: Comments for through transition

Rationale
Sub ID a:

• Clarifies that the processing is deliberately excluded.


• The comment that is added to a transition label is also included in the generated code.

Verification
Model Advisor check: “Check for comments in unconditional transitions” (Simulink Check)

Last Changed
R2020a

See Also
• “Add Descriptive Comments in a Chart” (Stateflow)
• “Transition Between Operating Modes” (Stateflow)

Version History
Introduced in R2020a

4-175
4 Stateflow

Miscellaneous

4-176
jc_0511: Return values from a graphical function

jc_0511: Return values from a graphical function

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — No recommendations
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The return value for graphical functions shall be set in one place only.

Custom Parameter

Not Applicable

Example — Correct

4-177
4 Stateflow

Example — Incorrect

Rationale
Sub ID a:

• Modifications to the output name is limited to prevent the changes from being missed or
overlooked.

Verification
Model Advisor check: “Check return value assignments in Stateflow graphical functions” (Simulink
Check)

Last Changed
R2020a

See Also
• “Create Flow Charts in Stateflow” (Stateflow)
• “Create Flow Charts by Using Pattern Wizard” (Stateflow)

4-178
jc_0511: Return values from a graphical function

Version History
Introduced in R2020a

4-179
4 Stateflow

jc_0804: Prohibited use of recursive calls with


graphical functions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Calls from a graphical function to itself and calls between graphical functions shall be prohibited.
Custom Parameter

Not Applicable
Example — Correct

Processing is performed within the graphical function.

Example — Incorrect

The graphical function is calling itself.

4-180
jc_0804: Prohibited use of recursive calls with graphical functions

Graphical functions are calling each other.

Rationale
Sub ID a:

• Readability decreases. Deviation from the rule can cause unintended overflows and infinite loops.

Verification
Adherence to this modeling guideline cannot be verified by using a Model Advisor check. For more
information, see “Check usage of graphical functions in Stateflow” (Simulink Check).

Last Changed
R2020a

See Also
• “Reuse Logic Patterns by Defining Graphical Functions” (Stateflow)
• “How Stateflow Objects Interact During Execution” (Stateflow)

4-181
4 Stateflow

Version History
Introduced in R2020a

4-182
na_0042: Usage of Simulink functions

na_0042: Usage of Simulink functions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

When using a Simulink Function block in a Stateflow Chart, one or more of the following conditions
shall be met:

• Input/output variables shall use only local Stateflow Chart data and input data in the Simulink
Function block.
• The Simulink Function block shall be called from multiple places in the Stateflow Chart.
• The Simulink Function block shall not be called at every time step.

Custom Parameter

Not Applicable
Example — Correct

The Simulink Function block lookup1D is not called from every time step and, therefore, can be used.

4-183
4 Stateflow

Example — Incorrect

The Simulink Function block lookup1D is called from every time step and, therefore, cannot be used
(out is the Stateflow output data)

Rationale
Sub ID a:

• To improve model readability, the use of the Simulink Function block should be used with caution
in charts.

Verification
Model Advisor check: “Check usage of Simulink function in Stateflow” (Simulink Check)

Last Changed
R2020a

See Also
• “Simulink Functions Overview”
• “Define a Simulink Function in a Model”

Version History
Introduced in R2020a

4-184
na_0039: Limitation on Simulink functions in Chart blocks

na_0039: Limitation on Simulink functions in Chart


blocks

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Stateflow blocks shall not be used in Simulink Function blocks that are included in a Stateflow Chart.
Custom Parameter

Not Applicable

4-185
4 Stateflow

Example — Incorrect

Rationale
Sub ID a:

• Readability decreases and can result in design errors.

Verification
Model Advisor check: “Check use of Simulink in Stateflow charts” (Simulink Check)

Last Changed
R2020a

See Also
• “Simulink Functions Overview”
• “Define a Simulink Function in a Model”

4-186
na_0039: Limitation on Simulink functions in Chart blocks

Version History
Introduced in R2020a

4-187
5

MATLAB

• “MATLAB Appearance” on page 5-2


• “MATLAB Data and Operations” on page 5-7
• “MATLAB Usage” on page 5-15
5 MATLAB

MATLAB Appearance

5-2
na_0025: MATLAB Function header

na_0025: MATLAB Function header

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

The MATLAB Function block shall have a descriptive header.

Information in the header can include, but is not limited to:

• Function name
• Description of function
• Assumptions and limitations
• Description of changes from previous versions
• Lists of inputs and outputs

Custom Parameter

Not Applicable
Example

%% Function Name: NA_0025_Example_Header


%
% Description: An example of a header file
%
% Assumptions: None
%
% Inputs:
% List of input arguments
%
% $Revision: R2020a$
% $Author: MathWorks Advisory Board (MAB)$

5-3
5 MATLAB

% $Date: November 20, 2019$


%---------------------------------------------------------

Rationale
Sub ID a:

• Improves readability, model simulation, testability, and workflow.


• Code generation may not be possible.

Verification
Adherence to this modeling guideline cannot be verified by using a Model Advisor check.

Last Changed
R2020a

See Also
• “Implement MATLAB Functions in Simulink with MATLAB Function Blocks”

Version History
Introduced in R2020a

5-4
na_0018: Number of nested if/else and case statement

na_0018: Number of nested if/else and case


statement

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

The number of nested levels in if /else and case statements shall be limited, typically to three
levels.
Custom Parameter

Maximum nested levels

Rationale
Sub ID a:

• Improves readability
• Code generation may not be possible.

Verification
Model Advisor check: “Check nested conditions in MATLAB Functions” (Simulink Check)

Last Changed
R2020a

5-5
5 MATLAB

See Also
• “Loops and Conditional Statements”

Version History
Introduced in R2020a

5-6
MATLAB Data and Operations

MATLAB Data and Operations

5-7
5 MATLAB

na_0024: Shared data in MATLAB functions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Signal lines shall be used to connect data that is shared between MATLAB Function blocks.
Custom Parameter

Not Applicable
Example — Correct

function ErrorFlag = EngineFaultEvaluation(EngineData,ErrorFlag_In)


%#codegen
RMP_HIGH = 10000;
RMP_LOW = 10;

5-8
na_0024: Shared data in MATLAB functions

HIGHRPMFAULT = 2^1;
LOWRPMFAULT = 2^2;
ErrorFlag = ErrorFlag_In;
if EngineData > RPM_HIGH
ErrorFlag = bitor(ErrorFlag,HIGHRPMFAULT);
end
if EngineData < RPM_LOW
ErrorFlag = bitor(ErrorFlag,LOWRPMFAULT);
end

function ErrorFlag = WheelFaultEvaluation(WheelData,ErrorFlag_In)


%#codegen
SLIP_HIGH = 1000;
WHEELSLIP = 2^3;
ErrorFlag = ErrorFlag_In;
if WheelData > SLIP_HIGH
ErrorFlag = bitor(ErrorFlag,WHEELSLIP);
end
end

Example — Incorrect

function EngineFaultEvaluation(EngineData)
%#codegen
global ErrorFlag_DataStore
RMP_HIGH = 10000;
RMP_LOW = 10;
HIGHRPMFAULT = 2^1;
LOWRPMFAULT = 2^2;
if EngineData > RPM_HIGH
ErrorFlag_DataStore = bitor(ErrorFlag_DataStore,HIGHRPMFAULT);
end
if EngineData < RPM_LOW
ErrorFlag_DataStore = bitor(ErrorFlag_DataStore,LOWRPMFAULT);
end

function WheelFaultEvaluation(WheelData)
%#codegen
global ErrorFlag_DataStore
SLIP_HIGH = 1000;
WHEELSLIP = 2^3;
if WheelData > SLIP_HIGH
ErrorFlag_DataStore = bitor(ErrorFlag_DataStore,WHEELSLIP);
end

5-9
5 MATLAB

end

Rationale
Sub ID a:

• When a data store is used, the readability of the data flow decreases and can lead to errors in the
update reference timing.

Verification
Model Advisor check: “Check MATLAB code for global variables” (Simulink Check)

Last Changed
R2020a

See Also
• “Implement MATLAB Functions in Simulink with MATLAB Function Blocks”
• “Signal Lines”
• “Resolve Signal Objects for Output Variables”

Version History
Introduced in R2020a

5-10
na_0031: Definition of default enumerated value

na_0031: Definition of default enumerated value

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Method getDefaultValue() shall be used to explicitly define the default value of an enumeration.
Custom Parameter

Not Applicable
Example — Correct

See “Specify a Default Enumerated Value”

classdef BasicColors < Simulink.IntEnumType


enumeration
Red(0)
Yellow(1)
Blue(2)
end
methods (Static)
function retVal = getDefaultValue()
retVal = BasicColors.Blue;
end
end
end

Example — Incorrect

classdef(Enumeration) BasicColors < Simulink.IntEnumType


enumeration
Red(0)
Yellow(1)
Blue(2)

5-11
5 MATLAB

end
end

Rationale
Sub ID a:

• When an enumerated type does not have a clearly defined a default value, the first enumeration
string that is described will be defined as the default, which may not be as intended.

Verification
Model Advisor check: “Check usage of enumerated values” (Simulink Check)

Last Changed
R2020a

See Also
• “Use Enumerated Data in Simulink Models”
• “Define Enumerated Data Types” (Stateflow)
• “Instantiate Enumerations”

Version History
Introduced in R2020a

5-12
na_0034: MATLAB Function block input/output settings

na_0034: MATLAB Function block input/output


settings

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

The data type in the model explorer shall be defined for input and output to the MATLAB Function
block.
Custom Parameter

Not Applicable

Rationale
Sub ID a:

• Defining the data type for input and output to the MATLAB Function block helps prevent
simulation errors and unexpected behavior.

Verification
Model Advisor check: “Check input and output settings of MATLAB Functions” (Simulink Check)

Last Changed
R2020a

5-13
5 MATLAB

See Also
• “Implement MATLAB Functions in Simulink with MATLAB Function Blocks”

Version History
Introduced in R2020a

5-14
MATLAB Usage

MATLAB Usage

5-15
5 MATLAB

na_0016: Source lines of MATLAB Functions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

The length of MATLAB functions shall be limited. The recommended limit is 60 lines of code. Sub-
functions can use an additional 60 lines of code.

This restriction applies to MATLAB functions that reside in the Simulink block diagram and external
MATLAB files with a .m extension.
Custom Parameter

Maximum effective lines of code per function

Rationale
Sub ID a:

• Improves readability and workflow


• Code generation may not be possible.

Verification
Model Advisor check: “Check lines of code in MATLAB Functions” (Simulink Check)

Last Changed
R2020a

5-16
na_0016: Source lines of MATLAB Functions

See Also
• “Integrate MATLAB Functions in a Stateflow Charts” (Stateflow)
• “Implement MATLAB Functions in Simulink with MATLAB Function Blocks”

Version History
Introduced in R2020a

5-17
5 MATLAB

na_0017: Number of called function levels

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

The number of sub-function levels shall be limited, typically to three levels.

MATLAB Function blocks that reside in the Simulink block diagram level counts as the first level,
unless it is simply a wrapper for an external MATLAB file with a .m extension. This includes functions
that are defined within the block and those in separate .m files.
Exclusions

The following function types are excluded from the number of levels:

• Standard utility functions, such as built-in functions sqrt or log


• Commonly used custom utility functions

Custom Parameter

Maximum function call levels

Rationale
Sub ID a:

• Improves readability and testability

Verification
Model Advisor check: “Check the number of function calls in MATLAB Function blocks” (Simulink
Check)

5-18
na_0017: Number of called function levels

Last Changed
R2020a

See Also
• “Implement MATLAB Functions in Simulink with MATLAB Function Blocks”
• “Integrate MATLAB Functions in a Stateflow Charts” (Stateflow)
• “Exponents and Logarithms”

Version History
Introduced in R2020a

5-19
5 MATLAB

na_0021: Strings in MATLAB functions

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

Assignment statements for strings shall not be used in MATLAB functions.


Custom Parameter

Not Applicable
Example — Incorrect

An assignment statement for strings is being used in the MATLAB function.


function y = fcn(u)
%#codegen

str = 'A';

for i = 1:u
str = [str 'B'];
end

if strcmp(str, 'ABB')
y = int16(1);
else
y = int16(0);
end
end

Rationale
Sub ID a:

5-20
na_0021: Strings in MATLAB functions

• MATLAB functions store strings as character arrays. As a result, storing strings of different
lengths in the same variable does not support dynamic memory allocation, which prevents the
strings from being stored.

Consider using enumerated types when a string is used in a Switch Case block

Verification
Model Advisor check: “Check usage of character vector inside MATLAB Function block” (Simulink
Check)

Last Changed
R2020a

See Also
• “Implement MATLAB Functions in Simulink with MATLAB Function Blocks”
• “Integrate MATLAB Functions in a Stateflow Charts” (Stateflow)

Version History
Introduced in R2020a

5-21
5 MATLAB

na_0022: Recommended patterns for Switch/Case


statements

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — Not supported

MATLAB Versions
All

Rule
Sub ID a

Switch/Case statements shall use constant values for Case arguments.

Input variables shall not be used in Case arguments.


Custom Parameter

Not Applicable
Example — Correct

function outVar = NA_0022_Pass(SwitchVar)


%#codegen
switch SwitchVar
case Case_1_Parameter % Parameter
outVar = 0;
case NA_0022.Case_2 % Enumerated Data Type
outVar = 2;
otherwise
outVar = 10;
end
end

Example — Incorrect

function outVar = NA_0022_Fail(Case_1,Case_2,Case_3,SwitchVar)


%#codegen
switch SwitchVar
case Case_1

5-22
na_0022: Recommended patterns for Switch/Case statements

outVar = 1;
case Case_2
outVar = 2;
case Case_3
outVar = 3;
otherwise
outVar = 10;
end
end

Rationale
Sub ID a:

• Improves model simulation and testability.


• Code generation may not be possible.

Verification
Model Advisor check: “Check usage of recommended patterns for Switch/Case statements” (Simulink
Check)

Last Changed
R2020a

See Also
• “Loops and Conditional Statements”

Version History
Introduced in R2020a

5-23
5 MATLAB

jc_0801: Prohibited use of the /* and */ comment


symbols

Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB, Simulink, and Stateflow

• Version 6.0

Sub ID Recommendations
• NA-MAAB — a
• JMAAB — a

MATLAB Versions
All

Rule
Sub ID a

As comment symbols /* and */ are automatically assigned in the generated code, the symbol shall
not be used in:

• Code Generate Templates (.cgt) files


• mpt.Signal description
• mpt.Parameter description

Custom Parameter

Not Applicable
Example — Incorrect

Included in a .cgt file.

5-24
jc_0801: Prohibited use of the /* and */ comment symbols

Included in the mpt.Signal description.

Rationale
Sub ID a:

• Since comment symbols /* and */ are automatically assigned in the generated code, comments
can be unintentionally nested and behave differently than expected.

Verification
Model Advisor check: “Check for use of C-style comment symbols” (Simulink Check)

Last Changed
R2020a

5-25
5 MATLAB

See Also
• “Code Generation Template (CGT) Files” (Embedded Coder)
• “MPT Data Object Properties” (Embedded Coder)
• “Specify Comment Style for C/C++ Code” (Embedded Coder)
• “Add Custom Comments for Variables in the Generated Code” (Embedded Coder)

Version History
Introduced in R2020a

5-26
6

Considerations

• “Considerations for Determining Guideline Operation Rules” on page 6-2


• “Considerations for Applying Guidelines to a Project” on page 6-5
6 Considerations

Considerations for Determining Guideline Operation Rules


Prior to selecting the modeling guidelines to adopt for your project, it is important that you consider
various aspects of your project and models, such as:

• “Process Definition and Development Environment” on page 6-2


• “MATLAB and Simulink Versions” on page 6-2
• “MATLAB and Simulink Settings” on page 6-2
• “Usable Blocks” on page 6-3
• “Using Optimization and Configuration Parameters” on page 6-3

Process Definition and Development Environment


The model base development that utilizes simulation is suitable for developing a safe product.
However, this does not mean that a system is safe simply because the design can be simulated. While
high quality control and functions is necessary, the process definition and development environment
being used is equally important. The foundation for a safe system is determined at the start of the
project, long before development begins.

MATLAB and Simulink Versions


The version of MATLAB and Simulink that is used at each development stage is determined at the
start of the project. That version must be used by everyone during that development stage.

Different MATLAB versions can be used for different stages in the development process. For example,
you can generate and verify the code in R2017b and then use Simulink Design Verifier™ to develop
test cases in R2020a.

It is necessary to regularly check the bug report published by MathWorks, which are available on the
MathWorks website at https://www.mathworks.com/support/bugreports. Depending on the bug, a
version change may be required; a decision that can be reversed if necessary. During this evaluation,
it is important to consider risk from both:

• Malfunctions that result from a bug


• Result from upgrading the version

It is necessary to always have a process that allows adaptation to the latest version and to
appropriately evaluate and judge what is the safest option.

MATLAB and Simulink Settings


MATLAB and Simulink settings shall adhere to the project. It is important that Simulink settings that
affect appearance are applied consistently across the project.

Options to be unified include:

• Simulink environment settings:

• New model standard font settings (block, line, annotation)


• Mask (Edit mask):

6-2
Considerations for Determining Guideline Operation Rules

• Icons and Ports


• Information display:

• Library links
• Sample Time
• (Block) Sorted execution order
• (Signals and ports) Wide Non-scalar Lines
• (Signals and ports) Port data types

See guidelines:

• na_0004: Simulink model appearance settings


• db_0043: Model font and font size

Usable Blocks
There are many blocks in Simulink, however, not all are suitable for all aspects of a project. For
example, only some blocks are suitable for generating production-quality code. Or, depending on the
block, a function using a combination of basic blocks can be represented by using one block. Usable
blocks and design should be defined and limited to the requirements and specifications of the project.

Significantly limiting the number of available blocks can cause adverse effects, such decreased
readability due to variation within the descriptions for the same function, decreased code efficiency,
and increased user libraries.

You must register custom blocks in the project’s user library.

See guideline db_0143: Usable block types in model hierarchy for defining usable blocks

Using Optimization and Configuration Parameters


It is important to consider how you are using optimization options and configuration parameters for
your project.

Optimization Parameters

Optimization options significantly affect generated code. Closely evaluate and apply the optimization
options with regards to how they impact the security and safety considerations for your project or
product.

As an example of how optimization parameters can impact a process:

For embedded automotive products, it is critical that processing time is fast and RAM/ROM
requirement are minimal. To accommodate these requirements, optimization parameters are applied
on the Conditional Input Branch Execution pane. These optimization parameters improve the
computation rate by executing only where the condition holds during execution of the conditional
branch by using the Switch block.

In contrast, for the aviation industry, the Conditional Input Branch Execution pane is disabled
because stabilizing the execution speed is key. Calculation on both sides is preferred in order to
maintain a stable computation time, even if calculation is needed only on the side where the condition
holds.

6-3
6 Considerations

Configuration Parameters

Consider these configuration parameters:

Hardware Implementation Settings

Describes model system hardware characteristics, including products and test hardware
configuration setup for simulation and code generation. Configure these parameters so they are
compatible with the microcomputer that the project uses. Unintended utility functions can be
inserted if signed integer division rounding is undefined.

Model Reference Settings

Specified when using model references. Refers to options to include other models in this model,
options to include this model in another model, and build options of simulation and code generation
targets.

Simulation Target Setting

Configures a simulation target of a model with MATLAB Function, Stateflow Chart (Stateflow), or
Truth Table (Stateflow) blocks.

High-Integrity Configuration Settings

For additional information about the high-integrity configuration settings, see “Configuration
Parameter Considerations” in the “High-Integrity System Modeling” guidelines.

Code Generation Configuration Settings

For additional information the about the code generation configuration settings, see the “Code
Generation” modeling guidelines.

6-4
Considerations for Applying Guidelines to a Project

Considerations for Applying Guidelines to a Project


It is important that you consider the following when applying modeling guidelines to a project:

• “Using the Model Analysis Process When Applying Guidelines” on page 6-5
• “Adoption of the Guideline Rule and Process Settings” on page 6-5
• “Setting the Guideline Rule Application Field and the Clarifying the Exclusion Condition” on page
6-5
• “Parameter Recommendations in the Guidelines” on page 6-6
• “Verifying Adherence to the Guidelines” on page 6-6
• “Modifying Adherence to the Guidelines” on page 6-6

Using the Model Analysis Process When Applying Guidelines


Model design specification should be defined prior to reviewing the guidelines. Doing so makes the
process of determining which guidelines to apply and the implementation of the guidelines more
efficient.

For example, the analysis of a simple model can use function sldiagnostics to investigate how
often a specific block is used. Adjust the operation rules list by specifying blocks that are frequently
used and those that are not.

Furthermore, reusability at a later stage is improved by adding rules that:

• Unify description styles


• Anticipate in advance the man-hours needed to correct models
• Measuring tendencies, such as where to place blocks that have feedback status variables (Unit
Delay block), whether the Unit Delay block should be inside or outside the subsystem, or whether
the Abs block should be set on the output side of the subsystem, and if it should process at the
input side after receiving a signal.

Adoption of the Guideline Rule and Process Settings


At the start of the project, it should be determined which guidelines apply to each development
process. The guidelines should be evaluated and applied so that they correspond with the
development process. Considerations may include questions such as:

• Will the guideline be applied only at the code generation stage?


• Will the adopted guideline rule change for each process stage?

Setting the Guideline Rule Application Field and the Clarifying the
Exclusion Condition
The field to which the guidelines apply must be determined. For example, guidelines can be:

• Limited to a model that represents the AUTOSAR field of application


• Applied to a general software field, such as where models implement interrupts (add processes
that prohibit interruption during calculation).

6-5
6 Considerations

• Specific to fields where general engineers edit the models. The intention of these rules is to
ensure that the models are easily understandable in those fields.

Note Specialized fields can be excluded from the constraints of these guidelines by limiting the
scope and applying unique set of guidelines that are specific in this environment.

Specialized fields, such as those where modelers design custom library blocks, are not typically
targeted by these guidelines.

Furthermore, when having a control model that is operated with Rapid Control Prototyping (RCP) ,
the entire model should not be set as a target; instead, the field needs to be limited. It is necessary to
generate the code and review the areas that are implemented in the built-in microcomputer as well as
the areas that are not. These guidelines do not apply to control models such as those scheduler
models that are made solely for RCP and are not implemented, or for interface sections with blocks
that correspond to drivers such as CAN and PWM signals for operating actual machines.

Parameter Recommendations in the Guidelines


Guidelines should not be adopted as they are written without further evaluation.

Implementation of guideline rules and parameter recommendations should be evaluated to determine


the impact on the project and the development processes being used. In addition, consideration
needs to be taken as to the effect on other guidelines and how applying custom parameters can affect
simulation or code generation.

Verifying Adherence to the Guidelines


At the beginning of a project, it is important to determine how and when the project will be evaluated
to ensure adherence to the guidelines.

The decision whether to use an automated checking mechanism (third part or internal) or perform
manual checks is very important. Also, the stage at which the checks occur, as well as developing a
system for revising the check rule criteria, is important.

Automated checking can significantly reduce the time required for review. It is recommended that an
additional, manual review also be performed by a skilled person, even if everything can be checked
automatically.

Modifying Adherence to the Guidelines


The decision to apply a guideline or a rule can change. When doing so, it is important to specify a
process and procedure for determine the root cause of the request and evaluate the potential impact
the change can have on the project and the organization.

When evaluating the change request, first listen to the needs of the modeler and determine the root
cause of the request. When the request is based on the user not understanding block usage or a
guideline rule, training should occur instead of revising the rule.

The procedure to relax the rules as needed should be implemented when there are restrictions due to
company objectives and control specifications or hardware (such as microcomputers).

6-6
A

Using Simulink and Stateflow


A Understanding Model Architecture

Understanding Model Architecture


When evaluating the modeling guidelines for your project, it is important that you understand the
architecture of your controller model, such the function/subfunction layers, schedule layer, control
flow layer, section layer, and data flow layer.

Hierarchical Structure of a Controller Model


This section provides a high-level overview of the hierarchical structuring in a basic model, using a
controller model as an example. This table defines the layer concepts in a hierarchy.

Layer concept Layer purpose


Top Function layer Broad functional division
Schedule layer Expression of execution timing
Layer
(sampling, order)
Bottom Sub function layer Detailed function division
Control flow layer Division according to processing
Layer
order (input → judgment →
output, etc.)
Selection layer Division (select output with
Merge) into a format that
switches and activates the
active subsystem
Data flow layer Layer that performs one
calculation that cannot be
divided

When applying layer concepts:

• Layer concepts shall be assigned to layers and subsystems shall be divided accordingly.
• When a layer concept is not needed, it does not need to be allocated to a layer.
• Multiple layer concepts can be allocated to one layer.

When building hierarchies, division into subsystems for the purpose of saving space within the layer
shall be avoided.

Top Layer

Layout methods for the top layer include:

• Simple control model — Represents both the function layer and schedule layer in the same layer.
Here, function is execution unit. For example, a control model has only one sampling cycle and all
functions are arranged in execution order.
• Complex control model Type α — The schedule layer is positioned at the top. This method makes
integration with the code easy, but functions are divided, and the readability of the model is
impaired.
• Complex control model Type β — Function layers are arranged at the top and schedule layers are
positioned below the individual function layers.

A-2
Understanding Model Architecture

Function Layers and Sub-Function Layers

When modeling function and sub-function layers:

• Subsystems shall be divided by function, with the respective subsystems representing one
function.

• One function is not always an execution unit so, for that reason, the respective subsystem is
not necessarily an atomic subsystem. In the type β example below, it is more appropriate for a
function layer subsystem to be a virtual subsystem. Algebraic loops are created when these
change into atomic subsystems.
• Individual functional units shall be described.
• When the model includes multiple large functions, consider using model references for each
function to partition the model.

A-3
A Understanding Model Architecture

Schedule Layers

When scheduling layers:

• System sampling intervals and execution priority shall be set. Use caution when setting multiple
sampling intervals. In connected systems with varying sampling intervals, ensure that the system
is split for each sampling interval. This minimizes the RAM needed to store previous values in the
situation where the processing of signals values differs for fast cycles and slow cycles.
• Priority ranking shall be set. This is important when designing multiple, independent functions.
When possible, computation sequence for all subsystems should be based on subsystem
connections.
• Two different types of priority rankings shall be set, one for different sampling intervals and the
other for identical sampling rates.

There are two types of methods that can be used for setting sampling intervals and priority rankings:

• For subsystems and blocks, set the block parameter sample time and block properties priority.
• When using conditional subsystems, set independent priority rankings to match the scheduler.

Patterns exist for many different conditions, such as the configuration parameters for custom
sampling intervals, atomic subsystem settings, and the use of model references. The use of a specific
pattern is closely linked to the code implementation method and varies significantly depending on the
status of the project. Models that are typically affected include:

• Models that have multiple sampling intervals


• Models that have multiple independent functions
• Usage of model references

A-4
Understanding Model Architecture

• Number of models (and whether there is more than one set of generated code)

For the generated code, affected factors include:

• Applicability of a real-time operating system


• Consistency of usable sampling intervals and computation cycles to be implemented
• Applicable area (application domain or basic software)
• Source code type: AUTOSAR compliant - not compliant - not supported.

Control Flow Layers

In the hierarchy, the control layer expresses all input processing, intermediate processing, and output
processing by using one function. The arrangement of blocks and subsystems is important in this
layer. Multiple, mixed small functions should be grouped by dividing them between the three largest
stages of input processing, intermediate processing and output processing, which forms the
conceptual basis of control. The general configuration occurs close to the data flow layer and is
represented in the horizontal line. The difference in a data flow layer is its construction from multiple
subsystems and blocks.

In control flow layers, the horizontal direction indicates processing with different significance; blocks
with the same significance are arranged vertically.

A-5
A Understanding Model Architecture

Block groups are arranged horizontally and are given a provisional meaning. Red borders, which
signify the delimiter for processing that is not visible, correspond to objects called virtual objects.
Using annotations to mark the delimiters makes it easier to understand.

A-6
Understanding Model Architecture

Control flow layers can co-exist with blocks that have a function. They are positioned between the
sub-function layer and the data flow layer. Control flow layers are used when:

• The number of blocks becomes too large


• All is described in the data flow layer
• Units that can be given a minimum partial meaning are made into subsystems

Placement in the hierarchy organizes the internal layer configuration and makes it easier to
understand. It also improves maintainability by avoiding the creation of unnecessary layers.

When the model consists solely of blocks and does not include a mix of subsystems, if the horizontal
layout can be split into input/intermediate/output processing, it is considered a control flow layer.

Selection Layers

When modeling selection layers:

• Selection layers should be written vertically or side-by-side. There is no significance to which


orientation is chosen.
• Selection layers shall mix with control flow layers.

When a subsystem has switch functions that allow only one subsystem to run depending on the
conditional control flow inside the red border, it is referred to as a selection layer. It is also described
as a control flow layer because it structures input processing/intermediate processing (conditional
control flow)/output processing.

A-7
A Understanding Model Architecture

In the control flow layer, the horizontal direction indicates processing with different significance.
Parallel processing with the same significance is structured vertically. In selection layers, no
significance is attached to the horizontal or vertical direction, but they show layers where only one
subsystem can run. For example:

• Switching coupled functions to run upwards or downwards, changing chronological order


• Switching the setting where the computation type switches after the first time (immediately after
reset) and the second time
• Switching between destination A and destination B

Data Flow Layers

A data flow layer is the layer below the control flow layer and selection layer.

A data flow layer represents one function as a whole; input processing, intermediate processing and
output processing are not divided. For instance, systems that perform one continuous computation
that cannot be split.

Data flow layers cannot coexist with subsystems apart from those where exclusion conditions apply.
Exclusion conditions include:

• Subsystems where reusable functions are set


• Masked subsystems that are registered in the Simulink standard library
• Masked subsystems that are registered in a library by the user

Example of a simple data flow layer.

A-8
Understanding Model Architecture

Example of a complex data flow layer.

When input processing and intermediate processing cannot be clearly divided as described above,
they are represented as a data flow layer.

A data flow layer becomes complicated when both the feed forward reply and feedback reply from the
same signal are computed at the same time. Even when the number of blocks in this type of cases is
large, the creation of a subsystem should not be included in the design when the functions cannot be
clearly divided. When meaning is attached through division, it should be designed as a control flow
layer.

Relationship Between Simulink Models and Embedded Implementation


Running an actual micro controller requires embedding the code that is generated from the Simulink
model into the micro controller. This requirement affects the configuration Simulink model and is
dependent on:

A-9
A Understanding Model Architecture

• The extent to which the Simulink model will model the functions
• How the generated code is embedded
• The schedule settings on the embedded micro controller

The configuration is affected significantly when the tasks of the embedded micro controller differs
from those modeled by Simulink.

Scheduler Settings in Embedded Software

The scheduler in embedded software has single-task and multi-task settings.

Single-task schedule settings

A single-task scheduler performs all processing by using basic sampling. Therefore, when processing
of longer sampling is needed, the function is split so the CPU load is as evenly distributed as possible,
and then processed using basic sampling. However, as equal splitting is not always possible, functions
may not be able to be allocated to all cycles.

For example, basic sampling is 2 millisecond, and sampling rates of 2 millisecond, 8 millisecond and
10 millisecond exist within the model. An 8 millisecond function is executed once for every four 2
millisecond cycles, and a 10 millisecond function is executed once for every five. The number of
executions is counted every 2 millisecond and the sampling function specified by this frequency is
executed. Attention needs to be paid to the fact that the 2 millisecond, 8 millisecond and 10
millisecond cycles are all computed with the same 2 millisecond. Because all computations need to be
completed within 2 millisecond, the 8 millisecond and 10 millisecond functions are split into several
and adjusted so that all 2 millisecond computations are of an almost equal volume.

The following diagram shows the 8 millisecond function split into 4 and the 10 millisecond function
split into 5.

Functions Fundamental frequency Offset


8millisecond 0millisecond
2-2 8millisecond 2millisecond
2-3 8millisecond 4millisecond
2-4 8millisecond 6millisecond
3-1 10millisecond 0millisecond
3-2 10millisecond 2millisecond
3-3 10millisecond 4millisecond
3-4 10millisecond 6millisecond
3-5 10millisecond 8millisecond

A-10
Understanding Model Architecture

To set frequency-divided tasking:

1 Clear configuration parameter Treat each discrete rate as a separate task.


2 For the Atomic Subsystem block parameter Sample time, enter the sampling period offset
values. A subsystem for which a sampling period can be specified is referred to as an atomic
subsystem.

A-11
A Understanding Model Architecture

Multi-task scheduler settings

Multi-task sampling is executed by using a real-time OS that supports multi-task sampling. In


single-task sampling, equalizing the CPU load is not done automatically, but a person divides the
functions and allocates them to the appointed task. In multi-task sampling, the CPU performs the
computations automatically in line with the current status; there is no need to set detailed
settings. Computations are performed and results are output starting from the task with the
highest priority, but the task priorities are user-specified. Typically, fast tasks are assigned
highest priority. The execution order for this task is user-specified.

A-12
Understanding Model Architecture

It is important that computations are completed within the cycle, including slow tasks. When the
processing of a high priority computation finishes and the CPU is available, the computation for
the system with the next priority ranking begins. A high priority computation process can
interrupt a low priority computation, which is then aborted so the high priority computation
process can execute first.

Effect of Connecting Subsystems with Sampling Differences

If subsystem B with a 20 millisecond sampling interval uses the output of subsystem A with a 10
millisecond sampling interval, the output result of subsystem A can change while subsystem B is
computing. If the values change partway through, the results of subsystem B’s computation may not
be as expected. For example, a comparison is made in subsystem B’s first computation with the
subsystem A output, and the result is computed with the conditional judgment based on this output.
At this point, the comparison result is true. It is then compared again at the end of subsystem B; if the
output from A is different, then the result of the comparison can be false. Generally, in this type of
function development it may happen that the logic created with true, true has become true, false, and
an unexpected computation result is generated. To avoid this type of malfunction, when there is a
change in task, output results from subsystem A are fixed immediately before they are used by
subsystem B as they are used in a different RAM from that used by the subsystem A output signals. In
other words, even if subsystem A values change during the process, the values that subsystem B are
looking at is in a different RAM, so no effect is apparent.

When a model is created in Simulink and a subsystem is connected that has a different sampling
interval in Simulink, Simulink automatically reserves the required RAM.

However, if input values are obtained with a different sampling interval through integration with
hand-coded code, the engineer who does the embedding work should design these settings. For
example, in the RTW concept using AUTOSAR, different RAMs are all defined at the receiving and
exporting side.

A-13
A Understanding Model Architecture

Single-task scheduler settings

Signal values are the same within the same 2 millisecond cycle, but when there are different 2
millisecond cycles, the computation value differs from the preceding one. When Function 2-1 and 2-2
uses signal A of Function 1, be aware that 2-1 and 2-2 uses results from different times.

Multi-task scheduler settings

For multi-task, you cannot specify at what point to use the computation result to use. With multi-task,
always store signals for different tasks in new RAM.

Before new computations are performed within the task, all values are copied.

A-14
Understanding Model Architecture

A-15
A Using Simulink and Stateflow in Modeling

Using Simulink and Stateflow in Modeling


When using Stateflow, Simulink is required for inputs, outputs, and structuring. Stateflow alone can
perform a variety of formula processing. When using Simulink, complex state variables can be
realized through methods, such as using the Switch Case block.

Either Simulink or Stateflow can be used to model specific parts of control, however, the application
of either product in the development workflow is based on the user’s understanding of the underlying
algorithms and, ultimately, comes down to the organization to determine which tool is best suited for
their needs. Determining whether Simulink or Stateflow should be used for design should be
determined by a group of people in accordance with the task. Whether implementation in Stateflow is
done by using state transitions or with flow charts should also be specified.

In most cases, Stateflow is less efficient with regards to RAM. Therefore, Simulink has an advantage
in computations that use simple formulas. In addition, Simulink is more advantageous for situations
where state variables are operated with simple flip-flops and the Relay block. When evaluating
whether to use Simulink or Stateflow in a project, these topics should be taken into consideration:

• Increasing RAM: There must always be a RAM available for visualization of Stateflow inputs,
outputs and internal variables.
• Equation error handling: When general computational formulas are used internally, the user
designs ways to prevent overflow.
• Splitting and separating functions: When performing calculations that use Simulink outside of
Stateflow, there is a possibility that they may split, thus reducing readability. There are also times
where readability may improve. This can be difficult to judge.

There are cases where Stateflow has more efficient code than Simulink for optimum expressions that
are close to code, but most of these result in a model that is difficult to understand. If code already
exists, it is more advantageous to use S-functions instead of Stateflow modelling. Stateflow can note
computations where specific arrangements are specified, or computations using for-loops, more
efficiently than Simulink, but in recent years it has also become convenient to use MATLAB language
for descriptions. If needed, consider using MATLAB language for modelling.

For Stateflow models, when dealing with states as described below, readability improves by
describing them as state transitions:

• Different output values are output for identical inputs.


• Multiple states exist (as a guide, three or more).
• States with meaningful names instead of just numbers.
• Inside a state, initialization (first time) and differentiation during execution (after the second time)
is required.

For instance, in flip-flop circuits, different values are outputted for inputs. State variables are limited
to 0 and 1. However, a meaningful name cannot be added to each state simply by retaining boolean
type numbers. There is also no distinction between initialization and execution within the state. Thus,
only one flip-flop applies out of the four above, so Simulink is more beneficial.

In Stateflow, situations that can be represented as states are implemented as state transitions and
conditional branches that are not states are implemented as flow charts. Truth tables are classified as
a conditional branch implementation method. When designing states as state transitions by using
Stateflow, Classic should be selected as the state machine type so that it is implemented as
software into the control system’s embedded micro controller.

A-16
Using Simulink and Stateflow in Modeling

HDL Coder™ is supported by Stateflow. When using HDL Coder, Mealy or Moore must be selected;
Moore mode is more appropriate when protection is required against internal electric leaks.

Note HDL Coder use cases are not described in these guidelines.

Simulink Functionality
This section provides information about using Simulink for modeling.

Blocks with State Variables

Blocks with state variables are primarily grouped into Simulink and discrete types.

For most of these blocks, the user can set the state attributes and initial values by using the block
parameters. A conditional subsystem can have state variables, depending on the structure pattern.

In this example, the Unit Delay block has state attributes.

In this example, the Tapped Delay block does not have state attributes.

A-17
A Using Simulink and Stateflow in Modeling

See guideline: jc_0640

Branch Syntax with State Variables

The Switch block and conditional subsystems behave differently when state variables are used.

Depending on the configuration setting, when any state variable exists, the Switch block generally
executes subsystem A when the condition of the control port is satisfied. If the condition is not
satisfied, it executes only subsystem B without calculating subsystem A. However, when the
subsystem A contains a state variable, calculation for the state variable within the subsystem A is
processed even when the conditions of the control port are not satisfied.

A-18
Using Simulink and Stateflow in Modeling

In the conditional subsystem, subsystem A is calculated when the condition is satisfied. When it is not
satisfied, subsystem B is calculated instead of subsystem A, regardless of the existence of any state
variables in subsystem A.

The reset action in a recalculation can be specified by using the {Action Port} setting.

The behavior of subsystem A when using a Switch block and a conditional control flow is listed in the
following tables. Familiarize yourself with these behaviors to determine which structure, the Switch
block, or conditional subsystem is most suitable for the intended purpose.

This table shows the behavior of subsystem A.

Control port condition (in subsystem A) Switch Conditional subsystem

State variables
Hold No Executed Executed
Yes
Not hold No Not executed Not executed
Yes Minimally-processed

*Executed calculations
related to the state
variables

This table provides the initialization timing of subsystem A.

Action Port Initialize

A-19
A Using Simulink and Stateflow in Modeling

Switch - First time only


Conditional subsystem Hold First time only
Reset At returned by condition

See guidelines:

• jc_0656: Usage of Conditional Control blocks


• jc_0657: Retention of output value based on conditional control flow blocks and Merge blocks

Subsystems

A subsystem is used for compiling various blocks and subsystems.

Subsystems can also be used for other purposes. Usage methods that are not functional subsystems
include:

• Mask display of the subsystem is used to describe the outline or display fixed form documents,
such as "classified"
• The open functions (callback functions in the block properties) of the subsystem is used for
running several tools or displaying explanatory text separate from the model
• Subsystems whose setting have changed to a mask subsystem (a subsystem that was simply set to
NoReadOrWrite) by a user with administrative rights to make a change, but other users cannot
see the content.

These non-typical subsystems are outside of the scope of the guidelines and, if excluded, should be
put on an exclusion list managed within the project.

See guidelines:

• jc_0201: Usable characters for subsystem names


• jc_0243: Length restriction for subsystem names
• db_0143: Usable block types in model hierarchy
• db_0144: Use of subsystems
• db_0141: Signal flow in Simulink models
• jc_0653: Delay block layout in feedback loops
• jc_0171: Clarification of connections between structural subsystems
• jc_0602: Consistency in model element names
• jc_0081: Inport and Outport block icon display
• db_0081: Unconnected signals and blocks

Atomic Subsystems and Virtual Subsystems

There are two types of subsystems: Virtual subsystems and Atomic subsystems. The primary
difference between these subsystems is whether the subsystem is treated as a single execution unit.
The virtual subsystem is the default subsystem block.

In a model, the border for a Virtual subsystem is thin as compared the border for the Atomic
subsystem, which is thick and bold.

A-20
Using Simulink and Stateflow in Modeling

Virtual Subsystems

A block that provides a visual representation is known as a "virtual block". For example, a Mux block
that compiles several signal lines, a From block that hands out the signal, and a Goto block that
corresponds to a virtual block. Since the subsystem block in the default setting only constitutes a
visual hierarchical structure, these blocks are considered virtual blocks. The subsystem is referred to
as a virtual subsystem.

Consider a subsystem that consults an external calculation result within a subsystem, as shown in the
following example. This system is calculated from these four equations.

• temp1= in1 + in2


• temp2= in3 + in4
• out1= in1 + in2 + temp2
• out2= temp1 + in3 + in4

Atomic Subsystems

An atomic subsystem is detached from the external system and is not subject to cross-border
optimization. Atomic subsystems do not use the results of the internal calculations of each subsystem.
Therefore, interim output value will use a calculation result that is delayed by a session.

• temp1= in1 + in2


• temp2= in4 + in5
• out1= in1+ in2 + in3
• out2= in4+ in5 + in6

A-21
A Using Simulink and Stateflow in Modeling

• in3= temp2
• in6= temp1

Atomic subsystems prohibit the direct referencing of the interim calculation results to other
subsystems.

Notes on atomic subsystems:

• Atomic subsystems can select C-source function settings.


• As explained above, the internal section of an atomic subsystem will become encapsulated
(objectified).
• Depending on the relationship before and after, a static RAM section should be secured inside the
subsystem for the output signal.
• Atomic subsystems (including the addition of function settings) should be used with caution.
Factor setting will not simply have a factor name inserted within a C code. It should be
acknowledged that it is described as a mathematically independent system and the conditions
under which an atomic subsystem can be used should be reviewed.
• Include the relationship with the structure layer; it is necessary to determine an operation rule
per project and to determine its relationship with the guideline rules.

Signal Name

Signals can be named and are referred to as signal names. When a signal is named, that signal name
is displayed as a label. Updates to labels are reflected in the signal name and are also displayed.

The signal name can be propagated to a signal line via a branched signal line or port block and
displayed as a signal name.

See guidelines:

• jc_0222: Usable characters for signal and bus names

A-22
Using Simulink and Stateflow in Modeling

• jc_0245: Length restriction for signal and bus names

Code can be generated by associating a signal name with a signal object (Simulink object or mpt
object). Type setting is configured through the data dictionary, setting of the storage class is optional.
The recommended data type settings for these blocks include:

• For Inport blocks, set data type} to auto.


• For Outport blocks, data type} to auto.
• For Sum blocks, set the output data type to Inherit via back propagation.

See guideline jc_0644: Type setting.

Vector Signals/Path Signal

Individual scalar signals that compose a vector shall have common functions, data type, and units.

Signals that do not fulfill the conditions as a vector can only be grouped as a bus signal. The Bus
Selector block shall be used only with bus signal inputs. It shall not be used to extract a scalar signal
from a vector signal.

The following table is an example of a vector signal.

Types of vector Size


Row vector [1 n]
Column vector [n 1]
Wheel speed subsystem [1 wheel number]
Cylinder vector [1 cylinder number]
Location vector based on a 2-dimensional [1 2]
coordination points
Location vector based on 3-dimensional [1 3]
coordination points

The following table is an example of a bus signal.

Bus type Factor


Sensor bus Force vectors
Location
Wheel speed vector [Θlf, Θrf, Θlr, Θrr]
Acceleration
Pressure
Controller bus Sensor bus
Actuator bus
Serial data bus Circulating water temperature
Engine speed, front passenger seat door open

See guidelines:

A-23
A Using Simulink and Stateflow in Modeling

• na_0010: Usage of vector and bus signals


• jc_0222: Usable characters for signal and bus names
• jc_0245: Length restriction for signal and bus names
• db_0097: Position of labels for signals and buses
• jc_0630: Usage of Multiport Switch blocks
• jc_0659: Usage restrictions of signal lines input to Merge blocks

Enumerated Types

Enumerated type data refers to data that is restricted to a determined numerical value.

The type of blocks that can be used in an enumerated type in Simulink is limited.

To use an enumerated type, you must define the enumerate type by using .m file on MATLAB. For
additional information about defining enumeration data types, see “Use Enumerated Data in Simulink
Models”.

Stateflow Functionality
This section provides information about using Stateflow for modeling.

Operations Available for Stateflow

For additional information about the Stateflow operations, see “Operations for Stateflow Data”
(Stateflow).

See guidelines:

• na_0001: Standard usage of Stateflow operators


• jc_0655: Prohibition of logical value comparison in Stateflow

Differences Between State Transition and Flow Chart

Stateflow can represent both a state transition and a flow chart.

Stateflow allows a flow chart to be designed within a state transition diagram.

An entry action is represented as a flow chart in a state, which starts from a default transition and
moves to junctions through transition lines, as illustrated below. Starting from an internal transition
line allows a during action to be represented in the flow chart.

A flow chart cannot maintain its active state between updates. As a result, a flow chart always ends at
a terminating junction (a connective junction that has no valid outgoing transitions).

In contrast, a state transition diagram stores its current state in memory to preserve local data and
active state between updates. As a result, state transition diagrams can begin executing where they
left off in the previous time step. This means that state transitions are suitable for modeling reactive
or supervisory systems that depend on history.

This table defines the start and end points for a flow chart and state transition diagram.

Start point End point

A-24
Using Simulink and Stateflow in Modeling

Flow chart Default transition All terminations from the state


are connected to the connective
junction.
State transition diagram Default transition Either termination should be
connected to the state

This illustration shows the difference between a general flow chart and state transition diagram

Mixture of flow charts and state transition diagrams with self-transition has more strict constraints.

A-25
A Using Simulink and Stateflow in Modeling

See guidelines:

• db_0132: Transitions in flow charts


• jc_0752: Condition action in transition label

Backtrack

This example shows the behavior of transitions with junctions that force backtracking behavior in
flow charts. The chart uses implicit ordering of outgoing transitions.

Initially, state A is active and transition conditions c1, c2, and c3 are true. Transition conditions c4 is
false.

1 The chart root checks to see if there is a valid transition from state A.

There is a valid transition segment marked with the transition condition c1 from state A to a
connective junction, therefore:

a Transition condition c1 is true, so action a1 executes.


b Transition condition c3 is true, so action a3 executes.
c Transition condition c4 is not true and, therefore, the control flow backtracks to state A.
2 The chart root checks to see if there is another valid transition from state A.

There is a valid transition segment marked with the transition condition c2 from state A to a
connective junction, therefore:.

a Transition condition c2 is true, so action a2 executes.


b Transition condition c3 is true, so action a3 executes.

A-26
Using Simulink and Stateflow in Modeling

c Transition condition c4 is not true and, therefore, the control flow backtracks to state A.
3 The chart goes to sleep.

To resolve this issue, consider adding unconditional transition lines to terminating junctions. The
terminating junctions allow flow to end if either c3 or c4 is not true. This design leaves state A
active without executing unnecessary actions.

See guidelines:

• jc_0751: Backtracking prevention in state transition


• jc_0773: Unconditional transition of a flow chart

Flow Chart Outside the State

A flow chart associated with a state can be written inside or outside of the state; however, be
attentive to the execution order and backtracking.

The following flow chart, which evaluates transition from a to b after executing the flow chart outside
the state, appears to execute the transition within the same period as that of a newer calculation.
However, the transition line to b is not evaluated if the termination point is reached by calculating the
transition outside the state. This is a state transition diagram which always stays at a.

A-27
A Using Simulink and Stateflow in Modeling

Done correctly, as shown below, the transition condition is not positioned at the termination of the
external flow chart, allowing the transition line from a to b to be evaluated after the flow chart is
executed. This enables the external flow chart to execute before the transition, and to be evaluated
using the most recent value at the instant of the transition. Note that this chart contains a dead path
where the transition condition will never hold, which can cause an error when the specification is
changed in the future. Use this chart structure with caution.

A-28
Using Simulink and Stateflow in Modeling

In contrast, the following flow chart is inside a state, which means that the internal flow chart is
always calculated when executing state a and can be described as an easily comprehensible structure
without dead paths. However, it should be noted that, as a performance characteristic, when state a
is executed, the transition from a to b is evaluated in the cycle following that in which the internal
flow chart is calculated. Due to this characteristic, the timing of the execution of calculations and
transitions for the external flow chart may be off. Use with caution.

A-29
A Using Simulink and Stateflow in Modeling

See guidelines:

• jc_0751: Backtracking prevention in state transition


• jc_0773: Unconditional transition of a flow chart

Pointer Variables

This code sample is from model sf_custom. To open the model, enter the following on the MATLAB
command line:
openExample('sf_custom')

In model sf_custom, click Open my_header.h.


#include "tmwtypes.h"

extern real_T my_function(real_T x);

/* Definition of custom type */

A-30
Using Simulink and Stateflow in Modeling

typedef struct {
real_T a;
int8_T b[10];
}MyStruct;

/* External declaration of a global struct variable */


extern MyStruct gMyStructVar;
extern MyStruct *gMyStructPointerVar;

In model sf_custom, click Open my_function.c.

#include "my_header.h"
#include <stdio.h>

/* Definition of global struct var */


MyStruct gMyStructVar;
MyStruct *gMyStructPointerVar=NULL;

real_T my_function(real_T x)
{
real_T y;

y=2*x;

return(y);
}

gMyStructVar is not defined in Stateflow. Typically, functions of my_function are called from C
source for use in Stateflow. However, direct reference to global variables exposed by the C source is
also available from Stateflow.

Initialization
This section provides information about using initialization values.

Initial Value Setting in Initialization

When a signal needs to be initialized, the initial values shall be set correctly.

When initial values are set inside a block, use an initial value list that includes annotations so you can
visually confirm the initial values input.

Cases that require initial values include:

A-31
A Using Simulink and Stateflow in Modeling

• When state variables are defined AND blocks that have state variables are used.

• Use the internal block settings.


• Use the external input values.
• When state variables are defined AND initial values are enabled for a block when a specific
configuration is performed.

• Set initial values in Merge blocks.


• Use signals registered in the data dictionary.
• When signal settings (with RAM) have been defined that can be referenced from the outside.

• Use signals registered in the data dictionary.

Initial Values of Signals Registered in the Data Dictionary

Set initial values for signals registered in the data dictionary.

• Discrete block groups, such as Unit Delay and Data Store Memory, have state variables.

In the case of automatic code generation, the signal name, type, and initial value can be set for
state variables by matching it to the signal in the data dictionary (associated with Simulink signal
objects). When using a signal defined in the data dictionary for a state variable, the respective
initial values should conform to the same value.
• When using a signal defined in the data dictionary for a state variable

For discrete blocks, such as Unit Delay and Data Store Memory, settings are performed not when
using signals defined in the data dictionary for the block output line, but for the state variables
inside the block. Even when the signal name of the data dictionary is assigned to the signal line,
RAM is reserved in duplicate, which is a waste of RAM.

Example — Correct

Signal is defined for the state variables inside the block. The signal name is defined and block
parameter State name must resolve to Simulink signal object is selected.

A-32
Using Simulink and Stateflow in Modeling

Example — Incorrect

Signal is defined for the output signal of the block that has state variables. The signal name is defined
and block parameter State name must resolve to Simulink signal object is not selected.

A-33
A Using Simulink and Stateflow in Modeling

Signal objects that are defined in the Workspace can be automatically associated with signal objects
and signal names of the same name by using disableimplicitsignalresolution(modelname).
However, for state variables inside the block, they are associated with the state variables inside the
block and the signal name of the same name. If a globally set signal is associated with two variables
at the same time, it is better to perform settings so that the state variables inside a block and the
signal label on the signal line have different names, otherwise the model cannot be simulated.

Block Whose External Input Value Is the Initial Value

When setting the initial value during initialization, the init function is called to set the signal to
either the value inside of the block or to the initial value that is defined in the data dictionary. Next,
the step function (the data flow executive function) is executed. Here, the external input value is set
as the initial value. When modelling, be attentive to the execution functions and execution timing for
initialization. This is demonstrated in the following image.

A-34
Using Simulink and Stateflow in Modeling

Initial Value Settings in a System Configuration That Would Enable Initialization Parameters

There are system configurations where, depending on their settings, initialization parameters are
enabled for combinations of conditional subsystems and Merge blocks. When initial values are
required in these combinations, either of the following modeling methods is performed:

• Set values in the Outport block


• Set in values the Merge block
• When an mpt signal is defined behind the Merge block, set the values in the mpt signal

The exception is when there are successive blocks with initial values and the settings for each block
are not needed to clearly show the signal’s initial value.

Example — Correct

Initial value set in the Merge block.

Example — Correct

Initial value set in mpt object.

A-35
A Using Simulink and Stateflow in Modeling

Example — Incorrect

Despite the requirement for an initial value setting, it is not shown anywhere.

A-36
B

Modeling Knowledge
B Usage Patterns

Usage Patterns

Simulink Patterns for If, elseif, else Constructs


These patterns shall be used for if, elseif, else constructs.

Function Simulink pattern


if, elseif, else construct when the Switch
block is used.

if (If_Condition)
{
output_signal = If_Value;
}
else if (Else_If_Condition)
{
output_signal = Else_If_Value;
}
else
{
output_signal = Else_Value;
}

if, elseif, else construct when using and


action subsystem

if (Fault_1_Active & Fault_2_Active)


{
ErrMsg = SaftyCrit;
}
else if (Fault_1_Active | Fault_2_Active)
{
ErrMsg = DriverWarn;
}
else
{
ErrMsg = NoFaults;

Simulink Patterns for case Constructs


These patterns shall be used for case constructs.

Function Simulink Pattern

B-2
Usage Patterns

Case construct using an action subsystem.

switch (PRNDL_Enum)
{
case 1
TqEstimate = ParkV;
break;
case 2
TqEstimate = RevV;
break;
default
TqEstimate = NeutralV;
break;
}
Case construct using a Multiport Switch block.

switch (Selection)
{
case 1:
output_signal =
look1_binlxpw(In2,y1,x1,3U);
break;
case 2:
output_signal =
look1_binlxpw(In3,y2,x2,3U);
break;
case 3:
output_signal =
look1_binlxpw(In4,y3,x3,3U);
break;
default:
output_signal =
look1_binlxpw(In5,y4,x4,3U);
break;
}

Simulink Patterns for Logical Constructs


These patterns shall be used for logical constructs.

Conjunctive normal form

B-3
B Usage Patterns

Disjunctive normal form

Simulink Patterns for Vector Signals


These patterns shall be used for vector signals.

Function Simulink Pattern


Vector signal and parameter (scalar)
multiplication

for (i=0; i>input_vector_size; i++) {


output_vector[i] = input_vector[i] *
tunable_parameter_value;
}

(Reference: generated code of R2013b)

for (i = 0; i < input_vectorDim; i++) {


output_vector[i] =
tunable_parameter_value *
input_vector[i];
}

(As the code is generated using a variable


number of dimensions, the upper limit of the
normal loop is a direct value.)

B-4
Usage Patterns

Multiplication of vector signals and parameters


(vectors)

for (i=0; i>input_vector_size; i++) {


output_vector[i] = input_vector[i] *
tunable_parameter_vector[i];
}
Vector signal element multiplication

output_signal = 1;
for (i=0; i>input_vector_size; i++) {
output_signal = output_signal *
input_vector[i];
}
Vector signal element division

output_signal = 1;
for (i=0; i>input_vector_size; i++) {
output_signal = output_signal /
input_vector[i];
}
Vector signal and parameter (scalar) addition

for (i=0; i>input_vector_size; i++) {


output_vector[i] = input_vector[i] +
tunable_parameter_value;
}

Vector signal and parameter (vector) addition

Vector signal and parameter (vector) addition

for (i=0; i>input_vector_size; i++) {


output_vector[i] = input_vector[i] +
tunable_parameter_vector[i];
}

Vector signal element subtraction

output_signal = 0;
for (i=0; i>input_vector_size; i++) {
output_signal = output_signal -
input_vector[i];
}

B-5
B Usage Patterns

Retention of minimum value/maximum value

Using Switch and If, Elseif, Else Action Subsystems


The Switch block shall be used for modeling simple if, elseif,else structures when the associated
elseif and else actions involve only the assignment of constant values.

Example — Recommended

For a simple if, elseif, else structure, use the Switch block.

Example — Not recommended

Using If and If Action Subsystem blocks for a simple if, elseif, else structure.

B-6
Usage Patterns

Example — Recommended

For a complex if, elseif, else structure, use If and If Action Subsystem blocks.

Example — Not recommended

Using Switch block for a complex if, elseif, else structure.

B-7
B Usage Patterns

Use of If, Elseif, Else Action Subsystem to Replace Multiple Switches


Frequent use of the Switch block for condition bifurcation shall be avoided. Instead, the upper limit
target shall be used (such as up to three levels). When the target value is exceeded, a conditional
control flow using the if, elseif, else action subsystem shall be used.

Example — Not recommended

Four levels of nesting.

Example — Recommended

By setting the fourth level as an if action subsystem, nesting is limited to a single level.

B-8
Usage Patterns

Example — Not recommended

Not dividing by using an if action subsystem.

Use atomic subsystem + function setting when the C code limit is applied. In this case, there is no
need to use the if, elseif, else action subsystem, but the configuration of the Switch block can be
split and encapsulated in the subsystem.

B-9
B Usage Patterns

Example of model with five levels of nesting — Not recommended

Example of model with five levels of nesting — Recommended

Use a description method that avoids layering of nesting in the Switch block.

B-10
Usage Patterns

While provided as an example, an if action subsystem is not typically used for switching the fixed
value. In these Recommended and Not Recommended examples, the generated C code will be the
same if the user does not add a function conversion setting. (Confirmed in R2010b to R2013a) The C
code is unconstrained.

B-11
B Usage Patterns

Usage Rules for Action Subsystems Using Conditional Control Flow


Example — Recommended

An if action subsystem shall not be used when the associated actions do not have a status variable.

Example — Recommended

Example of a model using five levels of nesting. Layering by using a subsystem does not occur
because there is no internal state.

B-12
Usage Patterns

Example — Recommended

An atomic subsystem is used to split either side of the Switch block without using an action
subsystem.

B-13
B Usage Patterns

Example — Not Recommended

Layering through the use of an unnecessary action subsystem.

B-14
Usage Patterns

If a function can be achieved by using the action subsystem, then layering using the action subsystem
is not performed.

B-15
B Usage Patterns

In the Not Recommended example, when the lowest level Unit Delay block on the third level is
initialized, the conditional subsystem initialization is first executed one time on the upper first level,
and then again on the second level for a total of two times of initial value settings. To prevent the
generation of unnecessary code, it is recommended that listing not be made in conditional
subsystems that reside in levels where the state variable does not exist.

This is based on the concept that the model complexity is reduced by dropping to a level. The purpose
of the rule is to avoid the execution of unnecessary initializations.

For bifurcation of systems where the bifurcation condition nest has a deep structure, split by using
function conversions to decrease the code bifurcation nesting. Functions before and after the Switch
block are divided into respective subsystems, and function settings are applied to the atomic
subsystem + function. Be aware, it is possible that this may result in unintentional implementation
and unnecessary RAM requirements.

Test for Information From Errors


When functions that are used in Stateflow (graphical functions, MATLAB functions, etc.) results in an
error, the error information shall be transformed into a model structure that will facilitate testing.

Not reviewing the error information returned by the functions can result in unintended behavior.

Example — Recommended

Error information is incorporated into the model structure, allowing the user to review and respond
to the errors.

Example — Not Recommended

Error information is not incorporated into the model structure.

B-16
Usage Patterns

Flow Chart Patterns for Conditions


These patterns shall be used for conditions within Stateflow flow charts.

Function Flow Chart Pattern


One condition.

[condition]

Up to three conditions, short form.

(The use of different logical operators in this form


is not allowed. Use subconditions instead.)

[condition1 && condition2 && condition3]


[condition1 || condition2 || condition3]
Two or more conditions, multiline form.

(The use of different logical operators in this form


is not allowed. Use subconditions instead.)

[condition1 ...
&& condition2 ...
&& condition3]
[condition1 ...
|| condition2 ...
|| condition3]

B-17
B Usage Patterns

Conditions with sub conditions.

(The use of different logical operators to connect


subconditions is not allowed. The use of brackets
is mandatory.)

[(condition1a || condition1b) ...


&& (condition2a || condition2b) ...
&& (condition3)]
[(condition1a && condition1b) ...
|| (condition2a && condition2b) ...
|| (condition3)]

Conditions that are visually separated.

(This form can be combined with the preceding


patterns.)

[condition1 && condition2]


[condition1 || condition2]

Flow Chart Patterns for Condition Actions


These patterns shall be used for condition actions within Stateflow flow charts

Function Flow Chart Pattern


One condition action.

action;

Two or more condition actions, multiline form.

(Two or more condition actions in one line are not


allowed.)

action1; ...
action2; ...
action3; ...

B-18
Usage Patterns

Condition actions that are visually separated.

(This form can be combined with the preceding


patterns.)

action1a;
action1b;
action2;
action3;

Flow Chart Patterns for If, Elseif, Else Constructs


These patterns shall be used for If constructs within Stateflow flow charts.

Function Flow Chart Pattern


If construct

if (condition){
action;
}

If, else construct

if (condition) {
action1;
}
else {
action2;
}

B-19
B Usage Patterns

If, elseif, else construct

if (condition1) {
action1;
}
else if (condition2) {
action2;
}
else if (condition3) {
action3;
}
else {
action4;
}

Cascade of if construct.

if (condition1) {
action1;
if (condition2) {
action2;
if (condition3) {
action3;
}
}
}

Flow Chart Patterns for Case Constructs


These patterns shall be used for case constructs in Stateflow flow charts.

Function Flow Chart Pattern


Case construct with exclusive selection.

selection = u1;
switch (selection) {
case 1:
y1 = 1;
break;
case 2:
y1 = 2;
break;
case 3:
y1 = 4;
break;
default:
y1 = 8;
}

B-20
Usage Patterns

Case construct with exclusive conditions.

c1 = u1;
c2 = u2;
c3 = u3;
if (c1 && ! c2 && ! c3) {
y1 = 1;
}
elseif (! c1 && c2 && ! c3) {
y1 = 2;
}
elseif (! c1 && ! c2 && c3) {
y1 = 4;
}
else {
y1 = 8;
}

Flow Chart Patterns for Loop Constructs


These patterns shall be used to create loop constructs in Stateflow flow charts.

Function Flow Chart Pattern


For loop construct

for ( index = 0;
index < number_of_loops;
index++ )
{
action;
}
While loop construct

while ( condition )
{
action;
}

Do While loop construct.

do
{
action;
}
while ( condition )

B-21
B Usage Patterns

State Machine Patterns for Conditions


These patterns shall be used for conditions within Stateflow state machines

Function State Machine Pattern


One condition

(condition)
Up to three conditions, short form

(The use of different logical operators in this form


is not allowed, use sub conditions instead)

(condition1 && condition2)


(condition1 || condition2)

Two or more conditions, multiline form

A subcondition is a set of logical operations, all of


the same type, enclosed in parentheses.

(The use of different operators in this form is not


allowed, use sub conditions instead.)

(condition1 ...
&& condition2 ...
&& condition3)

(condition1 ...
|| condition2 ...
|| condition3)

State Machine Patterns for Transition Actions


These patterns shall be used for transition actions within Stateflow state machines.

Function State Machine Pattern


One transition action.

action;
Two or more transition actions, multiline form

(Two or more transition actions in one line are


not allowed.)

action1;
action2;
action3;

B-22
Usage Patterns

jc_0321Limiting State Layering


Within a single viewer (subviewer), multiple layering shall be limited by defining constraints for a
single view (subview). Subcharts shall be used to switch the screen when defined constraint goals are
exceeded.

Example — Recommended

The fourth level is encapsulated in a subchart.

Example — Not Recommended

The constraint goal is set to three levels, but Level_4_a and Level_4_b have more than three levels

and are nested.

B-23
B Usage Patterns

Number of States per Stateflow Container


The number of states per Stateflow container shall be determined by the number of states that can be
viewed in the diagram. All states should be visible and readable.

Function Call from Stateflow


If a state exists in the Function-Call Subsystem of the call target, and a “reset” of the state is required
when the state of the caller becomes inactive, the caller shall use a bind action.

Function Types Available in Stateflow


The functions types used in Stateflow shall be dependent on the required processing.

B-24
Usage Patterns

For graphical functions, use:

• If, elseif, else logic

For Simulink functions, use:

• Transfer functions
• Integrators
• Table look-ups

For MATLAB functions, use:

• Complex equations
• If, elseif, else logic

B-25
C

Glossary
Atomic Subsystem

A subsystem block that executes the structural subsystem as a single unit. Conditional subsystems,
Stateflow Chart, and MATLAB Function blocks are considered atomic subsystems.

Basic Blocks

Built-in blocks in the standard Simulink library. Blocks with undefined internal processing, such as
subsystems, are not considered basic blocks

Basic blocks can include:

• Inport
• Outport
• Ground
• Terminator
• Constant
• Scope
• Saturation
• Unit Delay
• Delay
• Discrete-Time Integrator
• Switch
• Gain
• Product
• Relational Operator
• Logical Operator

Block

All blocks (type=block), including:

• Subsystems
• Models
• Charts (unless otherwise stated).

Standard Simulink library blocks are divided into two categories:

• Basic blocks
• Structural subsystems
C Usage Patterns

Built-in MATLAB functions

MATLAB functions and scripts.

Combined State Action Type

A combination of two or more of these basic state action types:

• entry (en), during (du)


• during (du), exit (ex)
• entry (en), exit (ex)
• entry (en), during (du), exit (ex)

Conditional Input Block

Includes Trigger, Enable, Function-Call Subsystem, Reset blocks.

Conditional Subsystem

A subsystem with conditional input ports.

Delay Block

Two meanings:

1 The previous value reference block that is placed in the loop route to specify the execution order
in an algebraic loop (circular reference). Uses Unit Delay and Memory blocks.

(As of R2021b and later) The Delay block can also be used
2 A block that retains past values. Uses Unit Delay, Memory, Delay, and Tapped Delay blocks.

Calculation Block

Blocks whose block type is "sum" that carry out addition and subtraction operations. Includes Add,
Subtract, Sum, Sum of Elements blocks.

Flow Chart

The part of a model that describes the action for the transition condition by using transition
conditions and condition actions. The start point is the default transition line or internal transition
line. The end point is the connective junction. Does not include states that are between the start and
end points. Graphical functions and the inside of states can be modeled as flow charts.

Machine Level

The root subsystem of a Simulink model with Stateflow blocks.

Multiplication and Division Block

Blocks whose block type is "product" that carry out division and multiplication operations. Includes
Product, Divide, and Product of Elements blocks.

Parameters

C-2
Usage Patterns

When modifications have not been made, this term refers to constants that are defined in the base
workspace and/or model workspace.

Port Label Name

The input and output port labels of a structural subsystem.

The names of Inport and Outport blocks are placed in a subsystem by default. Names of Stateflow
input and output data are displayed by default.

The display option can be changed when masking a subsystem.

Reserved MATLAB words

MATLAB keywords and built-in MATLAB functions.

State

An atomic subchart is considered a state.

State Action Type

Basic state action types and combined state action types.

Stateflow Block

Includes Chart, State Transition Table, and Truth Table blocks.

Subsystem

A subsystem that can be internally modeled by using Simulink.

Even when the block type is "subsystem", blocks that describe the inside (other than Simulink) of a
model, such as Chart, MATLAB Function blocks, are not included. The Model block also is not
included.

C-3

You might also like