A few years ago I asked this question about timers. I took Walter's answer as gospel and didn't bother testing it since the potential for timers to operate in a different thread made them unsuitable for my application. Per has a recent question on timers where the problem has come up again.
But in the case of a block of code:
a timer shot can occur after the first statement and change "x".
But if I run (note you may have to adjust the number of iterations to give a reasonable run time)
h = timer('TimerFcn', @(src, evt)toc, 'ExecutionMode', 'FixedRate');
for ii = 1:5e2
x = randn(1000000, 1);
y = x(1:500000);
y = [y x(500001:1000000)];
Elapsed time is 0.001405 seconds.
Elapsed time is 1.001806 seconds.
Elapsed time is 2.002036 seconds.
Elapsed time is 16.791777 seconds.
Elapsed time is 17.001169 seconds.
Elapsed time is 18.001609 seconds.
The timer appears to fire immediately after starting (as you would expect), and twice more during the pause before the loop starts (again as expected). There is then a 14.8 second gap (about the amount of time the loop takes in the absence of the timer) followed by 3 more timer events (again expected given the 2 second pause).
What am I missing? I am using R2011a, did something change in the 16 months following the release of the tech report. Is there new documentation.