Main Content

Stateflow Programmatic Interface

Create and modify chart elements at the MATLAB® command prompt

Programmatically create and edit Stateflow® charts. Add new objects to your chart, access and edit properties, set positions, copy and paste objects, and change the magnification level of the Stateflow Editor.

Functions

expand all

sfnewCreate Simulink model that contains an empty Stateflow block
sfrootRoot of Stateflow hierarchy
sfclipboardClipboard object
sfgcoSelected objects in chart

Objects

expand all

Chart, Block, and Machine Objects

Stateflow.ChartGraphical representation of a finite state machine
Stateflow.StateTransitionTableChartTabular representation of state machine for modal logic
Stateflow.TruthTableChartTabular representation of state machine for decision logic
Stateflow.EMChartStateflow interface to MATLAB Function block
Stateflow.MachineContainer for Stateflow blocks in a Simulink model

Graphical Objects

Stateflow.AnnotationAnnotation in chart, state, box, or function
Stateflow.AtomicBoxAtomic box in chart, state, box, or function
Stateflow.AtomicSubchartAtomic subchart in chart, state, or box
Stateflow.BoxBox in chart, state, box, or function
Stateflow.EMFunctionMATLAB function in chart, state, box, or function
Stateflow.FunctionGraphical function in chart, state, box, or function
Stateflow.JunctionJunction in chart, state, box, or function
Stateflow.SimulinkBasedStateSimulink based state in chart, state, or box
Stateflow.SLFunctionSimulink function in chart, state, box, or function
Stateflow.StateState in chart, state, or box
Stateflow.TransitionTransition in chart, state, box, or function
Stateflow.TruthTableTruth table function in chart, state, box, or function

Nongraphical Objects

Stateflow.DataData in chart, state, box, or function
Stateflow.EventEvent in chart, state, or box
Stateflow.MessageMessage in chart, state, or box

Clipboard and Editor Objects

Stateflow.ClipboardClipboard to copy and paste Stateflow objects
Stateflow.EditorGraphical aspects of a chart or state transition table

Object Functions

expand all

Object Hierarchy Operations

findSpecified objects in hierarchy
upReturn parent of object
defaultTransitionsReturn default transitions in object at top level of containment
innerTransitionsReturn inner transitions that originate with chart or state and terminate on contained object
outerTransitionsReturn array of outer transitions for object
sinkedTransitionsReturn transitions that have object as destination
sourcedTransitionsReturn transitions that have object as source

Property Operations

getReturn MATLAB structure containing property settings of object or array of objects
setSet properties with specified values
dialogOpen properties dialog box
classhandleProvide class handle for object

Display Operations

viewDisplay object in editing environment
highlightHighlight graphical object
fitToViewZoom in on graphical object
zoomInZoom in on Stateflow chart
zoomOutZoom out on Stateflow chart
setImageInsert image into annotation

Clipboard Operations

copyCopy array of objects to clipboard
pasteToPaste objects in clipboard to specified container object

Debugging Operations

isCommentedDetermine if object is commented out
parseParse single chart or all charts in model

Topics

Overview of the Stateflow API

Create and edit Stateflow charts by using MATLAB commands.

Create and Delete Stateflow Objects

Design your Stateflow chart by adding and deleting objects.

Access Objects in Your Stateflow Chart

Locate objects contained in your Stateflow chart.

Modify Properties and Call Functions of Stateflow Objects

Manipulate Stateflow objects by modifying properties and calling functions.

Specify Labels in States and Transitions Programmatically

Add labels with one or more lines of text to states and transitions.

Featured Examples