Main Content

statistics

Statistics of past execution periods

Description

example

stats= statistics(rate)returns statistics of previous periods of code execution.statsis a struct with these fields:Periods,NumPeriods,AveragePeriod,StandardDeviation, andNumOverruns.

Here is a sample execution graphic using the default setting,'slip', for theOverrunActionproperty in theRateobject. SeeOverrunActionfor more information on overrun code execution.

The output ofstatisticsis:

stats = Periods: [0.7 0.11 0.7 0.11] NumPeriods: 4 AveragePeriod: 0.09 StandardDeviation: 0.0231 NumOverruns: 2

Input Arguments

expand all

Rateobject, specified as an object handle. This object contains the information for theDesiredRateand other info about the execution. SeerateControlrateControl(Navigation Toolbox)for more information.

Output Arguments

expand all

Time execution statistics, returned as a structure. This structure contains the following fields:

  • Period— All time periods (returned in seconds) used to calculate statistics as an indexed array.stats.Period(end)is the most recent period.

  • NumPeriods— Number of elements inPeriods

  • AveragePeriod— Average time in seconds

  • StandardDeviation— Standard deviation of all periods in seconds, centered around the mean stored inAveragePeriod

  • NumOverruns— Number of periods with overrun

Examples

expand all

创建一个rateControlobject for running at 20 Hz.

r = rateControl(20);

Start a loop and control operation using therateControlobject.

fori = 1:30% Your code goes herewaitfor(r);end

GetRateobject statistics after loop operation.

stats = statistics(r)
stats =struct with fields:Periods: [0.0751 0.0269 0.0497 0.0512 0.0523 0.0449 0.0501 ... ] NumPeriods: 30 AveragePeriod: 0.0500 StandardDeviation: 0.0065 NumOverruns: 0

See Also

|(Navigation Toolbox)|

Introduced in R2016a