hasChangedTo - Detect change in data to specified value in Stateflow

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

Detect change in data to specified value in Stateflow chart

Syntax

Description

`tf` = hasChangedTo(`data`,`value`) returns 1 (true) if the value ofdata is not equal to value at the beginning of the previous time step and is equal to value at the beginning of the current time step. Otherwise, the operator returns0 (false).

example

Examples

expand all

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

[hasChangedTo(M,matrixValue)]

Stateflow chart that uses the hasChangedTo operator in a transition.

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

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

Stateflow chart that uses the hasChangedTo operator in a transition.

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

[hasChangedTo(M[0][2],7)]

Stateflow chart that uses the hasChangedTo 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 and the current value of struct is equal tostructValue.

[hasChangedTo(struct,structValue)]

Stateflow chart that uses the hasChangedTo operator in a transition.

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

[hasChangedTo(struct.field,5)]

Stateflow chart that uses the hasChangedTo 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.

Value of the data at the current time step, specified as the same data type of data. value must be an expression that resolves to a value that is comparable with data:

Limitations

Tips

Version History

Introduced in R2007a