To search for undefined symbol errors, use one of these methods:
View the Symbols window and look for a red error icon . When you hover your
cursor over the icon, you see
Parse a chart by selecting Chart > Parse Chart.
Start simulation by selecting Simulation > Run in the model window.
Update the model diagram by selecting Simulation > Update Diagram in the model window.
The parser behaves differently depending on how you set Parse custom code symbols in the Model Configuration Parameters dialog box, on the Simulation Target pane.
For C charts, if you select the Parse custom code symbols check box, the parser tries to find unresolved chart symbols in the custom code. If the custom code does not define these symbols, they are flagged in the Symbol Wizard. The Symbol Wizard suggests scopes for unresolved data and event symbols. This option is not available for charts that use MATLAB® as the action language.
If you do not select the Parse custom code symbols check box, the parser considers unresolved data symbols in the chart to be defined in the custom code. If the custom code does not define these symbols, an error does not appear until make time.
When you parse a chart, Stateflow® has access to all required information for detecting unresolved symbols, such as enumerated data types and exported graphical functions from other charts. However, there can be false alarms from data types inherited from Simulink.
When you edit charts, Stateflow detects symbols in your chart that you have not added as data, events, or messages. Undefined symbols are displayed in the Symbols window with a red error icon . When you select the error icon and choose Fix, Stateflow defines the symbol and infers a scope, type, size, and complexity. To resolve all the undefined symbols detected in the Symbols window, select the Resolve undefined symbols button,
When you parse a chart, the Symbol Wizard flags unresolved symbols in your chart. The Symbol Wizard infers the class and scope of unresolved data and events.
If the inferred scope is incorrect for any events or data, you can change the scope in the Symbol Wizard. You can also change the class of a symbol between data and event.
To accept, reject, or change the scope of a recommended item, perform one of these steps:
To accept an item, select the check box in front of the item.
To reject an item, clear the check box.
To change the class or scope, select a different value from the drop-down list under Class or Scope.
After you edit the symbol definitions, click OK to add the symbols to the Stateflow hierarchy.
Stateflow follows these rules for inferring the scope of unresolved data symbols.
|Unresolved Data Symbol||Inferred Scope|
|Written to and read from in the chart||Local|
|Read from but not written to in the chart||Input|
|Written to but not read from in the chart||Output|
|Contains all capital letters in the name and is only read from but not written to in the chart||Parameter|
Stateflow follows these rules for inferring the scope of unresolved event symbols.
|Unresolved Event Symbol||Inferred Scope|
|Appears only in triggers||Input|
|Appears only in ||Output|
|Appears in both triggers and ||Local|
When Stateflow flags unresolved data in your chart that uses MATLAB as the action language, the following properties are inferred along with the scope:
Size is –
Same as Simulink or
Inherit: From definition
in chart (for local data, and function inputs and outputs).