Main Content

Describe System Behavior Using Activity Diagrams

An activity diagram is the primary diagram to describe an activity. An activity describes system behavior that models the flow of tokens from inputs to outputs through a controlled sequence of actions. An activity diagram contains action nodes with pins connected by flow lines. Activity diagrams represent the flow of tokens through various actions that describe the execution of activities.

Actions are the building blocks of activities and describe what happens when activities execute. Each action can accept inputs and produce outputs, called tokens.

Use activity diagrams to conceptualize a system, visualize functional flow through actions or decisions, and understand how system components interact with one another. You can use activity diagrams to describe the behavior of systems as a transformation of inputs to outputs through actions that process token flows.

You can allocate activity diagram elements to elements of a System Composer™ architecture model using the Allocation Editor to more fully describe your functional architectural design. For more information, see Design Architectures and Activity Diagram for Mobile Robot.

Concepts Activity Diagram

These concepts are relevant for authoring activity diagrams:

  • Tokens are objects that flow in the activity diagram. A token can represent data such as structures and integers, or simply pass on the control.

    Use a token to move data or control across the activity diagram. These are the types of tokens:

    • Object token — Represents an object such as a piece of data.

    • Control token — Represents a control or a triggering event that does not carry any data.

  • A flow in an activity diagram connects two nodes. A dashed line represents a control flow and a solid line represents an object flow.

    You can use object flows to route input or output tokens to carry information or physical items between object nodes. You can use control flows to model transfer of control from one Action Node to another. These are the types of flows:

    • Object flow — Tokens in an object flow contains token data on which actions operate.

    • Control flow — Tokens in a control flow trigger the execution of actions.

  • An action node is a key building block in an activity diagram. An action node represents an action to be executed. Action nodes consume input tokens and produce output tokens on pins.

    Use a MATLAB® function or a nested activity diagram to describe the behavior of an action node.

  • A control node routes a logical flow of tokens through the system.

    Use control nodes and flows to route tokens. Control nodes can be used to initialize, split, merge, and terminate token flows.

    These are the various types of control nodes in an activity:

    • Initial Node — Dispatches a control token at the beginning of an activity.

    • Decision or Merge Node — A decision node routes an input token to an output flow based on the evaluation of guard expressions. A merge node routes tokens from multiple input flows to a single output flow. A merge decision node routes tokens from multiple input flows to certain output flows based on the evaluation of guard expressions.

    • Join or Fork Node — A join node consolidates multiple input tokens to one output flow given that a token is available at each input pin. A fork node replicates one input token on each output flow.

    • Flow Final Node — Terminates one object or control flow but not the entire activity.

    • Activity Final Node — Terminates the incoming token and the entire activity.

  • A pin directs tokens in or out of an action node. The directionality of the pin represents input or output. You can connect pins by object flows.

    Use pins to route an object token to or from an Action Node. Pins are also used to store object tokens before or during execution. You can use pins only for object flows.

Create New Activity Diagram

Create an activity diagram by launching the System Composer Start Page. Enter in the MATLAB Command Window:


From the following dialog box, select Activity Diagram.

Activity Diagram from Simulink Start menu

Alternatively, you can use the systemcomposer.createActivity function to create a new activity diagram.

Authoring, Simulating, and Visualizing Activity Diagrams

Activity diagrams are integrated with architecture models in System Composer. While designing a system, you can use an activity diagram to conceptualize a system, and visualize the flow of actions or decisions. Activity diagrams help you to understand how each element of your system interacts with each other. In System Composer, you can also simulate and visualize activity diagrams to validate system behavior.

Author Activity DiagramsInteractively create and edit an activity diagram and learn terminology.
Simulate, Visualize, and Validate Activity DiagramsSimulate and visualize an activity diagram to validate system behavior.

See Also




Related Topics