Main Content

Author and Simulate Basic Colors Sequence Diagram with Enumerations

This example shows how to author and simulate a sequence diagram containing a variable of datatype Simulink.IntEnumType.

Define BasicColors.m Enumeration

Create an enumeration class called BasicColors and define Red(0), Yellow(1), and Blue(2) as the enumerated values.

classdef BasicColors < Simulink.IntEnumType
  enumeration
    Red(0)
    Yellow(1)
    Blue(2)
  end

Open Enumeration Example Model

Open the EnumExample.slx architecture model that contains a sequence diagram that implements the BasicColors enumeration.

model = systemcomposer.openModel("EnumExample");

Simple enumeration example model.

Double-click the source component to inspect the Stateflow® Chart (Stateflow) block.

Stateflow Chart block in Simulink behavior in architectural diagram.

The output data port, data, is typed by the BasicColors enumeration in this state chart where the color changes from Red to Yellow as the model simulates.

Open Enumeration Sequence Diagram

Navigate to Modeling > Sequence Diagram to open the Architecture Views Gallery and access the EnumSequenceDiagram sequence diagram. Click Run to simulate the sequence diagram.

Sequence diagram after execution.

As the inEnum destination port inherits a value of 1 from the BasicColors enumeration, indicating a change from Red (0) to Yellow (1), the sequence diagram executes successfully.

See Also

Tools

Functions

Objects

Related Topics