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.

open_system('CFunctionPersistentExample');

An initial value, specified as a parameter, is cached in the block as persistent data in theStart Codepane.

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

TheSymbolstable defines the attributes of the symbols used in the code. Note that the scope of theinitialValuesymbol is specified asParameter, so its value can be changed using the block dialog. The state is defined as havingPersistentscope. This value changes at each time step.

See Also

Objects

Blocks