Main Content

getPrevious, prev

Previous value of data in Requirements Table block

Since R2022a

Description

z = getPrevious(u) returns the value of the data at the previous time step. This operator works only in the Requirements Table block.

z = prev(u) is an alternative way to execute getPrevious(u).

example

Input Arguments

expand all

Data, specified as data defined in the Requirements Table block. u must be input or output data. You must specify an initial value for u in the Property Inspector. For more information, see Define Data in Requirements Table Blocks.

Output Arguments

expand all

Value at the previous time step, returned as a value with the same data type of u.

Examples

expand all

At the start time, set y equal to 0. After the start time, recall the value of the input data u in the precondition at the previous time step. One requirement checks if the previous value of u is greater than or equal to the current value, and another checks if the previous value is less than the current value. The block assigns different values for the output data y.

This image shows a Requirements table that changes the output action depending on the previous value of the block input. If the block input previous value is greater than or equal to the current value, the block outputs 1. Otherwise, the block outputs 2. At the start time, the block outputs 0.

Tips

  • You can use this operator only in the Requirements tab.

Version History

Introduced in R2022a