Skip to Main Content Skip to Search
Product Documentation

startat - Start timer(s) running at specified time

Syntax

startat(obj,time)
startat(obj,S)
startat(obj,S,pivotyear)
startat(obj,Y,M,D)
startat(obj,[Y,M,D])
startat(obj,Y,M,D,H,MI,S)
startat(obj,[Y,M,D,H,MI,S])

Description

startat(obj,time) starts the timer represented by timer object objrunning at the time specified by the serial date number time. If obj is an array of timer objects, startat starts all the timers running at the specified time. To create a timer object, use the timer function. You can set the starting time to any serial date number less than or equal to 25 days from the current date.

startat sets the Running property of the timer object, obj, to 'on', initiates TimerFcn callbacks, and executes the StartFcn callback.

The serial date number, time, indicates the number of days that have elapsed since 1-Jan-0000 (starting at 1). See datenum for additional information about serial date numbers.

startat(obj,S) starts the timer running at the time specified by the date string S. The date string must use date format 0, 1, 2, 6, 13, 14, 15, 16, or 23, as defined by the datestr function. Date strings with two-character years are interpreted to be within the 100 years centered on the current year.

startat(obj,S,pivotyear) uses the specified pivot year as the starting year of the 100-year range in which a two-character year resides. The default pivot year is the current year minus 50 years.

startat(obj,Y,M,D) startat(obj,[Y,M,D]) start the timer at the year (Y), month (M), and day (D) specified. Y, M, and D must be arrays of the same size (or they can be a scalar).

startat(obj,Y,M,D,H,MI,S) startat(obj,[Y,M,D,H,MI,S]) start the timer at the year (Y), month (M), day (D), hour (H), minute (MI), and second (S) specified. Y, M, D, H, MI, and S must be arrays of the same size (or they can be a scalar). Values outside the normal range of each array are automatically carried to the next unit (for example, month values greater than 12 are carried to years). Month values less than 1 are set to be 1; all other units can wrap and have valid negative values.

The timer stops running if one of the following conditions apply:

Examples

This example uses a timer object to execute a function at a specified time.

t1=timer('TimerFcn','disp(''it is 10 o''''clock'')');
startat(t1,'10:00:00');

This example uses a timer to display a message when an hour has elapsed.

t2=timer('TimerFcn','disp(''It has been an hour now.'')');
startat(t2,now+1/24);

See Also

datenum | datestr | now | start | stop | timer

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS