hasChanged - Detect change in data since last time step in Stateflow

        chart - MATLAB ([original](https://www.mathworks.com/help/stateflow/ref/haschanged.html)) ([raw](?raw))

Detect change in data since last time step in Stateflow chart

Syntax

Description

`tf` = hasChanged(`data`) returns 1 (true) if the value ofdata at the beginning of the current time step is different from the value of data at the beginning of the last time step that the chart woke up. Otherwise, the operator returns 0 (false).

example

Examples

expand all

Transition out of state if any element of the matrix M has changed value since the last time step or input event.

Stateflow chart that uses the hasChanged operator in a transition.

Transition out of state if the element in row 1 and column 3 of the matrixM has changed value since the last time step or input event.

In charts that use MATLAB® as the action language, use:

Stateflow chart that uses the hasChanged operator in a transition.

In charts that use C as the action language, use:

Stateflow chart that uses the hasChanged operator in a transition.

Transition out of state if any field of the structurestruct has changed value since the last time step or input event.

Stateflow chart that uses the hasChanged operator in a transition.

Transition out of state if the field struct.field has changed value since the last time step or input event.

[hasChanged(struct.field)]

Stateflow chart that uses the hasChanged operator in a transition.

Input Arguments

expand all

Stateflow® data, specified as a:

If data is a matrix, the operator returns true when it detects a change in one of the elements of data. You can also index elements of a matrix by using numbers or expressions that evaluate to an integer. SeeOperations for Vectors and Matrices in Stateflow.

If data is a structure, the operator returns true when it detects a change in one of the fields of data. You can also index fields in a structure by using dot notation. See Index and Assign Values to Stateflow Structures.

The argument data cannot be a nontrivial expression or a custom code variable.

Standalone charts in MATLAB do not support change detection on an element of a matrix or a field in a structure.

Limitations

Tips

Version History

Introduced in R2007a