Countdown timer continuously running
조회 수: 4 (최근 30일)
이전 댓글 표시
I am trying to figure out the best approach to this so I appreciate your thoughts. I'm running a model that uses the number of minutes remaining as an input. Let's say it counts down to September 30th. So as of right now there is roughly 21*24*60 = 30,240 minutes remaining. The time remaining should decrease every second. How can I achieve this? Some sort of endless loop? Part of a script? Or a function? Keep in mind this is only one input in my model, and there are many other moving parts. What type do I want...a datetime array? That is what I have been working with so far.
댓글 수: 0
답변 (1개)
Tim Jackman
2015년 9월 14일
I'd recommend using a timer object. You can set it to execute a callback function every second. Within that callback function, you can update your countdown variable. It seems like the thing to try first in your scenario. Here are a couple links that include a basic example on how timer objects work:
As for your question about what data type to use, a datetime array should be fine. Alternatively, you could convert the datetime into the number of minutes or seconds remaining if that is all you need from this variable. Hope this helps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!