Stateflow

 

Stateflow

Model and simulate decision logic using state machines and flow charts

 

Stateflow® provides a graphical language that includes state transition diagrams, flow charts, state transition tables, and truth tables. You can use Stateflow to describe how MATLAB® algorithms and Simulink® models react to input signals, events, and time-based conditions. 

Stateflow enables you to design and develop supervisory control, task scheduling, fault management, communication protocols, user interfaces, and hybrid systems. 

With Stateflow, you model combinatorial and sequential decision logic that can be simulated as a block within a Simulink model or executed as an object in MATLAB. Graphical animation enables you to analyze and debug your logic while it is executing. Edit-time and run-time checks ensure design consistency and completeness before implementation.

Design Control Logic

Model system logic using state machines, flow charts, and truth tables.

Designing State Machines Graphically

Build state machines graphically by drawing states and junctions connected by transitions. You can also create functions using flow chart notation, Simulink subsystems, MATLAB code, and truth tables.

Stateflow diagram defining the logic for a boiler temperature control system. The diagram uses graphical functions (right side) to implement utility algorithms called by the heater system (left side).

Designing Flow Charts

Create flow charts by drawing transitions that are connected at junctions. The Pattern Wizard lets you create commonly used logic flow patterns. You can use flow charts to design logic for transitioning between states.

Represent combinatorial logic such as decision trees and iterative loops graphically with flow charts.

Designing Logic with Tables

Truth tables in Stateflow let you model logic in Simulink when the output depends purely on the current input. State transition tables provide a structured environment for modeling state machines in Simulink.

Truth table implementing the logic for selecting a valid sensor reading in a fault-detection algorithm.

Execute and Debug Charts

Visualize the behavior of your system for analysis and debugging.

Executing Stateflow Charts

Visualize system behavior using state diagram animations to highlight active states and transitions in your charts.

Debugging Stateflow Charts

Stateflow debugging capabilities let you step through chart execution in detail. You can set breakpoints, monitor data values, and step through different functions in your state diagrams.

Simulation data visualization options in Stateflow. Top left: Simulink Data Inspector for comparing specific signals; bottom left: custom MATLAB interface for analyzing data; right: Simulink Signal Selector for comparing specific states.

Develop Reusable Logic for MATLAB Applications

Use Stateflow chart objects to develop reusable logic for MATLAB applications. Design state machine and timing logic for a wide range of applications, including test and measurement, autonomous systems, signal processing, and communications.

Reusable Chart Objects

Create standalone Stateflow charts that use the full capabilities of the MATLAB language in state and transition actions. Use these charts as MATLAB objects in your applications that require state machine and timing logic.

State Machine and Timing Logic

Accelerate the development of MATLAB applications by using Stateflow to graphically design state machine and timing logic that would be difficult to implement textually.

Deploying Stateflow Applications

Create MATLAB applications that include Stateflow chart objects and share them without requiring Stateflow.

Share MATLAB applications that include Stateflow chart objects with users who do not have Stateflow. 

Schedule Simulink Algorithms

Schedule algorithms modeled in Simulink.

Periodic and Continuous Scheduling

You can model conditional, event-based, and time-based logic in Stateflow to invoke Simulink algorithms in a periodic or continuous manner. Orchestrate the execution of components to simulate the scheduling of your real-time environment.

You can model logic in Stateflow to call Simulink and MATLAB algorithms in a periodic or continuous manner.

Temporal Operators

Use event-based and time-based operators (such as after and duration) to specify state-transition logic based on event counts, elapsed time, and denoised signals without having to create and maintain your own timers and counters.

Validate Designs and Generate Code

Validate your design against requirements and generate code for implementation on your embedded system.

Validating Designs

Use Stateflow with other Simulink products to validate your design against requirements.

Highlight Active Logic using Model Slicer.

Generating Code

Generate code for implementation of your Stateflow logic on embedded systems.

Generate code to implement Stateflow logic. 

Latest Features

Stateflow Charts in MATLAB

Graphically program, debug, and execute standalone state machines as MATLAB objects

External C Code

Fully integrate external C code in Stateflow charts with change synchronization, error checking, examination of values, and analysis by Simulink Coverage and Simulink Design Verifier

Truth Table Editor

Design combinatorial logic within the Simulink and Stateflow editing environment by using edit-time checking, animation, break points, and step-by-step debugging

Simulink Subsystem as a Stateflow State

Design states by using continuous and periodic Simulink algorithms to model hybrid systems

Sequence Viewer

Visualize state changes, event activity, and function calls over time

State and Data Visualization

Stream state activity and data directly from Stateflow to the Simulation Data Inspector

Edit-Time Checking

Detect and fix potential issues in charts at design time

Symbol Manager

Create and manage data, events, and messages directly in the Stateflow Editor

See the release notes for details on any of these features and corresponding functions.

Stateflow® ist eine Umgebung für die Modellierung und Simulation von kombinatorischer und sequenzieller Entscheidungslogik auf Grundlage von Zustandsautomaten und Flussdiagrammen. In Stateflow können Sie grafische und tabellarische Darstellungen kombinieren, um zu modellieren, wie Ihr System auf Ereignisse, zeitabhängige Bedingungen und externe Eingangssignale reagiert. Zu den Methoden gehören Zustandsübergangs-Diagramme, Flussdiagramme, Zustandsübergangs-Tabellen und Wahrheitstabellen.

Mit Stateflow können Sie Algorithmen für die Überwachung und Steuerung technischer Prozesse, für Aufgabenmanagement und für Fehlerbehebungsmanagement entwickeln. Stateflow umfasst animierte Zustandsdiagramme, sowie statische- und Laufzeitprüfungen, um die Konsistenz und Vollständigkeit des Entwurfs vor der Implementierung zu testen.

Get a Free Trial

30 days of exploration at your fingertips.

Download now

Ready to Buy?

Get pricing information and explore related products.

Are You a Student?

Get MATLAB and Simulink student software.

Learn more