Programming Previous page   Next Page

Stopping Timer Objects

Once started, the timer object stops running if one of the following conditions apply:

You can also stop a timer object by using the stop function, specifying the timer object as the only argument. The following example illustrates stopping a timer object:

  1. Create a timer object.
  2. Start it running.
  3. Check the state of the timer object after starting it.
  4. Stop the timer using the stop command and check the state again. When a timer stops, the value of the Running property of the timer object is set to 'off'.
  5. Delete the timer object when you are finished using it.

Blocking the MATLAB Command Line

By default, when you use the start or startat function to start a timer object, the function returns control to the command line immediately. For some applications, you might prefer to block the command line until the timer fires. To do this, call the wait function right after calling the start or startat function.

  1. Create a timer object.
  2. Start the timer object running.
  3. After the start function returns, call the wait function immediately. The wait function blocks the command line until the timer object fires.
  4. Delete the timer object after you are finished using it.

Previous page  Starting a Timer at a Specified Time Creating and Executing Callback Functions Next page

© 1994-2005 The MathWorks, Inc.