Hi Michael,
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:
function counter=Counter(reset)
persistent value
if isempty(value) || reset == 1
value = -1;
end
value = value + 1;
counter = value;
end
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.
Cheers!
Duncan
Hi Duncan,
When I right click the MATLAB function block, properties, there are general, block annotation and callbacks. There is no option to set the update rate
Please login or Register to submit your answer