| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Stateflow |
| Contents | Index |
| Learn more about Stateflow |
| On this page… |
|---|
Error messages appear in a dialog box and in the MATLAB Command Window. Double-clicking a message in the error dialog box zooms the source Stateflow chart to the object that caused the error.
The Stateflow parser flags syntax errors in a chart. For example, using a backward slash (\) instead of a forward slash (/) to separate the transition action from the condition action generates a general parse error message.
Typical parse error messages include:
"Invalid state name xxx" or "Invalid event name yyy" or "Invalid data name zzz"
A state, data, or event name contains a nonalphanumeric character other than underscore.
"State name xxx is not unique in objects #yyy and #zzz"
Two or more states at the same hierarchy level have the same name.
"Invalid transition out of AND state xxx (#yy)"
A transition originates from an AND (parallel) state.
"Invalid intersection between states xxx and yyy"
Neighboring state borders intersect. If the intersection is not apparent, consider the state to be a cornered rectangle instead of a rounded rectangle.
"Junction #x is sourcing more than one unconditional transition"
More than one unconditional transition originates from a connective junction.
"Multiple history junctions in the same state #xxx"
A state contains more than one history junction.
Typical code generation error messages include:
"Failed to create file: modelName_sfun.c"
Code generation software does not have permission to generate files in the current folder.
"Another unconditional transition of higher priority shadows transition #xx"
More than one unconditional inner, default, or outer transition originates from the same source.
"Default transition cannot end on a state that is not a substate of the originating state."
A transition path starting from a default transition segment in one state completes at a destination state that is not a substate of the original state.
"Input data xxx on left hand side of an expression in yyy"
A Stateflow expression assigns a value to an Input from Simulink data object. By definition, a Stateflow expression cannot change the value of a Simulink input.
"Transition <number> has a condition action which is preceded by a transition <number> containing a transition action. This is not allowed as it results in out-of-order execution, i.e., the condition action of <number> gets executed before the transition action of <number>."

The preceding Stateflow chart flags this error. Assuming that there are no other actions than those you indicate for the labeled transition segments between state A and state B, the following pseudocode expresses the sequence of execution that takes place when state A is active:
If (c1) {
if(c2) {
a2;
exit A;
a1;
enter B;
}
}
Because condition actions evaluate when their guarding condition is true and transition actions evaluate when the transition is actually taken, condition action a2 executes prior to transition action a1. This action violates the apparent graphical sequence of executing a1 and then a2. In this case, the preceding chart flags the error during build time. To fix this problem, you can change a1 and a2 to be both condition or transition actions.
If compilation errors indicate undeclared identifiers, verify that variable expressions in state, condition, and transition actions are defined.
Consider, for example, an action language expression such as a=b+c. In addition to entering this expression in the Stateflow chart, you must create data objects for a, b, and c using the Model Explorer. If you do not define the data objects, the parser assumes that these unknown variables appear in the Custom code portion of the target, at the beginning of the generated code. Because of this assumption, error messages appear at compile time and not at code generation time.
![]() | Resolving Event, Data, and Function Symbols in Stateflow Action Language | Generated Code Files for Targets You Build | ![]() |

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 |