Re: Pause in a while loop
- From: Peter Boettcher <boettcher@xxxxxxxxxx>
- Date: Thu, 06 Jul 2006 09:30:39 -0400
"Nelson WONG" <nelson_wph@xxxxxxxxxxxxxxxxxxxxx> writes:
I have some difficulty in using the pause command inside a while
loop.
It is a kind of hearing test m-file program. The while loop inside
consists of a custom-made function to play a sound, like, wavplay,
sound, and a plot command to update the hearing response on the
figure. After these 2 parts, I have added a pause command , so that I
can catch any repsonse from the subject in the form of the
WindowButtonUpFcn / DownFcn.
However, if the iteration of this while loop goes for more than 300
or more, it will gradually slow, and when I tried to use tic toc to
measure the time taken for each parts.
pause_time = 0.018
tic;
pause(pause_time);
disp('*** 3. Time taken for the Pause ***');
toc;
i found that the pause time keep increasing from 0.018 second to
nearly 7 seconds at the end (i have kept this constant in the while
loop).
pause() also causes MATLAB to flush the graphics queue and update the
plot. Graphics commands do not immediately draw to the screen (this
limits flickering and makes the graphics more efficient), but wait
until the command prompt, or until pause or drawnow is called. You
are probably measuring the time to actually draw to the screen.
To test this, put "drawnow" before the pause timing block.
If this is correct, you may want to downsample the signal you are
plotting.
I have no idea why it behaves like that, it seems it will also
cause the Matlab to shut down imeediately if I use wavplay or sound
instead,
I have no idea what this means. I assume they are unrelated.
--
Peter Boettcher <boettcher@xxxxxxxxxx>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
.
- References:
- Pause in a while loop
- From: Nelson WONG
- Pause in a while loop
- Prev by Date: Re: generating points on a line joining 2 points in 3D space
- Next by Date: Puzzle
- Previous by thread: Re: Pause in a while loop
- Next by thread: Vectorize cropping NaN rows and cols of a matrix
- Index(es):