Skip to Main Content Skip to Search
Product Documentation

Examples


Use this list to find examples in the documentation.

Stateflow Chart Objects

Stateflow Chart Objects

Stateflow Hierarchy

Stateflow Hierarchy of Objects
State Hierarchy Example
Transition Hierarchy

Active and Inactive States

Exclusive (OR) State Decomposition
Parallel (AND) State Decomposition

Label Notation

Transition Label Example

Transition Connections

Transitions to and from Exclusive (OR) States
Transitions to and from Junctions
Transitions to and from Exclusive (OR) Superstates
Transitions to and from Substates
Self-Loop Transitions

Inner Transitions

Before Using an Inner Transition
After Using an Inner Transition to a Connective Junction
Using an Inner Transition to a History Junction
Processing One Event in an Exclusive (OR) State
Processing a Second Event in an Exclusive (OR) State
Processing a Third Event in an Exclusive (OR) State
Processing the First Event with an Inner Transition to a Connective Junction
Processing a Second Event with an Inner Transition to a Connective Junction
Inner Transition to a History Junction Example

Default Transitions

Default Transition to a Junction Example
Default Transition with a Label Example
Default Transition in Exclusive (OR) Decomposition Example
Default Transition to a Junction Example
Default Transition and a History Junction Example
Labeled Default Transitions Example

Connective Junctions

Connective Junction with All Conditions Specified Example
Connective Junction with One Unconditional Transition Example
Connective Junction and For Loops Example
Flow Graph Notation Example
Connective Junction from a Common Source to Multiple Destinations Example
Connective Junction Common Events Example
Label Format for Transition Segments Example
If-Then-Else Decision Construct Example
Self-Loop Transition Example
For-Loop Construct Example
Flow Graph Notation Example
Transitions from a Common Source to Multiple Destinations Example
Transitions from Multiple Sources to a Common Destination Example
Transitions from a Source to a Destination Based on a Common Event Example
Backtracking Behavior in Flow Graphs Example

History Junctions

Use of History Junctions Example

Boxes

Boxes
Drawing and Editing a Box
Deleting a Box
Using a Box to Group Functions
Using a Box to Group States

Early Return Logic for Event Broadcasts

Early Return Logic for Event Broadcasts

Charts

Creating an Empty State Chart

Self-Loop Transitions

Creating Self-Loop Transitions

Stateflow Editor Window

Stateflow Editor Window

Mealy and Moore Charts

Creating Mealy and Moore Charts
Mealy Vending Machine
Moore Traffic Light

Supertransition

What Is a Supertransition?
Drawing a Supertransition Into a Subchart
Drawing a Supertransition Out of a Subchart

Smart and Nonsmart Transitions

Smart Transitions Slide Around Surfaces
Smart Transitions Slide and Maintain Shape
Smart Transitions Connect States to Junctions at 90 Degree Angles
Smart Transitions Snap to an Invisible Grid
Smart Transitions Bow Symmetrically
Smart Transitions Prefer Straight Lines from Junctions
Nonsmart Transitions Anchor Connection Points
Nonsmart Transitions Distort Asymmetrically

Graphical Functions

Creating a Graphical Function
Calling Graphical Functions in States and Transitions
Exporting Chart-Level Graphical Functions
Specifying Graphical Function Properties

Note Font and Color

TeX Instructions

Data and Events

Example of Using an Edge-Triggered Output Event
Example of Queuing Behavior for Edge-Triggered Output Events
Example of Using Queuing Behavior to Approximate a Function Call
Example of Using a Function-Call Output Event
Example of Interleaving Behavior for Function-Call Output Events
Example of Collecting and Storing Input Data in a Vector
Using Data and Event Arguments in Actions
Example of Directed Event Broadcasting Using send
Example of Directed Event Broadcasting Using Qualified Event Names

Action Language

State Action Types

MATLAB Functions and Variables

ml Namespace Operator
ml Function
ml Expressions
Which ml Should I Use?
ml Data Type
How Charts Infer the Return Size for ml Expressions

Temporal Logic Operators

Rules for Using Temporal Logic Operators
Operators for Event-Based Temporal Logic
Examples of Event-Based Temporal Logic
Operators for Absolute-Time Temporal Logic
Examples of Absolute-Time Temporal Logic
Running a Model That Uses Absolute-Time Temporal Logic

Change Detection

Running a Model That Demonstrates Change Detection
Change Detection Operators
Change Detection Example

Checking State Activity

The in Operator
State Resolution for Identically Named Substates
Best Practices for Checking State Activity

Simulation State of a Chart

Dividing a Long Simulation into Segments
Testing a Unique Chart Configuration
Testing a Chart with Fault Detection and Redundant Logic

Continuous-Time Modeling

Models That Demonstrate Continuous-Time Modeling
Modeling a Bouncing Ball in Continuous Time

Fixed-Point Data

Tutorial: Using Fixed-Point Chart Inputs
Tutorial: Using Fixed-Point Parameters and Local Data
Example of Using the := Operator for Addition and Subtraction
Example of Using the := Operator for Multiplication
Example of Using the := Operator for Division
Offline and Online Conversion Examples

Complex Data

Detection of Valid Transmission Data with Frame Synchronization
Frequency Response Measurement with a Spectrum Analyzer

Interfaces with Simulink Models

Triggered Stateflow Block Example
Sampled Stateflow Block Example
Inherited Stateflow Block Example

Structures and Buses

Example of Stateflow Structures
Indexing Sub-Structures and Fields
Integrating Custom Structures in Stateflow Charts

Stateflow Design Patterns

Debouncing Signals
Scheduling Execution of Simulink Subsystems
Implementing Dynamic Test Vectors with Hierarchy and Parallelism

Truth Table Functions

Creating a Stateflow Truth Table
Calling a Truth Table in a Stateflow Action
Creating Truth Table Data in Stateflow Charts and Simulink Models
Programming a Truth Table

MATLAB Functions in Stateflow Charts

Building a Model with a MATLAB Function in a Chart
Programming a MATLAB Function in a Chart
Debugging a MATLAB Function in a Chart

Simulink Functions in Stateflow Charts

Defining a Function That Uses Simulink Blocks
Scheduling Execution of Multiple Controllers

Parsing Stateflow Charts

Parsing Chart Example

Debugging

Example of Debugging Run-Time Errors in a Chart
State Inconsistency Example
Example of Conflicting Transitions
Data Range Violation Example
Cyclic Behavior Example
Flow Cyclic Behavior Not Detected Example
Noncyclic Behavior Flagged as a Cycle Example

Signal Logging

Logging Multiple Signals At Once
Logging Chart Signals Using the Command-Line API

Search and Replace

Searching with Regular Expression Tokens
Replacing with Case Preservation
Replacing with Tokens

Transitions to and from Exclusive (OR) States

Transitioning from State to State with Events Example
Transitioning from a Substate to a Substate with Events Example

Condition Actions

Condition Action Example
Condition and Transition Actions Example
Condition Actions in For-Loop Construct Example
Condition Actions to Broadcast Events to Parallel (AND) States Example
Cyclic Behavior to Avoid with Condition Actions Example

Event Actions

Event Actions in a Superstate Example

Parallel (AND) States

Event Broadcast State Action Example
Event Broadcast Transition Action with a Nested Event Broadcast Example
Event Broadcast Condition Action Example

Directed Event Broadcasting

Directed Event Broadcast Using Send Example
Directed Event Broadcast Using Qualified Event Name Example

Free Stateflow Interactive Kit

Learn how engineers use Stateflow to model state machines in their Simulink models.


Get free kit

Trials Available

Try the latest version of Stateflow.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS