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.
To define temporary data for a Stateflow® function, follow these steps:
Open the Model Explorer.
In the Model Explorer, select the graphical, truth table, or MATLAB function that will use temporary data.
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.
Change other properties of the data if necessary, as described in Set Data Properties.