Main Content

reset

Reset Rate object

Description

reset(rate) resets the state of the Rate object, including the elapsed time and all statistics about previous periods. reset is useful if you want to run multiple successive loops at the same rate, or if the object is created before the loop is executed.

example

Input Arguments

expand all

Rate object, specified as a handle. This object contains the information for the desired rate and other information about the execution. See rateControl for more information.

Examples

expand all

Create a rateControl object for running at 20 Hz.

r = rateControl(2);

Start a loop and control operation using the Rate object.

for i = 1:30
    % Your code goes here
    waitfor(r);
end

Display the rateControl object properties after loop operation.

disp(r)
  rateControl with properties:

         DesiredRate: 2
       DesiredPeriod: 0.5000
       OverrunAction: 'slip'
    TotalElapsedTime: 15.0047
          LastPeriod: 0.5000

Reset the object to restart the time statistics.

reset(r);
disp(r)
  rateControl with properties:

         DesiredRate: 2
       DesiredPeriod: 0.5000
       OverrunAction: 'slip'
    TotalElapsedTime: 0.0018
          LastPeriod: NaN

Version History

Introduced in R2016a

See Also

| (Navigation Toolbox) |