Products & Services Solutions Academia Support User Community Company

Learn more about Stateflow   

Using the Model Explorer with Stateflow Objects

Viewing Stateflow Objects in the Model Explorer

Depending on what you edit, you can use one of these methods for opening the Model Explorer:

The Model Explorer appears something like this:

The main window has two panes: a Model Hierarchy pane on the left and a Contents pane on the right. When you open the Model Explorer, the Stateflow object you are editing appears highlighted in the Model Hierarchy pane and its objects appear in the Contents pane. This example shows how the Model Explorer appears when you open from the Truth Table Editor for the truth table tt_func in the chart myChart.

The Model Hierarchy pane displays the elements of all loaded Simulink models, which includes Stateflow charts. A preceding plus (+) character for an object indicates that you can expand the display of its child objects by double-clicking the entry or by clicking the plus (+). A preceding minus (-) character for an object indicates that it has no child objects.

Clicking an entry in the Model Hierarchy pane selects that entry and displays its child objects in the Contents pane. A hypertext link to the currently selected object in the Model Hierarchy pane appears after the Contents of: label at the top of the Contents pane. Click this link to display that object in its native editor. In the preceding example, clicking the link

model_explorer_example/myChart/tt_func

displays the truth table tt_func in the Truth Table Editor.

By default, the Model Explorer displays event and data child objects in the Contents pane for the selected object in the Model Hierarchy pane. To display additional or different child Stateflow objects in the Contents pane:

  1. From the Model Explorer, select View > List View Options.

  2. In the submenu, select any or all of the following individual options: States/Functions/Boxes/Etc., Transitions, Junctions, Events, or Data.

    To display all of the preceding Stateflow child objects, select All Stateflow Objects.

Each type of object, whether in the Model Hierarchy or Contents pane, appears with an adjacent icon. Subcharted objects (states, boxes, or graphical functions) appear altered with shading.

Object

Icon

Icon for Subcharted Object

Chart

Not applicable

State

Box

Graphical function

Truth table function

Not applicable

Embedded MATLAB function

Not applicable

Simulink function

Not applicable

Data

Not applicable

Event

Not applicable

Target

Not applicable

The display of child objects in the Contents pane includes properties for each object, most of which are directly editable. You can also access the properties dialog box for an object from the Model Explorer. See Setting Properties for Stateflow Objects in the Model Explorer for more details.

Editing States or Charts in the Model Explorer

To edit a state or chart that appears in the Model Hierarchy pane of the Model Explorer:

  1. Right-click the object.

  2. Select Open from the menu.

    The selected object appears highlighted in the Stateflow Editor in the context of its parent.

Adding Data and Events in the Model Explorer

States, boxes, and functions can parent data and events. To add data or events to a Stateflow object:

  1. In the Model Hierarchy pane of the Model Explorer, select a state, box, or function.

  2. From the Add menu, select Data or Event.

    A new data or event appears in the Contents pane with the default name data or event. If you continue adding more data, each new data or event is named with an integer suffix (data1, event1, data2, event2, and so on).

    You can change the properties for data or events directly in the Model Explorer. You can also access the complete list of properties for data or events from the Model Explorer. See Setting Properties for Stateflow Objects in the Model Explorer.

For more detailed examples of creating data and events in the Model Explorer, see Adding Events Using the Model Explorer and Adding Data Using the Model Explorer.

Adding Custom Targets in the Model Explorer

Custom targets belong to a Simulink model, not a chart. In the Model Explorer, you can add custom targets to a model as follows:

  1. In the Model Explorer, in the left Model Hierarchy pane, select the Simulink model to receive the custom target.

  2. In the Model Explorer, select Add > Stateflow Target.

    The Contents pane of the Model Explorer displays the new custom target with the default name untitled.

  3. In the Contents pane, right-click the row of the custom target and select Properties from the context menu.

    The Stateflow Custom Target dialog box appears.

  4. Enter the name of the custom target.

    You can use any string except the reserved names sfun and rtw.

  5. Specify other properties in the dialog box.

  6. Click Apply.

For more information, see How to Build a Stateflow Custom Target.

Renaming Objects in the Model Explorer

To rename a Stateflow object in the Model Explorer:

  1. Right-click the object row in the Contents pane of the Model Explorer and select Rename.

    The name of the selected object appears in a text edit box.

  2. Change the name of the object and click outside the edit box.

Setting Properties for Stateflow Objects in the Model Explorer

To change the property of an object in the Contents pane of the Model Explorer:

  1. In the Contents pane, click in the row of the displayed object.

  2. Click an individual entry for a property column in the highlighted row.

    • For text properties, such as the Name property, a text editing field with the current text value overlays the displayed value. Edit the field and press the Return key or click anywhere outside the edit field to apply the changes.

    • For properties with enumerated entries, such as the Scope, Trigger, or Type properties, select from a drop-down combo box that overlays the displayed value.

    • For Boolean properties (properties that are set on or off), select or clear the box that appears in place of the displayed value.

To set all the properties for an object displayed in the Model Hierarchy or Contents pane of the Model Explorer:

  1. Right-click the object and select Properties.

    The properties dialog box for the object appears.

  2. Edit the appropriate properties and click Apply or OK.

To display the property dialog box dynamically for the selected object in the Model Hierarchy or Contents pane of the Model Explorer:

  1. Select View > Dialog View.

    The property dialog box for the selected object appears in the far right pane of the Model Explorer.

Moving and Copying Data, Events, and Targets in the Model Explorer

You can move data, event, or target objects to another parent:

  1. Select the data, event, or target to move in the Contents pane of the Model Explorer.

    You can select a contiguous block of items by highlighting the first (or last) item in the block and then using Shift+click for highlighting the last (or first) item.

  2. Click and drag the highlighted objects from the Contents pane to a new location in the Model Hierarchy pane to change its parent.

    A shadow copy of the selected objects accompanies the mouse cursor during dragging. If no parent is chosen or the parent chosen is the current parent, the mouse cursor changes to an X enclosed in a circle, indicating an invalid choice.

You can also cut or copy the selected data, events, and targets:

  1. Select the event, data, and targets to move in the Contents pane of the Model Explorer.

  2. In the Model Explorer, select Edit > Cut or Edit > Copy.

    If you select Cut, the selected items are deleted and then copied to the clipboard for copying elsewhere. If you select Copy, the selected items are left unchanged.

    You can also right-click a single selection and select Cut or Copy from the context menu. The Model Explorer also uses the keyboard equivalents of Ctrl+X (Cut) and Ctrl+C (Copy) on a computer running the UNIX or Windows operating system.

  3. Select a new parent object in the Model Hierarchy pane of the Model Explorer.

  4. Select Edit > Paste. The cut items appear in the Contents pane of the Model Explorer.

    You can also paste the cut items by right-clicking an empty part of the Contents pane and selecting Paste from the context menu. The Model Explorer also uses the keyboard equivalent of Ctrl+V (Paste) on a computer running the UNIX or Windows operating system.

Changing the Port Order of Input and Output Data and Events

Input data, output data, input events, and output events each have numerical sequences of port index numbers. You can change the order of indexing for event or data objects with a scope of Input to Simulink or Output to Simulink in the Contents pane of the Model Explorer as follows:

  1. Select one of the input or output data or event objects.

  2. Click the Port property for the object.

  3. Enter a new value for the Port property for the object.

    The remaining objects in the affected sequence are automatically assigned a new value for their Port property.

Deleting Data, Events, and Targets in the Model Explorer

Delete data, event, and target objects in the Contents pane of the Model Explorer as follows:

  1. Select the object.

  2. Press the Delete key.

    You can also select Edit > Cut or Ctrl+X from the keyboard to delete an object.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS