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]
This model shows how you can design switching controllers by combining the power of Stateflow and Simulink functions.
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 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
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
Use "Simulation Save and Restore" feature with Stateflow charts. There are two common use cases as listed below.
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,
'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
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.
The use of Change detection feature that allows a condition in a Stateflow® chart to query whether a chart input or local variable has changed value since the last time step. This example shows
This model shows a simple use of combined actions in Stateflow®. Multiple state actions can be combined into a single composite action, making the code more concise. This syntax works for
A simple use of multiword fixed-point data in Stateflow® charts. Starting from R2010a, you can define multiword fixed-point data at the chart level, with one of the following scopes:
How graphical functions can be used as recursive functions. The graphical function in the chart (called FACTORIAL) returns the factorial value of the input. This is possible because
The advantage of using the AT function. In this example, the AT function is used three times in the 'Temporal Logic' chart.
A simple model of a CD Player/Radio logic that uses State Transition Tables in Stateflow® (new in R2012b). This model is a reimplementation of sf_cdplayer using State Transition Tables.
The use of BEFORE function to execute a transition or an action before a certain number of events occur. In this example, we illustrate the use of the BEFORE function for three different
The use of feedback when using function-call outputs. The 'Source' chart sends the signal 'out_fcn_two' when transition to from State A to State B or vice versa. 'out_fcn_two' activates
How Stateflow® local variables and outputs can be resolved to Simulink® Signal Objects. Double click on the chart 'Signal Object Chart'. Open Model Explorer and navigate to the chart
This model shows a new feature in Stateflow® R2008a, namely, the ability to have multiple outputs from a graphical function. The syntax for calling a function with multiple outputs is
This model shows the behavior of absolute time temporal logic in the presence of enabled subsystems.
How graphical functions can be exported and used as a means for accessing data. The output shown in the scope block, is equal to 1 when the manual switch is in the On_switch state, or 0 when the
Use flow charts in a Stateflow® block to calculate the product of two fixed-point numbers.
The use of fixed point operations in Stateflow® to create a graph from a sine wave input.
This model shows the behavior of absolute time temporal logic in the presence of continuous time Stateflow® charts with zero crossings enabled.
Use the static error diagnostics in State Transition Tables (STT) in Stateflow® (new in R2012b).
The use of a fixed point variable in Simulink® and Stateflow® to create an output in a specified range.
'Throw Error' 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
A simple implementation of the Karplus-Strong algorithm for string synthesis, using Stateflow®. The Stateflow® charts use Moore semantics.