| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Stateflow |
| Contents | Index |
| Learn more about Stateflow |
This table summarizes what's new in V7.2 (R2008b):
| New Features and Changes | Version Compatibility Considerations | Fixed Bugs and Known Problems | Related Documentation at Web Site |
|---|---|---|---|
| Yes Details below | Yes—Details labeled as Compatibility Considerations, below. See also Summary. | Bug
Reports | No |
New features and changes introduced in this version are:
Support for Embedding Simulink Function-Call Subsystems in a Stateflow Chart
Support for Using Enumerated Data Types in a Stateflow Chart
New Alignment, Distribution, and Resizing Commands for Stateflow Charts
New Pattern Wizard for Consistent Creation of Logic Patterns and Iterative Loops
Support for Initializing Vectors and Matrices in the Data Properties Dialog Box
Change in Default Mode for Ordering Parallel States and Outgoing Transitions
Change in Casting Behavior When Calling MATLAB Functions in a Chart
Use of Output Data with Change Detection Operators Disallowed for Initialize-Outputs-at-Wakeup Mode
Parsing a Stateflow Chart Without Simulation No Longer Detects Unresolved Symbol Errors
Generation of a Unique Name for a Copied State Limited to States Without Default Labels
New Configuration Set Created When Loading Nonlibrary Models with an Active Configuration Reference
You can use a Simulink function to embed a function-call subsystem in a Stateflow chart. You fill this function with Simulink blocks and call it in state actions and on transitions. Like graphical functions, truth table functions, and Embedded MATLAB functions, you can use multiple return values with Simulink functions.
For more information, see Using Simulink Functions in Stateflow Charts in the Stateflow and Stateflow Coder User's Guide.
You can use data of an enumerated type in a Stateflow chart.
For more information, see Using Enumerated Data in Stateflow Charts in the Stateflow and Stateflow Coder User's Guide and Using Enumerated Data in the Simulink User's Guide. For information on how enumerated data types appear in Real-Time Workshop generated code, see Enumerated Data Type Considerations in the Real-Time Workshop User's Guide.
You can use alignment, distribution, and resizing commands on graphical chart objects, such as states, functions, and boxes.
For more information, see Formatting Chart Objects in the Stateflow and Stateflow Coder User's Guide.
You can use a single dialog box to specify simulation and embeddable code generation options that apply to Stateflow charts and Truth Table blocks. These changes apply:
| Type of Model | Simulation Options | Embeddable Code Generation Options |
|---|---|---|
| Nonlibrary | Migrated from the Simulation Target dialog box to the Configuration Parameters dialog box | Enhanced with new options in the Real-Time Workshop pane of the Configuration Parameters dialog box See GUI Enhancements in Real-Time Workshop Code Generation Options for Nonlibrary Models |
| Library | Migrated from the Simulation Target dialog box to the Configuration Parameters dialog box | Migrated from the RTW Target dialog box to the Configuration Parameters dialog box See GUI Changes in Real-Time Workshop Code Generation Options for Library Models |
For more information, see Configuration Parameters Dialog Box in the Simulink Graphical User Interface and Building Targets in the Stateflow and Stateflow Coder User's Guide.
For compatibility information, see Compatibility Considerations.
The following sections describe changes in the panes of the Simulation Target dialog box for nonlibrary models.
Changes for the General Pane of the Simulation Target Dialog Box.
| Release | Appearance |
|---|---|
| Previous | General pane of the Simulation Target dialog box
|
| New | Simulation Target pane of the Configuration Parameters dialog box
|
For details, see Nonlibrary Models: Mapping of GUI Options from the Simulation Target Dialog Box to the Configuration Parameters Dialog Box.
Changes for the Custom Code Pane of the Simulation Target Dialog Box.
| Release | Appearance |
|---|---|
| Previous | Custom Code pane of the Simulation Target dialog box
|
| New | Simulation Target > Symbols pane of the Configuration Parameters dialog box
|
| New | Simulation Target > Custom Code pane of the Configuration Parameters dialog box
|
For details, see Nonlibrary Models: Mapping of GUI Options from the Simulation Target Dialog Box to the Configuration Parameters Dialog Box.
Changes for the Description Pane of the Simulation Target Dialog Box. In previous releases, the Description pane of the Simulation Target dialog box appeared as follows.

In R2008b, these options are no longer available. For older models where the Description pane contained information, the text is now accessible only in the Model Explorer. When you select Simulink Root > Configuration Preferences in the Model Hierarchy pane, the text appears in the Description field for that model.
Nonlibrary Models: Mapping of GUI Options from the Simulation Target Dialog Box to the Configuration Parameters Dialog Box. For nonlibrary models, the following table maps each GUI option in the Simulation Target dialog box to the equivalent in the Configuration Parameters dialog box. The options are listed in order of appearance in the Simulation Target dialog box.
| Old Option in the Simulation Target Dialog Box | New Option in the Configuration Parameters Dialog Box | Default Value of New Option |
|---|---|---|
| General > Enable debugging / animation | Simulation Target > Enable debugging / animation | on |
| General > Enable overflow detection (with debugging) | Simulation Target > Enable overflow detection (with debugging) | on |
| General > Echo expressions without semicolons | Simulation Target > Echo expressions without semicolons | on |
| General > Build Actions | Simulation Target > Simulation target build mode | Incremental build |
| None | Simulation Target > Custom Code > Source file | '' |
| Custom Code > Include Code | Simulation Target > Custom Code > Header file | '' |
| Custom Code > Include Paths | Simulation Target > Custom Code > Include directories | '' |
| Custom Code > Source Files | Simulation Target > Custom Code > Source files | '' |
| Custom Code > Libraries | Simulation Target > Custom Code > Libraries | '' |
| Custom Code > Initialization Code | Simulation Target > Custom Code > Initialize function | '' |
| Custom Code > Termination Code | Simulation Target > Custom Code > Terminate function | '' |
| Custom Code > Reserved Names | Simulation Target > Symbols > Reserved names | {} |
| Custom Code > Use these custom code settings for all libraries | None | Not applicable |
| Description > Description | None | Not applicable |
| Description > Document Link | None | Not applicable |
Note For nonlibrary models, Simulation Target options in the Configuration Parameters dialog box are also available in the Model Explorer. When you select Simulink Root > Configuration Preferences in the Model Hierarchy pane, you can select Simulation Target in the Contents pane to access the options. |
The following sections describe changes in the panes of the Simulation Target dialog box for library models.
Changes for the General Pane of the Simulation Target Dialog Box. In previous releases, the General pane of the Simulation Target dialog box for library models appeared as follows.

In R2008b, these options are no longer available. All library models inherit these option settings from the main model to which the libraries are linked.
Changes for the Custom Code Pane of the Simulation Target Dialog Box.
| Release | Appearance |
|---|---|
| Previous | Custom Code pane of the Simulation Target dialog box
|
| New | Simulation Target pane of the Configuration Parameters dialog box
|
For details, see Library Models: Mapping of GUI Options from the Simulation Target Dialog Box to the Configuration Parameters Dialog Box.
Changes for the Description Pane of the Simulation Target Dialog Box. In previous releases, the Description pane of the Simulation Target dialog box appeared as follows.

In R2008b, these options are no longer available. For older models where the Description pane contained information, the text is discarded.
Library Models: Mapping of GUI Options from the Simulation Target Dialog Box to the Configuration Parameters Dialog Box. For library models, the following table maps each GUI option in the Simulation Target dialog box to the equivalent in the Configuration Parameters dialog box. The options are listed in order of appearance in the Simulation Target dialog box.
| Old Option in the Simulation Target Dialog Box | New Option in the Configuration Parameters Dialog Box | Default Value of New Option |
|---|---|---|
| General > Enable debugging / animation | None | Not applicable |
| General > Enable overflow detection (with debugging) | None | Not applicable |
| General > Echo expressions without semicolons | None | Not applicable |
| General > Build Actions | None | Not applicable |
| None | Simulation Target > Source file | '' |
| Custom Code > Include Code | Simulation Target > Header file | '' |
| Custom Code > Include Paths | Simulation Target > Include directories | '' |
| Custom Code > Source Files | Simulation Target > Source files | '' |
| Custom Code > Libraries | Simulation Target > Libraries | '' |
| Custom Code > Initialization Code | Simulation Target > Initialize function | '' |
| Custom Code > Termination Code | Simulation Target > Terminate function | '' |
| Custom Code > Reserved Names | None | Not applicable |
| Custom Code > Use local custom code settings (do not inherit from main model) | Simulation Target > Use local custom code settings (do not inherit from main model) | off |
| Description > Description | None | Not applicable |
| Description > Document Link | None | Not applicable |
Note For library models, Simulation Target options in the Configuration Parameters dialog box are not available in the Model Explorer. |
The following sections describe enhancements to the Real-Time Workshop pane of the Configuration Parameters dialog box for nonlibrary models.
Enhancement for the Real-Time Workshop: Symbols Pane of the Configuration Parameters Dialog Box. In previous releases, the Real-Time Workshop > Symbols pane of the Configuration Parameters dialog box appeared as follows.

In R2008b, a new option is available in this pane: Reserved names. You can use this option to specify a set of keywords that the Real-Time Workshop build process should not use. This action prevents naming conflicts between functions and variables from external environments and identifiers in the generated code.

You can also choose to use the reserved names specified in the Simulation Target > Symbols pane to avoid entering the same information twice for the nonlibrary model. Select the Use the same reserved names as Simulation Target check box.
For more information, see Reserved names in the Real-Time Workshop Reference.
Enhancement for the Real-Time Workshop: Custom Code Pane of the Configuration Parameters Dialog Box. In previous releases, the Real-Time Workshop > Custom Code pane of the Configuration Parameters dialog box appeared as follows.

In R2008b, a new option is available in this pane: Use the same custom code settings as Simulation Target. You can use this option to copy the custom code settings from the Simulation Target > Custom Code pane to avoid entering the same information twice for the nonlibrary model.

For more information, see Use the same custom code settings as Simulation Target in the Real-Time Workshop Reference.
The following sections describe changes in the panes of the RTW Target dialog box for library models.
Changes for the General Pane of the RTW Target Dialog Box. In previous releases, the General pane of the RTW Target dialog box for library models appeared as follows.

In R2008b, these options are no longer available. During Real-Time Workshop code generation, options specified for the main model are used.
Changes for the Custom Code Pane of the RTW Target Dialog Box.
| Release | Appearance |
|---|---|
| Previous | Custom Code pane of the RTW Target dialog box
|
| New | Real-Time Workshop pane of the Configuration Parameters dialog box
|
For details, see Library Models: Mapping of GUI Options from the RTW Target Dialog Box to the Configuration Parameters Dialog Box.
Changes for the Description Pane of the RTW Target Dialog Box. In previous releases, the Description pane of the RTW Target dialog box appeared as follows.

In R2008b, these options are no longer available. For older models where the Description pane contained information, the text is discarded.
Library Models: Mapping of GUI Options from the RTW Target Dialog Box to the Configuration Parameters Dialog Box. For library models, the following table maps each GUI option in the RTW Target dialog box to the equivalent in the Configuration Parameters dialog box. The options are listed in order of appearance in the RTW Target dialog box.
| Old Option in the RTW Target Dialog Box | New Option in the Configuration Parameters Dialog Box | Default Value of New Option |
|---|---|---|
| General > Comments in generated code | None | Not applicable |
| General > Use bitsets for storing state configuration | None | Not applicable |
| General > Use bitsets for storing boolean data | None | Not applicable |
| General > Compact nested if-else using logical AND/OR operators | None | Not applicable |
| General > Recognize if-elseif-else in nested if-else statements | None | Not applicable |
| General > Replace constant expressions by a single constant | None | Not applicable |
| General > Minimize array reads using temporary variables | None | Not applicable |
| General > Preserve symbol names | None | Not applicable |
| General > Append symbol names with parent names | None | Not applicable |
| General > Use chart names with no mangling | None | Not applicable |
| General > Build Actions | None | Not applicable |
| None | Real-Time Workshop > Source file | '' |
| Custom Code > Include Code | Real-Time Workshop > Header file | '' |
| Custom Code > Include Paths | Real-Time Workshop > Include directories | '' |
| Custom Code > Source Files | Real-Time Workshop > Source files | '' |
| Custom Code > Libraries | Real-Time Workshop > Libraries | '' |
| Custom Code > Initialization Code | Real-Time Workshop > Initialize function | '' |
| Custom Code > Termination Code | Real-Time Workshop > Terminate function | '' |
| Custom Code > Reserved Names | None | Not applicable |
| Custom Code > Use local custom code settings (do not inherit from main model) | Real-Time Workshop > Use local custom code settings (do not inherit from main model) | off |
| None | Real-Time Workshop > Use the same custom code settings as Simulation Target | off |
| Description > Description | None | Not applicable |
| Description > Document Link | None | Not applicable |
Note For library models, Real-Time Workshop options in the Configuration Parameters dialog box are not available in the Model Explorer. |
Previously, you could programmatically set options for simulation and embeddable code generation by accessing the API properties of Target objects sfun and rtw, respectively. In R2008b, the API properties of Target objects sfun and rtw are replaced by parameters that you configure using the commands get_param and set_param.
For compatibility details, see Updating Scripts That Set Options Programmatically for Simulation and Embeddable Code Generation and What Happens When You Load an Older Model in R2008b.
Mapping of Object Properties to Simulation Parameters for Nonlibrary Models. The following table maps API properties of the Target object sfun for nonlibrary models to the equivalent parameters in R2008b. Object properties are listed in alphabetical order; those not listed in the table do not have equivalent parameters in R2008b.
| Old sfun Object Property | Old Option in the Simulation Target Dialog Box | New Configuration Parameter | New Option in the Configuration Parameters Dialog Box |
|---|---|---|---|
CodeFlagsInfo | General > Enable debugging / animation | SFSimEnableDebug string - off, on | Simulation Target > Enable debugging / animation |
CodeFlagsInfo | General > Enable overflow detection (with debugging) | SFSimOverflowDetection string - off, on | Simulation Target > Enable overflow detection (with debugging) |
CodeFlagsInfo | General > Echo expressions without semicolons | SFSimEcho string - off, on | Simulation Target > Echo expressions without semicolons |
| CustomCode | Custom Code > Include Code | SimCustomHeaderCode string - '' | Simulation Target > Custom Code > Header file |
| CustomInitializer | Custom Code > Initialization Code | SimCustomInitializer string - '' | Simulation Target > Custom Code > Initialize function |
| CustomTerminator | Custom Code > Termination Code | SimCustomTerminator string - '' | Simulation Target > Custom Code > Terminate function |
ReservedNames | Custom Code > Reserved Names | SimReservedNameArray string array - {} | Simulation Target > Symbols > Reserved names |
| UserIncludeDirs | Custom Code > Include Paths | SimUserIncludeDirs string - '' | Simulation Target > Custom Code > Include directories |
| UserLibraries | Custom Code > Libraries | SimUserLibraries string - '' | Simulation Target > Custom Code > Libraries |
| UserSources | Custom Code > Source Files | SimUserSources string - '' | Simulation Target > Custom Code > Source files |
Mapping of Object Properties to Simulation Parameters for Library Models. The following table maps API properties of the Target object sfun for library models to the equivalent parameters in R2008b. Object properties are listed in alphabetical order; those not listed in the table do not have equivalent parameters in R2008b.
| Old sfun Object Property | Old Option in the Simulation Target Dialog Box | New Configuration Parameter | New Option in the Configuration Parameters Dialog Box |
|---|---|---|---|
| CustomCode | Custom Code > Include Code | SimCustomHeaderCode string - '' | Simulation Target > Header file |
| CustomInitializer | Custom Code > Initialization Code | SimCustomInitializer string - '' | Simulation Target > Initialize function |
| CustomTerminator | Custom Code > Termination Code | SimCustomTerminator string - '' | Simulation Target > Terminate function |
UseLocalCustomCodeSettings | Custom Code > Use local custom code settings (do not inherit from main model) | SimUseLocalCustomCode string - off, on | Simulation Target > Use local custom code settings (do not inherit from main model) |
| UserIncludeDirs | Custom Code > Include Paths | SimUserIncludeDirs string - '' | Simulation Target > Include directories |
| UserLibraries | Custom Code > Libraries | SimUserLibraries string - '' | Simulation Target > Libraries |
| UserSources | Custom Code > Source Files | SimUserSources string - '' | Simulation Target > Source files |
Mapping of Object Properties to Code Generation Parameters for Library Models. The following table maps API properties of the Target object rtw for library models to the equivalent parameters in R2008b. Object properties are listed in alphabetical order; those not listed in the table do not have equivalent parameters in R2008b.
| Old rtw Object Property | Old Option in the RTW Target Dialog Box | New Configuration Parameter | New Option in the Configuration Parameters Dialog Box |
|---|---|---|---|
| CustomCode | Custom Code > Include Code | CustomHeaderCode string - '' | Real-Time Workshop > Header file |
| CustomInitializer | Custom Code > Initialization Code | CustomInitializer string - '' | Real-Time Workshop > Initialize function |
| CustomTerminator | Custom Code > Termination Code | CustomTerminator string - '' | Real-Time Workshop > Terminate function |
| UseLocalCustomCodeSettings | Custom Code > Use local custom code settings (do not inherit from main model) | RTWUseLocalCustomCode string - off, on | Real-Time Workshop > Use local custom code settings (do not inherit from main model) |
| UserIncludeDirs | Custom Code > Include Paths | CustomInclude string - '' | Real-Time Workshop > Include directories |
| UserLibraries | Custom Code > Libraries | CustomLibrary string - '' | Real-Time Workshop > Libraries |
| UserSources | Custom Code > Source Files | CustomSource string - '' | Real-Time Workshop > Source files |
In R2008b, new parameters are added to the Configuration Parameters dialog box for simulation and embeddable code generation.
New Simulation Parameters for Nonlibrary Models. The following table lists the new simulation parameters that apply to nonlibrary models.
| New Configuration Parameter | New Option in the Configuration Parameters Dialog Box | Description |
|---|---|---|
SimBuildMode string – sf_incremental_build, sf_nonincremental_build, sf_make, sf_make_clean, sf_make_clean_objects | Simulation Target > Simulation target build mode | Specifies how you build the simulation target for a model. |
SimCustomSourceCode string - '' | Simulation Target > Custom Code > Source file | Enter code lines to appear near the top of a generated source code file. |
New Simulation Parameter for Library Models. The following table lists the new simulation parameter that applies to library models.
| New Configuration Parameter | New Option in the Configuration Parameters Dialog Box | Description |
|---|---|---|
SimCustomSourceCode string - '' | Simulation Target > Source file | Enter code lines to appear near the top of a generated source code file. |
New Code Generation Parameters for Nonlibrary Models. The following table lists the new code generation parameters that apply to nonlibrary models.
| New Configuration Parameter | New Option in the Configuration Parameters Dialog Box | Description |
|---|---|---|
ReservedNameArray string array - {} | Real-Time Workshop > Symbols > Reserved names | Enter the names of variables or functions in the generated code that match the names of variables or functions specified in custom code. |
RTWUseSimCustomCode string – off, on | Real-Time Workshop > Custom Code > Use the same custom code settings as Simulation Target | Specify whether to use the same custom code settings as those specified for simulation. |
UseSimReservedNames string – off, on | Real-Time Workshop > Symbols > Use the same reserved names as Simulation Target | Specify whether to use the same reserved names as those specified for simulation. |
New Code Generation Parameters for Library Models. The following table lists the new code generation parameters that apply to library models.
| New Configuration Parameter | New Option in the Configuration Parameters Dialog Box | Description |
|---|---|---|
CustomSourceCode string – '' | Real-Time Workshop > Source file | Enter code lines to appear near the top of a generated source code file. |
RTWUseSimCustomCode string – off, on | Real-Time Workshop > Use the same custom code settings as Simulation Target | Specify whether to use the same custom code settings as those specified for simulation. |
Updating Scripts That Set Options Programmatically for Simulation and Embeddable Code Generation. In previous releases, you could use the Stateflow API to set options for simulation and embeddable code generation by accessing the Target object (sfun or rtw) in a Stateflow machine. For example, you could set simulation options programmatically by running these commands in a MATLAB script:
r = slroot;
machine = r.find('-isa','Stateflow.Machine','Name','main_mdl');
t_sim = machine.find('-isa','Stateflow.Target','Name','sfun');
t_sim.setCodeFlag('debug',1);
t_sim.setCodeFlag('overflow',1);
t_sim.setCodeFlag('echo',1);
t_sim.getCodeFlag('debug');
t_sim.getCodeFlag('overflow');
t_sim.getCodeFlag('echo');In R2008b, you must update your scripts to use the set_param and get_param commands to configure simulation and embeddable code generation. For example, you can update the previous script as follows:
cs = getActiveConfigSet(gcs); set_param(cs,'SFSimEnableDebug','on'); set_param(cs,'SFSimOverflowDetection','on'); set_param(cs,'SFSimEcho','on'); get_param(cs,'SFSimEnableDebug'); get_param(cs,'SFSimOverflowDetection'); get_param(cs,'SFSimEcho');
| For information about... | See... | |
|---|---|---|
Object properties and their equivalent parameters in R2008b | Mapping of Target Object Properties to Parameters in the Configuration Parameters Dialog Box
| |
Using the set_param and get_param commands | Using the Command-Line API to Set Parameters for Simulation and Embeddable Code Generation in the Stateflow and Stateflow Coder User's Guide |
Accessing Target Options for Library Models. In previous releases, you could access target options for library models via the Tools menu in the Stateflow Editor or the Contents pane of the Model Explorer. In R2008b, you must use the Tools menu to access target options for library models. For example, to specify parameters for the simulation target, select Tools > Open Simulation Target in the Stateflow Editor.
What Happens When You Load an Older Model in R2008b. When you use R2008b to load a model created in an earlier version, dialog box options and the equivalent object properties for simulation and embeddable code generation targets migrate automatically to the Configuration Parameters dialog box, except in the cases that follow.
For the simulation target of a nonlibrary model, these options and properties do not migrate to the Configuration Parameters dialog box. The information is discarded when you load the model, unless otherwise noted.
| Option in the Simulation Target Dialog Box of a Nonlibrary Model | Equivalent Object Property |
|---|---|
| Custom Code > Use these custom code settings for all libraries | ApplyToAllLibs |
| Description > Description | Description |
| Description > Document Link | Document |
For the simulation target of a library model, these options and properties do not migrate to the Configuration Parameters dialog box. The information is discarded when you load the model.
| Option in the Simulation Target Dialog Box of a Library Model | Equivalent Object Property |
|---|---|
| General > Enable debugging / animation | CodeFlagsInfo('debug') |
| General > Enable overflow detection (with debugging) | CodeFlagsInfo('overflow') |
| General > Echo expressions without semicolons | CodeFlagsInfo('echo') |
| General > Build Actions | None |
| Custom Code > Reserved Names | ReservedNames |
| Description > Description | Description |
| Description > Document Link | Document |
For the embeddable code generation target of a library model, these options and properties do not migrate to the Configuration Parameters dialog box. The information is discarded when you load the model.
| Option in the RTW Target Dialog Box of a Library Model | Equivalent Object Property |
|---|---|
| General > Comments in generated code | CodeFlagsInfo('comments') |
| General > Use bitsets for storing state configuration | CodeFlagsInfo('statebitsets') |
| General > Use bitsets for storing boolean data | CodeFlagsInfo('databitsets') |
| General > Compact nested if-else using logical AND/OR operators | CodeFlagsInfo('emitlogicalops') |
| General > Recognize if-elseif-else in nested if-else statements | CodeFlagsInfo('elseifdetection') |
| General > Replace constant expressions by a single constant | CodeFlagsInfo('constantfolding') |
| General > Minimize array reads using temporary variables | CodeFlagsInfo('redundantloadelimination') |
| General > Preserve symbol names | CodeFlagsInfo('preservenames') |
| General > Append symbol names with parent names | CodeFlagsInfo('preservenameswithparent') |
| General > Use chart names with no mangling | CodeFlagsInfo('exportcharts') |
| General > Build Actions | None |
| Custom Code > Reserved Names | ReservedNames |
| Description > Description | Description |
| Description > Document Link | Document |
What Happens When You Save an Older Model in R2008b. When you use R2008b to save a model created in an earlier version, parameters for simulation and embeddable code generation from the Configuration Parameters dialog box are saved. However, properties of API Target objects sfun and rtw are not saved if those properties do not have an equivalent parameter in the Configuration Parameters dialog box (see What Happens When You Load an Older Model in R2008b). Properties that do not migrate to the Configuration Parameters dialog box are discarded when you load the model. Therefore, old Target object properties are not saved even if you choose to save the model as an older version (for example, R2007a).
Workaround for Library Models If They No Longer Use Local Custom Code Settings.
Behavior in R2008a and Earlier Releases
In R2008a and earlier releases, the main model simulation target had a custom code option Use these custom code settings for all libraries, or the target property ApplyToAllLibs. The library model simulation target had a similar custom code option Use local custom code settings (do not inherit from main model), or the target property UseLocalCustomCodeSettings.
The following criteria determined which custom code settings would apply to the library model:
| If ApplyToAllLibs for the main model is... | And UseLocalCustomCodeSettings for the library model is... | Then the library model uses... |
|---|---|---|
| True | False | Main model custom code |
| True | True | Local custom code |
| False | True | Local custom code |
| False | False | Local custom code (by default, but ambiguous) |
The last case was ambiguous, because the main model did not propagate custom code settings and the library model did not specify use of local custom code settings either. In this case, the default behavior was to use local custom code settings for the library model.
Behavior in R2008b
In R2008b, the Use these custom code settings for all libraries option for the main model is removed. The library model either picks up its local custom code settings if specified to do so, or uses the main model custom code settings when the Use local custom code settings option is not selected. This change introduces backward incompatibility for older models that use the "False (main model), False (library model)" setup for specifying custom code settings.
Workaround to Prevent Backward Incompatibility
To resolve the ambiguity in older models, you must explicitly select Use local custom code settings for the library model when you want the local custom code settings to apply:
Open the Stateflow simulation target for the library model.
Load the library model and unlock it.
Open one of the library charts in the Stateflow Editor.
Select Tools > Open Simulation Target.
In the dialog box that appears, select Use local custom code settings (do not inherit from main model).
You can use the Stateflow Pattern Wizard to create commonly used flow graphs such as for-loops in a quick and consistent manner.
For more information, see Modeling Logic Patterns and Iterative Loops Using Flow Graphs in the Stateflow and Stateflow Coder User's Guide.
In the Data properties dialog box, you can initialize vectors and matrices in the Initial value field of the Value Attributes pane.
For more information, see How to Define Vectors and Matrices in the Stateflow and Stateflow Coder User's Guide.
The default mode for ordering parallel states and outgoing transitions is now explicit. When you create a new chart, you define ordering explicitly in the Stateflow Editor. However, if you load a chart that uses implicit ordering, that mode is retained until you switch to explicit ordering.
For more information, see Execution Order for Parallel States and Evaluation Order for Outgoing Transitions in the Stateflow and Stateflow Coder User's Guide.
In R2008b, Real-Time Workshop code generation is enhanced to enable optimized inlining of code generated for Stateflow charts.
When you parse a nonlibrary model, library charts that are not linked to this model are ignored. This enhancement enables more efficient parsing for nonlibrary models.
When you call MATLAB functions in a Stateflow chart, scalar inputs are no longer cast automatically to data of type double. This behavior applies when you use the ml operator to call a built-in or custom MATLAB function. (For details, see ml Namespace Operator in the Stateflow and Stateflow Coder User's Guide.)
Previously, Stateflow generated code for simulation would automatically cast scalar inputs to data of type double when calling MATLAB functions in a chart. This behavior has changed. Stateflow charts created in earlier versions now generate errors during simulation if they contain calls to external MATLAB functions that expect scalar inputs of type double, but the inputs are of a different data type.
To prevent these errors, you can change the data type of a scalar input to double or add an explicit cast to type double in the function call. For example, you can change a function call from ml.function_name(i) to ml.function_name(double(i)).
If you enable the option Initialize Outputs Every Time Chart Wakes Up in the Chart properties dialog box, do not use output data as the first argument of a change detection operator. When this option is enabled, the change detection operator returns false if the first argument is an output data. In this case, there is no reason to perform change detection. (For details, see Using Change Detection in Actions in the Stateflow and Stateflow Coder User's Guide.)
Previously, Stateflow software would allow the use of output data with change detection operators when you enable the option Initialize Outputs Every Time Chart Wakes Up. This behavior has changed. Stateflow charts created in earlier versions now generate errors during parsing to prevent such behavior.
To detect unresolved symbol errors in a chart, you must start simulation or update the model diagram. When you parse a chart without simulation or diagram updates, the Stateflow parser does not have access to all the information needed to check for unresolved symbols, such as exported graphical functions from other charts and enumerated data types. Therefore, the parser now skips unresolved symbol detection to avoid generating false error messages. However, if you start simulation or update the model diagram, you invoke the model compilation process, which has full access to the information needed, and unresolved symbols are flagged.
For more information, see Parsing Stateflow Charts and Resolving Symbols in the Stateflow and Stateflow Coder User's Guide.
If you copy and paste a state in the Stateflow Editor, a unique name is generated for the new state only if the original state does not use the default ? label. For more information, see Copying Graphical Objects in the Stateflow and Stateflow Coder User's Guide.
When you load a nonlibrary model with an active configuration reference for Stateflow charts or Truth Table blocks, a copy of the referenced configuration set is created and attached to your model. The new configuration set is marked active, and the configuration reference is marked inactive. This behavior does not apply to library models.
For information about using configuration references, see Referencing Configuration Sets in the Simulink User's Guide.
In previous releases, you could load a nonlibrary model with an active configuration reference for Stateflow charts or Truth Table blocks. In R2008b, the configuration reference becomes inactive after you load the model, and a warning message appears to explain this change in behavior. To restore the configuration reference to its original active state, follow the instructions in the warning message.
For more information, see Configuration References for Models with Older Simulation Target Settings in the Simulink User's Guide.
![]() | Version 7.3 (R2009a) Stateflow and Stateflow Coder Software | Version 7.1.1 (R2008a+) Stateflow and Stateflow Coder Software | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |