| Stateflow® and Stateflow® Coder Release Notes | ![]() |
New Features
This section summarizes new features added to Stateflow 6.0 and Stateflow Coder 6.0 for Release 14. These Release Notes reflect the following new features introduced since Stateflow 5.0 and Stateflow Coder 5.0 Release Notes.
Multibyte Comment Characters in Generated Code
You can optionally include Stateflow action language comments in generated code for a Real-Time Workshop or Stateflow custom target. When you do this, multibyte characters in Stateflow action language comments are preserved as multibyte characters in the generated code. This means that you can have comments in code with characters from non-English alphabets such as Japanese Kanji or Chinese Hanzi characters.
See Comment Symbols for more information on inserting comments into Stateflow action language and optionally into Stateflow generated code.
Target Configuration Integration with Simulink and RTW
Configuring simulation and RTW targets for the Stateflow blocks in nonlibrary models has been integrated with Simulink target configuration in the Configuration Parameters dialog. For library models, you still configure targets for Stateflow blocks in Stateflow as you did for previous versions of Stateflow. This also applies to the configuration of Stateflow custom targets.
For more information on configuring targets for models with Stateflow blocks in the Simulink Configuration Parameters dialog, see the following sections in Stateflow documentation:
Type Casting with cast and type
Stateflow now supports the cast operator cast for all Stateflow data types except ml and fixed-point data. To make casting easier, Stateflow also provides a type operator that provides the type of an existing data you can use as an argument in cast operations.
The cast and type operators are documented in Type Cast Operations in Stateflow online documentation.
Data and State Activity Logging
You can log the values of Stateflow data and the activity of Stateflow states against sampling time during simulation. After simulation you access the data with a set of object-oriented commands. See Logging Data Values and State Activity in Stateflow documentation for a detailed example.
Data Type and Size Inheritance From Simulink
Stateflow inherits the type and size for input and output data from the signals that connect to them in Simulink. This feature minimizes the double data entry that was previously required for defining Stateflow input and output data. To inherit input or output data type from their block connections in Simulink, enter Inherited for their Type property. To inherit input or output data size from their block connections in Simulink, enter -1 for their Size property.
See Inheriting Input and Output Data Type from Simulink in and Inheriting Input and Output Data Size from Simulink in the Stateflow documentation more detailed descriptions.
Data and State Monitoring with a Floating Scope
Use Simulink floating scope blocks monitor Stateflow data during simulation. Stateflow data and states now appear in the hierarchy of the Signal Selector dialog of a floating scope. Selecting them causes them to be displayed in the floating scope at simulation time.
See Using a Floating Scope to Monitor Data Values and State Activity in Stateflow documentation for an example.
Data Sized by Expression
You can use expressions in the Size property for Stateflow data. Expressions can include numeric constants, arithmetic operators, Stateflow data of scope Parameter or Constant, and calls to the MATLAB functions min, max, and size. See Specifying Data Size in Stateflow documentation for more details.
Parameter Scope for Simulink Parameters In Stateflow
You can specify Stateflow constant read-only data that is initialized from the MATLAB workspace by specifying data with the scope Parameter. The MATLAB workspace can include Simulink parameters for masked subsystems that contain the Stateflow block or variables in the MATLAB base workspace. See Initializing Data from the MATLAB Workspace in Stateflow documentation for more information.
Obsolete Chart Parented Temporary Data
Chart parented data no longer has the option of being marked temporary. Instead, an optimization in Stateflow generated code converts chart parented local data acting as temporary data to temporary data.
No conversion needs to be made to old models; chart parented temporary data is automatically converted to local data.
Command Line Debugger in MATLAB
The Stateflow Debugger Browse Data option is limited in displaying all the elements of a large matrix. The Stateflow Debugger now supports a command-line mode at the MATLAB command prompt. Now when a Stateflow breakpoint is reached you can type simple expressions at the Stateflow command-line debugger in the MATLAB command window to display their value. For example, the following entries compute and display values for parts of the matrix x in the MATLAB command window:
For details on using the Command Line Debugger in MATLAB, see the topic Using the Command Line Debugger to Watch Data in Stateflow documentation.
Stateflow Boxes Parent Data
Box objects in Stateflow charts can now parent data. This is useful for encapsulating the design better by limiting the visibility of certain data to a given Box object and its hierarchy. For example, a Box object that parents data and graphical functions that manipulate this data can be thought of as an implementation of a singleton class with data and methods.
Stateflow in the Model Explorer
The new Model Explorer tool in Simulink now lists Stateflow objects in its hierarchy of Simulink model objects. In place of the old Explorer tool in Stateflow, you now use the Model Explorer tool to add and modify data and events to Stateflow objects. For complete details on using the Model Explorer from Stateflow, see the section Using the Model Explorer with Stateflow Objects in Stateflow documentation.
For details on using the Model Explorer in Simulink, see The Model Explorer in Simulink documentation.
Writable Dirty Property for API Chart Object
The Dirty property for a Chart object in the Stateflow API is writable. The Dirty property for the Machine object is still read-only (RO).
Fixed-Point Autoscaling of Stateflow Data
Stateflow fixed-point data now participate in autoscaling for fixed-point numbers in Simulink. For a procedure on how to autoscale fixed-point data in Simulink, see the topic Automatic Scaling in Fixed-Point Blockset documentation.
Support for Directional Vectors
Stateflow now supports directional vectors. Directional vectors can be row or column vectors. Row vectors are matrices with one row (for example, [1,3]), and column vectors are matrices with one column (for example, [3,1]). In prior versions, vectors were specified only as single index arrays (for example, [3]). These arrays are now interpreted as column vectors (for example, [3,1]).
You can still specify single index arrays as input from and output to the Simulink model. To maintain backward compatibility with prior versions, single index arrays are compatible with Simulink row or column vectors of the same size. However, if you specify Stateflow input or output data as a directional vector, the corresponding Simulink signal must match the specified direction or a mismatch error results.
Stateflow data also has a similar relationship with MATLAB workspace data used to initialize it during simulation. In this case, single index arrays in Stateflow can be initialized by MATLAB workspace row or column vectors of the same size. However, a Stateflow vector of a specified direction can only be initialized by a vector of the same size and direction in MATLAB.
Stateflow directional vectors are introduced in Stateflow version 6.0 (R14) and documented in Defining Input and Output Signals from Simulink in the Stateflow documentation.
Embedded MATLAB Functions
Stateflow now gives users access to a special subset of MATLAB programming in the form of Embedded MATLAB functions. These functions give you the power of MATLAB data, function, and language features that are specially tailored to the tight memory and operating system requirements found in embedded target environments.
Stateflow eML functions provide the following functionality to users:
Embedded MATLAB functions are introduced in Stateflow 6.0 and Stateflow Coder 6.0 and are documented in Using Embedded MATLAB Functions in Stateflow online documentation.
Custom C++ Code Included with Stateflow Generated Code
With the proper modifications, you can now include C++ custom code with Stateflow generated code.
Support for including C++ custom code in Stateflow generated code is introduced in Stateflow Coder 6.0 and is documented in Including Custom C++ Code in Stateflow online documentation.
Object Descriptions in Generated Code for RTW Targets
The object descriptions entered in the property dialogs for charts, states, transitions, and graphical functions are now optionally propagated into RTW generated code with RTW Embedded Coder license. You can specify this in the Simulink Configuration Parameters dialog as follows:
Matrix Inputs and Outputs for Graphical Functions
Input and output data sizes for Stateflow graphical functions can now be vectors or two-dimensional matrices. The semantics of the input vector or matrix data are compliant with MATLAB's "pass by value" instead of "pass-by reference" for the C language.
Warnings for Missing Default Paths
A common modeling error in Stateflow is to create states with one of the following:
Both of these cases are now detected during code generation and result in a warning to fix the model.
Unified Code Generation Settings for Simulink and Stateflow
All Stateflow code generation settings for Real-Time Workshop are now consolidated into the new Simulink/RTW Configuration Parameters dialog. This enables users to specify code generation settings for Simulink and Stateflow in a single location.
In addition, custom code settings (code inclusion, user source files, and so on) are now supported by the Configuration Parameters dialog for Real-Time Workshop, although it can still be entered on Stateflow's Real-Time Workshop target object. All custom code settings and Stateflow optimization settings from old models are grandfathered into the new Configuration Parameters dialog at load time.
Faster Real-Time Workshop Code Generation
Stateflow uses a two-phase code-generation scheme with Real-Time Workshop. During the first phase, a TLC file is generated from every chart. These TLC files are converted into C code in the second phase. In R13SP1 and prior versions, Stateflow regenerated these TLC files for charts even when they had not changed from a previous code generation session. In Release 14, the first phase of TLC generation is incremental so that the TLC file for a chart is regenerated only if there is a change in the chart since the last code generation session. This incremental TLC generation significantly improves the speed of RTW code generation for models with a large number of Stateflow charts. If, for any reason, you desire to turn off the incremental TLC generation, use the following command, which lasts until the end of the current MATLAB session:
Unified Identifier Naming Scheme in Generated Code
The names of identifiers (variable names, structure names, field names in structures, function names) in the generated code from Simulink/Stateflow model are now uniformly managed for a common look and feel, and to prevent name collisions.
| Known Software Limitations | Major Bug Fixes | ![]() |
© 1994-2005 The MathWorks, Inc.