Main Content

hasChanged

Detect data change in test step

Description

tf = hasChanged(u) returns 1 (true) if the value of u at the beginning of the current time step is different from the value of u at the beginning of the previous time step. Otherwise, the operator returns 0 (false).

example

Examples

expand all

Detect if x has changed value. This statement returns true if x has changed.

hasChanged(x)

For a bus with two signals, signal_1 and signal_2, and data as the name of the input to the test sequence, detect when the value of signal_2 has changed.

hasChanged(data.signal2)

Tips

hasChanged statements can be used in the Test Sequence and Test Assessment blocks and in Stateflow® charts.

Version History

Introduced in R2015a