hasChangedFrom - Detect change in data from specified value in Stateflow

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

Detect change in data from specified value in Stateflow chart

Syntax

Description

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

example

Examples

expand all

Transition out of state if the previous value of the matrixM was equal to matrixValue and any element of M has changed value since the last time step or input event.

[hasChangedFrom(M,matrixValue)]

Stateflow chart that uses the hasChangedFrom operator in a transition.

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

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

[hasChangedFrom(M(1,3),7)]

Stateflow chart that uses the hasChangedFrom operator in a transition.

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

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

Stateflow chart that uses the hasChangedFrom operator in a transition.

Transition out of state if the previous value of the structurestruct was equal to structValue and any field of struct has changed value since the last time step or input event.

[hasChangedFrom(struct,structValue)]

Stateflow chart that uses the hasChangedFrom operator in a transition.

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

[hasChangedFrom(struct.field,5)]

Stateflow chart that uses the hasChangedFrom 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 previous 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