You can create a custom method in MATLAB that uses persistent variables to store the previous value of the variable being checked.
Here's an example:
main.m363 chars13 lines
The persistent
keyword declares that storedValue
is a variable that keeps its value between different calls of the function.
To use this function, just call it with the variable you want to check:
main.m145 chars6 lines
Note that the isequal
function is used to test for equality between the currentValue
and storedValue
variables, so any change in the variable will trigger the isChanged
output to be true
. You can modify this comparison to fit your specific needs.
gistlibby LogSnag