Countdown timer continuously running

7 visualizaciones (últimos 30 días)
Cary
Cary el 10 de Sept. de 2015
Respondida: Tim Jackman el 14 de Sept. de 2015
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.

Respuestas (1)

Tim Jackman
Tim Jackman el 14 de Sept. de 2015
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.

Categorías

Más información sobre Word games en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by