MATLAB: Do I receive an internal error when running the chart in Stateflow 5.1.1 (R13SP1)

errorfunctiongraphicalinternalr12.1pv1_swatstateflow

When I run the model with my chart, I receive the following error:
Stateflow Runtime Error: INTERNAL ERROR. Failed assertion in sfc_tm.c at line 144:
thisTraceNode->objectNumber==objectNumber
Function doIt (#126)
While executing: none
Note that doIt is a graphical function.

Best Answer

This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
This has been verified as a bug in Stateflow 5.1.1 (R13SP1). This problem occurs because of two transition guard statements in the main chart that each contain a function call to a graphical function. When 'Transition Conflict' detection is enabled in the debugger, Stateflow does multiple tests on each transition to detect inconsistencies in the guard conditions. Complimentary guard conditions with function calls in them can cause an internal problem in Stateflow.
There are two workarounds to this problem. The first is to disable the 'Transition Conflict' checkbox in the Stateflow debugging window. This causes some decrease in debugging capability, but will apply to all instances of this problem.
The second workaround is to only execute the function once, and place the result in a temporary data variable. The variable can then be tested for multiple conditions.