Phantom Documentation

[Help Home] [Phantom Home]
clock

real clock(int)

Return Type: real
Parameters: int StateFlag

Description:
This function starts and stops an internal clock. If the StateFlag is 1, the internal clock starts and returns 0.0. If the StateFlag is 0, the function returns the number of seconds elapsed since the call with StateFlag = 1. Calling the function again with the StateFlag = 1 resets the internal clock. This function is useful for timing how long a process takes. Calling 'clock' with StateFlag = 0 without calling 'clock' with StateFlag = 1 first produces undefined results. Therefore, 'clock' should always be called with StateFlag = 1 prior to use so the internal clock is reset.

Example Code
1 >>clock(1);
2 >>disp("Hi");
Hi
3 >>disp(clock(0));
9.90500000000000
4 >>disp(clock(0));
12.10800000000000
5 >>disp(clock(1));
0.00000000000000
6 >>disp(clock(0));
2.50400000000000


 


Copyright 2000-2011 Phantom Automated Solutions