I need to make a continuous timer
4 ビュー (過去 30 日間)
古いコメントを表示
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.
1 件のコメント
Guillaume
2015 年 11 月 9 日
" but they have a finite number of periods"
As far as I know, this is not true.
採用された回答
Guillaume
2015 年 11 月 9 日
As far as I know, matlab timers are not restricted to a finite number of periods.
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.
0 件のコメント
その他の回答 (1 件)
TastyPastry
2015 年 11 月 9 日
If you want to measure performance in real time (i.e. seconds), you can use the functions tic() and toc() which start and read the timer, respectively. Call tic() again to reset the timer. Alternatively, there are functions timeit() and cputime() depending on what you're trying to time.
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!