Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
19
Добавлен:
09.02.2015
Размер:
109.06 Кб
Скачать

150.697 179.323 203.212 226.505 249.633]'; % Population

plot(datenum(t,1,1),p) % Convert years to date numbers and plot

datetick('x','yyyy') % Replace x-axis ticks with 4 digit year labels.

See also datestr, datenum.

Reference page in Help browser

doc datetick

Timing functions

<cputime> - CPU time in seconds.

CPUTIME CPU time in seconds.

CPUTIME returns the CPU time in seconds that has been used

by the MATLAB process since MATLAB started.

For example:

t=cputime; your_operation; cputime-t

returns the cpu time used to run your_operation.

The return value may overflow the internal representation

and wrap around.

See also etime, tic, toc, clock

Reference page in Help browser

doc cputime

<tic> - Start stopwatch timer.

TIC Start a stopwatch timer.

TIC and TOC functions work together to measure elapsed time.

TIC, by itself, saves the current time that TOC uses later to

measure the time elapsed between the two.

TSTART = TIC saves the time to an output argument, TSTART. The

numeric value of TSTART is only useful as an input argument

for a subsequent call to TOC.

Example: Measure the minimum and average time to compute a sum

of Bessel functions.

REPS = 1000; minTime = Inf; nsum = 10;

tic;

for i=1:REPS

tstart = tic;

sum = 0; for j=1:nsum, sum = sum + besselj(j,REPS); end

telapsed = toc(tstart);

minTime = min(telapsed,minTime);

end

averageTime = toc/REPS;

See also toc, cputime.

Reference page in Help browser

doc tic

<toc> - Stop stopwatch timer.

TOC Read the stopwatch timer.

TIC and TOC functions work together to measure elapsed time.

TOC, by itself, displays the elapsed time, in seconds, since

the most recent execution of the TIC command.

T = TOC; saves the elapsed time in T as a double scalar.

TOC(TSTART) measures the time elapsed since the TIC command that

generated TSTART.

Example: Measure the minimum and average time to compute a sum

of Bessel functions.

REPS = 1000; minTime = Inf; nsum = 10;

tic;

for i=1:REPS

tstart = tic;

sum = 0; for j=1:nsum, sum = sum + besselj(j,REPS); end

telapsed = toc(tstart);

minTime = min(telapsed,minTime);

end

averageTime = toc/REPS;

See also tic, cputime.

Reference page in Help browser

doc toc

<etime> - Elapsed time.

ETIME Elapsed time.

ETIME(T1,T0) returns the time in seconds that has elapsed between

Vectors t1 and t0. The two vectors must be six elements long, in

the format returned by CLOCK:

T = [Year Month Day Hour Minute Second]

Time differences over many orders of magnitude are computed accurately.

The result can be thousands of seconds if T1 and T0 differ in their

first five components, or small fractions of seconds if the first five

components are equal.

Note: When timing the duration of an event, use the TIC and TOC

functions instead of CLOCK or ETIME. These latter two functions are

based on the system time which can be adjusted periodically by the

operating system and thus might not be reliable in time comparison

operations.

Example:

This example shows two ways to calculate how long a particular FFT

operation takes. Using TIC and TOC is preferred, as it can be

more reliable for timing the duration of an event:

x = rand(800000, 1);

t1 = tic; fft(x); toc(t1) % Recommended

Elapsed time is 0.097665 seconds.

t = clock; fft(x); etime(clock, t)

ans =

0.1250

See also tic, toc, clock, cputime, datenum.

Reference page in Help browser

doc etime

<pause> - Wait in seconds.

PAUSE Wait for user response.

PAUSE(n) pauses for n seconds before continuing, where n can also be a

fraction. The resolution of the clock is platform specific. Fractional

pauses of 0.01 seconds should be supported on most platforms.

PAUSE causes a procedure to stop and wait for the user to strike any

key before continuing.

PAUSE OFF indicates that any subsequent PAUSE or PAUSE(n) commands

should not actually pause. This allows normally interactive scripts to

run unattended.

PAUSE ON indicates that subsequent PAUSE commands should pause.

PAUSE QUERY returns the current state of pause, either 'on' or 'off'.

STATE = PAUSE(...) returns the state of pause previous to processing

the input arguments.

The accuracy of PAUSE is subject to the scheduling resolution of the

operating system you are using and also to other system activity. It

cannot be guaranteed with 100% confidence, but only with some expected

error. For example, experiments have shown that choosing N with a

resolution of .1 (such as N = 1.7) leads to actual pause values that

are correct to roughly 10% in the relative error of the fractional

part. Asking for finer resolutions (such as .01) shows higher relative

error.

Examples:

% Pause for 5 seconds

pause(5)

% Temporarily disable pause

pause off

pause(5) % Note that this does not pause

pause on

% Aternatively, disable/restore the state

pstate = pause('off')

pause(5) % Note that this does not pause

pause(pstate);

See also keyboard, input.

Overloaded methods:

audiorecorder/pause

audioplayer/pause

Reference page in Help browser

doc pause

Соседние файлы в папке Библиотеки Matlab