hasChangedTo
Detect change in data to specified value in Stateflow chart
Description
returns tf = hasChangedTo(data,value)1 (true) if the value of
data 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 returns
0 (false).
Examples
Input Arguments
Limitations
Unable to be used within a Stateflow truth table.
Tips
If multiple input events occur in the same time step, the
hasChangedTooperator can detect changes in data value between input events.If the chart writes to the data object but does not change the data value, the
hasChangedTooperator returnsfalse.The type of Stateflow chart determines the scope of the data supported by the change detection operators:
Standalone Stateflow charts in MATLAB:
LocalonlyIn Simulink® models, charts that use MATLAB as the action language:
InputonlyIn Simulink models, charts that use C as the action language:
Input,Output,Local, orData Store Memory
In a standalone chart in MATLAB, a change detection operator can detect changes in data specified in a call to the
stepfunction because these changes occur before the start of the current time step. For example, ifxis equal to zero, the expressionhasChangedTo(x,1)returnstruewhen you execute the chartchwith the command:In contrast, a change detection operator cannot detect changes in data caused by assignments in state or transition actions in the same time step. Instead, the operator detects the change in value at the start of the next time step.step(ch,x=1);
In a chart in a Simulink model, if you enable the chart option Initialize Outputs Every Time Chart Wakes Up, using an output as the argument of the
hasChangedoperator always returnsfalse. For more information, see Initialize outputs every time chart wakes up.When row-major array layout is enabled in charts that use
hasChangedTo, code generation produces an error. Before generating code in charts that usehasChangedTo, enable column-major array layout. See Select Array Layout for Matrices in Generated Code.
Version History
Introduced in R2007a




