If you're using the MATLAB - LEGO interface, then you're not really deploying any code, right? If so, then I would recommend using the tic and toc functions.
- https://www.mathworks.com/help/matlab/ref/tic.html
- https://www.mathworks.com/help/matlab/ref/toc.html
Your code would look something like
tic;
while (toc < 2)
% Do stuff
% Optionally, pause if you don't want to spam as fast as possible
pause(0.1)
end
If you have Robotics System Toolbox, you can get more advanced with the sample rates using Robotics.Rate.
r = robotics.Rate(10); % 10 Hz
while (r.TotalElapsedTime < 2)
% Do stuff
waitfor(r);
end
- Sebastian