Define Temporary Data

When to Define Temporary Data

In C charts, define temporary data when you want to use data that is only valid while a function executes. In charts that use MATLAB® as the action language, you do not need to define temporary function data in the Model Explorer. If a variable is used and not previously defined, then it is automatically created. The variable is available to the rest of the function.

You can define temporary data in graphical, truth table, and MATLAB functions in your chart. For example, you can designate a loop counter to have Temporary scope if the counter value does not need to persist after the function completes.

How to Define Temporary Data

To define temporary data for a Stateflow® function, follow these steps:

  1. Open the Model Explorer.

  2. In the Model Explorer, select the graphical, truth table, or MATLAB function that will use temporary data.

  3. Select Add > Data.

    The Model Explorer adds a default definition for the data in the Stateflow hierarchy, with a scope set to Temporary by default.

  4. Change other properties of the data if necessary, as described in Set Data Properties.

Was this topic helpful?