| Stateflow User's Guide | ![]() |
Inheriting Input and Output Data Type from Simulink
You can tell the Stateflow chart to inherit the type of input data and output data from Simulink by selecting Inherited in the Type field for that data. This is the default setting for input and output data that you add to the Stateflow chart. Once you connect Simulink signals to the ports for input and output data and build the model, the CompiledType column of the Model Explorer gives the actual type inherited.
In the following example, a Stateflow diagram inherits an input signal from a Constant block of type int16, multiplies it by the numerical constant 2, and assigns the result to the output.
Inheriting the type of input data is successful in all cases. According to the CompiledType field in the preceding example, the Stateflow diagram inherits the input type correctly at int16.
The inherited type of output data is inferred from diagram actions that store values in the specified output. Because numerical constants in Stateflow are of type double, the inherited output type in the example is double. If the expected output type in Simulink matches the inferred type, inheritance is successful. In all other cases, a mismatch error occurs during build time.
| Selecting Stateflow Data Types | Typing Data by Using the Type of Other Data | ![]() |
© 1994-2005 The MathWorks, Inc.