Stateflow Programmatic Interface

Create and modify chart elements at the MATLAB® command prompt

Programmatically create, edit, and simulate your Stateflow® charts by using MATLAB commands. Access and edit the properties and methods, set positions, or copy and paste objects in your chart. Edit graphical properties by accessing the editor object.


expand all

sfgcoSelected objects in chart
sfclipboardStateflow clipboard object
sfcloseClose chart
sfnewCreate Simulink model that contains an empty Stateflow block
sfopenOpen existing model
sfprintPrint graphical view of charts
sfrootRoot object
sfsaveSave chart in current folder
sfhelpOpen Stateflow online help
sflibOpen Stateflow library window
stateflowOpen Stateflow library window and create Simulink model that contains an empty chart
sfdebuggerOpen Stateflow Debugger
sfexplrOpen Model Explorer


expand all

classhandleProvide handle to schema class of object type
defaultTransitionsReturn default transitions in object at top level of containment
dispDisplay properties and settings for object
findSpecified objects in hierarchy
getReturn MATLAB structure containing property settings of object or array of objects
helpDisplay list of properties for object with accompanying descriptions
innerTransitionsReturn inner transitions that originate with chart or state and terminate on contained object
methodsList methods belonging to object
outerTransitionsReturn array of outer transitions for object
setSet properties with specified values
sinkedTransitionsReturn transitions that have object as destination
sourcedTransitionsReturn transitions that have object as source
structReturn MATLAB structure containing property settings of object
upReturn parent of object
copyCopy specified array of objects to clipboard
deleteDelete object
pasteToPaste objects in clipboard to specified container object
setImageInsert image from clipboard or image file into an annotation
Stateflow.AnnotationCreate annotation
Stateflow.AtomicBox Create atomic box
Stateflow.AtomicSubchartCreate atomic subchart
Stateflow.BoxCreate box
Stateflow.DataCreate data
Stateflow.EMFunctionCreate MATLAB function
Stateflow.EventCreate event
Stateflow.FunctionCreate graphical function
Stateflow.JunctionCreate junction
Stateflow.MessageCreate message
Stateflow.SimulinkBasedStateCreate Simulink based state
Stateflow.SLFunctionCreate Simulink function
Stateflow.StateCreate state
Stateflow.TransitionCreate transition
Stateflow.TruthTableCreate truth table function
isCommentedDetermine if object is commented out
parseParse single chart or all charts in model
dialogOpen properties dialog box of object
fitToViewZoom in on graphical Stateflow object
highlightHighlight graphical object in chart
viewMake object visible for editing
zoomIn, zoomOutZoom in or out on Stateflow chart


Overview of the Stateflow API

Create and edit Stateflow charts by using MATLAB commands.

Create and Destroy Stateflow Objects

Add and delete Stateflow objects to your chart.

Access Objects in Your Stateflow Chart

Create handles to manipulate Stateflow objects in your chart.

Copy and Paste Stateflow Objects

Access the clipboard object to duplicate Stateflow objects.

View Stateflow Graphical Objects

Use the fitToView method to zoom in on an object in your chart.

Move Stateflow Graphical Objects

Programmatically reposition states and subcharts.

Modify the Graphical Properties of Your Chart

Access the Editor object to perform graphical operations on a chart.

Create Default Transition Objects

Indicate which substate becomes active during state initialization.

Create Supertransition Objects

Connect transitions between different levels in a chart.

Specify Labels in States and Transitions Programmatically

Specify more than one line of text in your state and transition labels.

Featured Examples