Time Functions

clock

Current date and time.

Syntax

t = clock

Description

clock returns a 1x6 row vector, containing the year (four digits), the month, the day, the hour, the minute and the second of the current date and time. All numbers are integers, except for the seconds which are fractional. The absolute precision is plus or minus one second with respect to the computer's clock; the relative precision is plus or minus 1 microsecond on a Macintosh, and plus or minus 1 millisecond on Windows.

Example

clock
  1999 3 11 15 37 34.9167

See also

tic, toc

tic

Start stopwatch.

Syntax

tic

Description

tic resets the stopwatch. Typically, tic is used once at the beginning of the block to be timed.

See also

toc, clock

toc

Elapsed time of stopwatch.

Syntax

elapsed_time = toc

Description

toc gets the time elapsed since the last execution of tic. Typically, toc is used at the end of the block of statements to be timed.

On multi-tasking operating systems like Windows, Mac OS X and Unix, toc measures only the time spent in the LME application. Other processes do not have a large impact. For instance, typing tic at the command-line prompt, waiting 5 seconds, and typing toc will show a value much smaller than 5.

Example

tic; x = eig(rand(200)); toc
  0.3046

See also

tic, clock


Copyright 1998-2007, Calerga.
All rights reserved.