MATLAB: How to to locate all Stateflow 8.0 (R2012b) transitions with disconnected endpoints in a model

disconnectstateflowunconnect

I want to find all transitions in my model's Stateflow charts with endpoints that are not connected to anything. How can I do this?

Best Answer

This can be done using the Stateflow API:
rt = sfroot;
modelHandle = rt.find('-isa','Simulink.BlockDiagram','$MODELNAME');
disconnectedTransitions = modelHandle.find('-isa','Stateflow.Transition','-and','Destination',[]);
The variable disconnectedTransitions will be an array of Stateflow.Transition objects that are not connected to a destination object. These transitions should come from any Stateflow chart within the model. $MODELNAME in the above code should be replaced with the name the model containing the charts/transitions. The VIEW method of the Stateflow.Transition object can be used to view the location of specific transitions.