Main Content

Modify States of a C Function Block Using Persistent Symbols

This example shows a unit delay system where a C Function block takes in a sine wave signal and delays its output by a specified sample period.


An initial value, specified as a parameter, is cached in the block as persistent data in the Start Code pane.

In the Output Code pane, a calculation is done on this state. A new input is passed to the block as the next state at the next time step.

The Symbols table defines the attributes of the symbols used in the code. Note that the scope of the initialValue symbol is specified as Parameter, so its value can be changed using the block dialog. The state is defined as having Persistent scope. This value changes at each time step.

See Also