MATLAB: I need to make a continuous timer

loop timerMATLAB

I need to make a continuous timer to be used with a Data Acquisition program. I am saving the acquired data every minute, and my timer will occur every hour, so I cannot use pause instead of a timer because I will not be able to save my data. I have been able to create timers that activate on a periodic basis, but they have a finite number of periods. I am looking to make a timer that runs indefinitely. I am using the core Matlab program to acquire my data, this program is in an .m file.

Best Answer

As far as I know, matlab timers are not restricted to a finite number of periods.
If a standard matlab timer is not suitable and you're on Windows, you can always use a .Net Timer:
period = 5000; %in milliseconds
nettimer = System.Timers.Timer(period);
nettimer.AutoReset = true; %true by default anyway
timerlistener = addlistener(nettimer, 'Elapsed', @(~, ~) disp('Hello'));
nettimer.Enabled = true; %start timer
I would still recommend using a matlab timer.
Related Question