%% Run Loop at Fixed Rate
% Create a rate object that runs at 1 Hz.

r = robotics.Rate(1);

%
% Start a loop using the Rate object inside to control the loop execution. Reset the object prior to the loop execution to reset timer. Print the iteration and time elapsed.

reset(r)
for i = 1:10
	time = r.TotalElapsedTime;
	fprintf('Iteration: %d - Time Elapsed: %f\n',i,time)
	waitfor(r);
end

% Each iteration executes at a 1-second interval.
% Copyright 2012 The MathWorks, Inc.