Real-Time Workshop    

Symbolic Names for Block States

To determine the variable or field name generated for a block's state, you can either:

or

Default Block State Naming Convention

If you do not define a symbolic name for a block state, Real-Time Workshop uses the following default naming convention:

where

For example, consider the model shown in Figure 5-15.

Figure 5-15: Model with Two Discrete Filter Block States

We will examine code generated for the states of the two Discrete Filter blocks. Assume that:

The initialization code for the states of the two Discrete Filter blocks would be as shown in the following code fragment.

User-Defined Block State Names

Using the State Properties dialog box, you can define your own symbolic name for a block state. To do this:

  1. Select the desired block. Then select State properties from the Edit menu of your model. This opens the State Properties dialog box.
  1. Alternatively, you can right-click on the block, and select State properties from the pull-down menu.

  1. Enter the symbolic name into the State name field of the State Properties dialog box. In this picture, the state name Top_filter is entered.

  1. Click Apply and close the dialog box.

The following state initialization code was generated from the example model shown in Figure 5-7, under the following conditions:


  Using the State Properties Dialog Box to Interface States to External Code Block States and Simulink Signal Objects