rateControl
Execute loop at fixed frequency
Description
The rateControl
object enables you to run a loop at a fixed
frequency. It also collects statistics about the timing of the loop iterations. Use
waitfor
in the loop to pause code execution until the next time step.
The loop operates every DesiredPeriod
seconds, unless the enclosed
code takes longer to operate. The object uses the OverrunAction
property to determine how it handles longer loop operation times. The default setting,
'slip'
, immediately executes the loop if
LastPeriod
is greater than DesiredPeriod
.
Using 'drop'
causes the waitfor
method to wait until the next multiple of
DesiredPeriod
is reached to execute the next
loop.
Tip
The scheduling resolution of your operating system and the level of other system activity can affect rate execution accuracy. As a result, accurate rate timing is limited to 100 Hz for execution of MATLAB® code. To improve performance and execution speeds, use code generation.
Creation
Description
creates an object that operates loops at a fixed-rate based on your system
time and directly sets the rateObj
= rateControl(desiredRate
)DesireRate
property.
Properties
Object Functions
waitfor | Pause code execution to achieve desired execution rate |
statistics | Statistics of past execution periods |
reset | Reset Rate object |