Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Industries Academia Support User Community Company
spacer spacer spacer spacer spacer spacer

 

Stateflow 7.4

Product Description

Adding Functions

With Stateflow you can define and use three types of functions in your chart:

Graphical functions—for graphically programming an algorithm and tracking its behavior during simulation

Embedded MATLAB™ functions — for calling MATLAB functions for data analysis and visualization, and for defining embedded, matrix-oriented algorithms

Truth tables—for specifying functions with combinational logic in a concise, tabular form without drawing flow diagrams

You can call Simulink subsystems like functions from Stateflow. You can also incorporate existing hand-written C code functions into your Stateflow chart.

Stateflow Figure 4

Truth table used to implement the logic to select a valid sensor reading in a fault-detection algorithm. Click on image to see enlarged view.

Specifying Temporal Logic Conditions

Stateflow employs an event-scheduling mechanism that generates accurate and efficient code for event-driven systems. You can use temporal operators (before, after, at, and every) to specify scheduling logic for transition and state activities. These temporal logic conditions respond to counts of Stateflow events, freeing you from the error-prone event-scheduling tasks of handling timers and counters.

Statefloe Figure 5

Stateflow chart (below, left) defining the logic for a boiler temperature control system that uses temporal logic to ensure that the boiler does not overheat. An Embedded MATLAB function (left) and graphical functions (right side of chart) implement utility algorithms called by the heater system (left side of chart). Click on image to see enlarged view.

Creating Chart Libraries

By creating a chart library in Stateflow, you facilitate chart reuse. For example, when you update a chart in a library, all instances of the chart are automatically updated.

Interfacing with Simulink

You can exchange events and data with Simulink by simply:

  • Adding and defining input and output events and data for your Stateflow chart in Model Explorer
  • Connecting the Stateflow input and output ports to Simulink blocks
  • Defining simulation parameters in Simulink

You can also define an interface between a Stateflow block and code sources external to the Stateflow block and Simulink model. Model Explorer lets you navigate, create, configure, and search all data, events, and attributes of your Stateflow chart, as well as create an interface with Simulink.

Stateflow Figure 6

>Model Explorer, which lets you navigate, create, configure, and search all data, events, and attributes of your Stateflow chart, as well as create an interface with Simulink. Click on image to see enlarged view.

Stateflow Figure 7

Logic for a fault-tolerant fuel system, defined using several key Stateflow elements. Click on image to see enlarged view.

Contact sales
Free technical kit
Trial software
E-mail this page

Get Pricing and
Licensing Options

Upcoming Webinar

Generate C Code from MATLAB Functions Using the Embedded MATLAB Subset new