The use of Simulink® and Stateflow® to model a hydraulic servomechanism controlled by a pulse-width modulated (PWM) solenoid. This type of motion control system is used in industrial,
Model an automotive drivetrain with Simulink®. Stateflow® enhances the Simulink model with its representation of the transmission control logic. Simulink provides a powerful
Model an automotive passenger power window system using Model-Based Design with Simulink®, Stateflow®, Fixed-Point Designer™ and DSP System Toolbox™. The Control System design meets a
Design a fault detection, isolation, and recovery (FDIR) application for a pair of aircraft elevators with redundant actuators. The fault detection control logic used in this model is the
Model a launch abort system. An aircraft is launched into outer space. If an anomaly or fault occurs during the launch, the operation is aborted, and the aircraft is sent back down to Earth.
The difference in behavior of a Stateflow message compared to events or data.
To use extrinsic functions that are not supported for code generation within a chart that uses MATLAB as the action language, you must use coder.extrinsic. When you declare a function with
The model of a permanent magnet DC motor. The mode logic and dynamics of the DC motor are both modeled using Stateflow.
Model a popular toy called "Newton's cradle" which consists of a row of seven identical balls which are hung from a common height. At rest they are arranged such that they just touch each other.
This model shows how to define continuous time state variables and their derivatives in Stateflow®. The dynamics of a bouncing ball can be defined in terms of two continuous time variables,
This model shows the modeling of the Simulink® clutch example using Simulink based states inside a Stateflow® chart. You can find a detailed explanation of the physical system, including
Model the opening shot of pool using continuous time semantics of Stateflow®. There are 15 balls arranged in a triangular grid near one end of the table and the cue ball is released towards them
The model of a rectifier which takes a single (scalar) input and converts it into its absolute value. This simple model illustrates the zero crossings capability of Stateflow® (a new feature
This model shows a simple use of Simulink functions in Stateflow. Starting from R2008b, you can use Simulink function call subsystems in Stateflow just like other function objects such as
A model that demonstrates a basic temperature control simulation that allows you to enter the temperatures and the power of the air conditioner that you want to use.
The use of flow charts in a Stateflow® C chart to create C statements such as the FOR loop. This particular example shows how you can create a simple FOR Loop that defines an array variable. The
How a WHILE loop and a DO-WHILE can be implemented in Stateflow® in order to create a variable array. The equivalent statements in C-Code are as follows:
This model shows how you can schedule a Simulink algorithm using Stateflow.
The use of flow charts in Stateflow® to create C or MATLAB® statements such as the IF - ELSE statement. This particular example shows how you can create a simple IF - ELSE statement in Stateflow.
The example shows the ability of Stateflow® to accept matrix input signals from Simulink® and also output matrix signals to Simulink. In this particular example, we are multiplying a [2x2]
The State Transition Matrix view for a simple model of a debouncing logic that uses State Transition Tables in Stateflow® (new in R2012b).
This model shows how you can design switching controllers by combining the power of Stateflow and Simulink functions.
This model shows the basic semantics of absolute time temporal logic in Stateflow®.
The concept of a graphical function and how it can be used to simplify your Stateflow® model. In this example, we pass two inputs in the Stateflow chart. The first input is a sine wave with
The advantage of using the EVERY function to call a graphical function when certain events occur. Notice how complicated it becomes when you try to accomplish the same behavior without the
Use "Simulation Save and Restore" feature with Stateflow charts. There are two common use cases as listed below.
This model shows the use of Superstep semantics on a Stateflow® chart which allows the chart to repeatedly take all possible transitions from the current state to get to a stable state
'Proceed' mode behaviour for the Superstep semantics for Stateflow® charts. Please see the documentation for help on selecting this mode for the Stateflow chart. Once this mode is turned
Use a variable from the MATLAB® workspace in a Stateflow® chart. The variables delay and gain are local variables whose initial value method is defined as "Parameter". For such variables,
This example shows the difference between two Stateflow® charts: one chart uses temporal logic and the AFTER function to achieve the goal, and the other chart achieves the same goal without
This model shows how Stateflow® allows you to incorporate and to call your custom-written C-Code functions.
How the Change Detection feature allows a condition in a Stateflow® chart to query whether a chart input, output or local variable has changed value since the last time step. This example
A simple use of variable-size data in Stateflow® charts. Starting from R2010a, variable-size data can be passed as inputs and outputs to and from MATLAB® functions, MATLAB® truth-tables,
Interface Simulink® bus signals with a Stateflow® chart, how to define Stateflow data of structure type using Simulink.Bus object, and how to integrate custom C code with structure typed
Vectorize the data inputs and perform 1-D array manipulations. In this example, the following MATLAB® code is implemented:
The use of function call event outputs from a Stateflow® chart to drive other Stateflow® charts as well as Simulink® function call subsystem.
This model shows a re-visit of the classic tetris game which has been shipping with Stateflow® to use some of the more modern programming paradigms and features. It shows the use of the
Use Stateflow® to model a bang-bang control system that regulates the temperature of a boiler. The boiler dynamics are modeled in Simulink® in a boiler plant model.
Model a home alarm system including motion sensors. Like in modern alarm systems, if the system detects an intrusion, it allows a certain (small) time for the alarm to be disabled, otherwise
This model shows a method for measuring the frequency response of a continuous time system (plant) using Stateflow®. It illustrates several features of Stateflow® such as the
This model shows a variation of the classic tic-tac-toe game with an interesting twist. Only the last three moves of each player count. Thus the user needs to also account for the order in which
How Mealy and Moore machines can be used in signal processing applications; in this case, for sequence recognition. In the Moore machine, actions can only be state actions, whereas in the
Use the truth table block to control the temperature and humidity using a climate control system. The truth table block defines two possible boolean variables, Hot and Dry. Stateflow® sets
This model shows how MATLAB®, Simulink®, and Stateflow® can be used together to create and edit graphical icons. On running the simulation, a drawing window will appear. You can then select
The difference between fixed-point and floating-point computation by displaying the result of computing the Mandelbrot set using each method in a figure window.
The simulation of a queueing system for a server processing tasks. There are four Stateflow® charts involved in the process: 1) The Source produces tasks that are weighted 1 to 5. Tasks take an
A simple model of a CD Player/Radio logic that uses enumerated data types in Simulink® and Stateflow® (new in R2008b).
Model a two-car elevator system with some of the common features expected in modern elevators such as call queuing, fire alarm responses, hall calls etc.
Illustrates a common design pattern with messages: processing all the messages in the queue in a single time step.
Models an intersection of two 1-way roads controlled using a distributed control system. In order to coordinate the traffic light state between the two charts, the two charts communicate
Illustrates a common design pattern using message semantics: receiving acknowledgements from one or more charts to which you have sent a message.
Two important concepts underlying the lifetime of Stateflow® messages.
The difference between forwarding a message and resending another message with the same data.
This model shows the basic semantics and syntax of sending and receiving messages by contrasting them with data and events. Prior to messages, Stateflow® charts could communicate with each