The moving target sample was really just intended as an example - the use of the counter in this case was a convenience.
You could make your own counter with a bit of embedded MATLAB. Something like this should work:
if isempty(value) || reset == 1
value = -1;
value = value + 1;
counter = value;
In your Stateflow you would need to send the "reset" input on this code to 1 briefly at the start of each trial.
This counter would run at the default speed of the model. i.e. 2 or 4 kHz. If you want the counter to run at 1 kHz then you would need to right click on the MATLAB block, get properties, and explicitly set the update rate to 0.001 (i.e. 1 ms).
There are many other ways to solve this problem, it just depends on the specifics of what you want to do.
Please login or Register to submit your answer