Stateflow User's Guide

    Preface
        System Requirements
        Using Stateflow on a Laptop Computer
        Related Products
        Using This Guide
            Chapter Quick Reference
            Typographical Conventions

        Installing Stateflow

    Introduction
        Overview
            What Is Stateflow?
            Examples of Stateflow Applications
            Stateflow Components
            Design Approaches

        Quick Start
            The Power Switch Model
            Creating a Simulink Model
            Creating a Stateflow Diagram
            Defining Input Events
            Defining the Stateflow Interface
            Defining Simulink Parameters
            Parsing the Stateflow Diagram
            Running a Simulation
            Debugging
            Generating Code

    How Stateflow Works
        Finite State Machine Concepts
            What Is a Finite State Machine?
            FSM Representations
            Stateflow Representations
            Notations
            Semantics
            References

        Anatomy of a Model and Machine
            The Simulink Model and Stateflow Machine
            Defining Stateflow Interfaces
            Stateflow Diagram Objects

        Exploring a Real-World Stateflow Application
            Analysis and Physics
            Control Logic
            Running the Model

    Creating Charts
        Creating a Chart
        Using the Stateflow Editor
            Displaying Shortcut Menus
            Drawing Objects
            Specifying Object Styles
            Selecting and Deselecting Objects
            Cutting and Pasting Objects
            Copying Objects
            Editing Object Labels
            Exploring Objects in the Editor Window
            Zooming a Diagram

        Creating States
            Moving and Resizing States
            Creating Substates
            Grouping States
            Specifying State Decomposition
            Specifying Activation Order for Parallel States
            Labeling States
            Using the State Properties Dialog Box
            Naming States
            Defining State Actions
            Outputting State Activity to Simulink

        Creating Boxes
        Creating Transitions
            What Is a Default Transition?
            Creating Default Transitions
            Editing Transition Attach Points
            Labeling Transitions
            Valid Labels
            Changing Arrowhead Size
            Moving Transition Labels
            Using the Transition Properties Dialog

        Creating Junctions
            Changing Size
            Changing Arrowhead Size
            Moving a Junction
            Editing Junction Properties

        Specifying Chart Properties
        Waking Up Charts
        Working with Graphical Functions
            Creating a Graphical Function
            Invoking Graphical Functions
            Exporting Graphical Functions
            Specifying Graphical Function Properties

        Working with Subcharts
            Creating a Subchart
            Manipulating Subcharts as Objects
            Opening a Subchart
            Navigating Subcharts
            Editing a Subchart

        Working with Supertransitions
            About Supertransitions
            Drawing a Supertransition
            Labeling Supertransitions

        Creating Chart Libraries
        Stateflow Printing Options
            Printing the Current View
            Printing a Stateflow Book

    Defining Events and Data
        Defining Events
            Adding Events to the Data Dictionary
            Changing Event Properties
            Event Dialog Box
            Naming Events
            Defining Local Events
            Defining Input Events
            Defining Output Events
            Exporting Events
            Importing Events
            Specifying Trigger Types
            Describing Events
            Documenting Events
            Implicit Events

        Defining Data
            Adding Data to the Data Dictionary
            Setting Data Properties
            Data Dialog Box
            Defining Data Arrays
            Defining Input Data
            Defining Output Data
            Associating Ports with Data
            Defining Temporary Data
            Exporting Data
            Importing Data
            Documenting Data

        Symbol Autocreation Wizard

    Defining Stateflow Interfaces
        Overview
            Interfaces to Stateflow
            Typical Tasks to Define Stateflow Interfaces
            Where to Find More Information on Events and Data

        Defining the Stateflow Block Update Method
            Stateflow Block Update Methods
            Defining a Triggered Stateflow Block
            Defining a Sampled Stateflow Block
            Defining an Inherited Stateflow Block
            Defining a Continuous Stateflow Block

        Defining Output to Simulink Event Triggers
            Overview
            Defining Function Call Output Events
            Defining Edge-Triggered Output Events

        Inputting Events from Simulink
            Add an Event Choosing a Chart as the Parent
            Choose Input from Simulink as the Scope
            Select the Trigger
            Apply the Changes

        Inputting Data from Simulink
            Add a Data Object Choosing a Chart as the Parent
            Choose Input from Simulink as the Scope
            Specify Data Attributes
            Apply and Save the Changes

        Outputting Events to Simulink
            Add an Event Parented by the Chart
            Choose Output to Simulink as the Scope
            Apply the Changes

        Outputting Data to Simulink
            Add a Data Object Parented by the Chart
            Choose Output to Simulink as the Scope
            Specify Data Attributes
            Apply the Changes

        MATLAB Workspace
            What Is the MATLAB Workspace?
            Using the MATLAB Workspace

        Defining the Interface to External Sources
            What Are External Sources?
            Exported Events
            Imported Events
            Exported Data
            Imported Data

    Exploring and Searching Charts
        Overview
        Exploring Charts
            Explorer Main Window
            Moving Objects/Changing Parent
            Moving Objects/Changing Index and Port Order
            Deleting Objects
            Editing Objects
            Setting Properties
            Renaming Objects
            Transferring Object Properties

        Searching Charts
            Stateflow Finder
            Finder Display Area

    Notations
        Overview
            What Is Meant by Notation?
            Motivation Behind the Notation
            How the Notation Checked Is Checked
            Graphical Objects
            The Data Dictionary
            How Hierarchy Is Represented

        States
            Overview
            State Decomposition
            Active and Inactive States
            Combination States
            Labeling a State

        Transitions
            Labeling a Transition
            Valid Transitions
            Types of Transitions
            Default Transitions
            Labeling Default Transitions
            What Is an Inner Transition?
            What Is a Self Loop Transition?

        Connective Junctions
            What Is a Connective Junction?
            What Is Flow Diagram Notation?

        History Junctions
            History Junctions and Inner Transitions

        Action Language
            What Is an Action Language?
            Objects with Actions
            Transition Action Notation
            State Action Notation
            Keywords
            Action Language Components
            Bit Operations
            Binary Operations
            Unary Operations
            Unary Actions
            Assignment Operations
            User-Written Functions
            ml() Functions
            MATLAB Name Space Operator
            The ml() Function Versus ml Name Space Operator
            Data and Event Arguments
            Arrays
            Pointer and Address Operators
            Hexadecimal Notation
            Typecast Operators
            Event Broadcasting
            Directed Event Broadcasting
            Conditions
            Time Symbol
            Literals
            Continuation Symbols
            Comments
            Use of the Semicolon
            Temporal Logic Operators
            After Operator
            Before Operator
            At Operator
            Every Operator
            Temporal Logic Events

    Semantics
        Overview
            List of Semantic Examples

        Event-Driven Effects on Semantics
            What Does Event-Driven Mean?
            Top-Down Processing of Events
            Semantics of Active and Inactive States
            Semantics of State Actions
            Semantics of Transitions

        Transitions to and from Exclusive (OR) States
        Condition Actions
        Default Transitions
        Inner Transitions
        Connective Junctions
        Event Actions
        Parallel (AND) States
        Directed Event Broadcasting
        Execution Order
            Overview
            Execution Order Guidelines
            Parallel (AND) States

        Semantic Rules Summary
            Entering a Chart
            Executing an Active Chart
            Entering a State
            Executing an Active State
            Exiting an Active State
            Executing a Set of Flow Graphs
            Executing an Event Broadcast

    Building Targets
        Overview
            Target Types
            Building a Target
            How Stateflow Builds Targets

        Setting Up Target Build Tools
            Setting Up Build Tools on UNIX
            Setting Up Build Tools on Windows

        Starting a Build
            Starting from a Target Builder Dialog Box

        Configuring a Target
            Specifying Code Generation Options
            Simulation Coder Options Dialog Box
            RTW Coder Options Dialog Box
            Specifying Custom Code Options

        Parsing
            Parser
            Parse the Machine or the Stateflow Diagram

        Error Messages
            Parser Error Messages
            Code Generation Error Messages
            Compilation Error Messages

        Integrating Custom and Generated Code
            Invoking Graphical Functions

    Debugging
        Overview
            Typical Debugging Tasks
            Including Debugging in the Target Build
            Breakpoints
            Runtime Debugging

        Stateflow Debugger User Interface
            Debugger Main Window
            Status Display Area
            Breakpoint Controls
            Debugger Action Control Buttons
            Animation Controls
            Display Controls
            MATLAB Command Field

        Debugging Runtime Errors
            Example Stateflow Diagram
            Typical Scenario to Debug Runtime Errors
            Create the Model and Stateflow Diagram
            Define the sfun Target
            Invoke the Debugger and Choose Debugging Options
            Start the Simulation
            Debug the Simulation Execution
            Resolve Runtime Error and Repeat
            Solution Stateflow Diagram

        Debugging State Inconsistencies
            Causes of State Inconsistency
            Detecting State Inconsistency

        Debugging Conflicting Transitions
            Detecting Conflicting Transitions

        Debugging Data Range Violations
            Detecting Data Range Violations

        Debugging Cyclic Behavior
            Detecting Cyclic Behavior

    Function Reference
        sfnew
        sfexit
        sfsave
        stateflow
        sfprint
        sfhelp

    Glossary

Printable Documentation (PDF)

Product Page (Web)