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

sfgcoRecently selected 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

defaultTransitionsReturn default transitions in object at top level of containment
dispDisplay properties and settings for object
findReturn specified objects
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
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.AnnotationConstructor for creating note
Stateflow.AtomicBoxConstructor for creating atomic box
Stateflow.AtomicSubchartConstructor for creating atomic subchart
Stateflow.BoxConstructor for creating box
Stateflow.DataConstructor for creating data
Stateflow.EMFunctionConstructor for creating MATLAB function
Stateflow.EventConstructor for creating event
Stateflow.FunctionConstructor for creating graphical function
Stateflow.JunctionConstructor for creating junction
Stateflow.MessageConstructor for creating message
Stateflow.SimulinkBasedStateConstructor for creating a Simulink based state
Stateflow.SLFunctionConstructor for creating Simulink function
Stateflow.StateConstructor for creating state
Stateflow.TransitionConstructor for creating transition
Stateflow.TruthTableConstructor for creating truth table
dialogOpen properties dialog box of object
fitToViewZoom in on graphical Stateflow object
highlightHighlight graphical object in chart
viewMake object visible for editing
zoomIn and zoomOutZoom in or out on Stateflow chart
classhandleProvide handle to schema class of object type
isCommentedDetermine if object is commented out
outputDataCreate, retrieve, or delete data output to Simulink base workspace of state activity status
parseParse single chart or all charts in model
upReturn parent of object


Overview of the Stateflow API

Create and edit Stateflow charts by using MATLAB commands.

Access Properties and Methods of Stateflow Objects

Use dot notation to refer to API properties and methods.

Create and Destroy Stateflow Objects

Add and delete Stateflow objects to your chart.

Access Existing Stateflow Objects

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.

Enter Multiline Labels in States and Transitions

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