timer in matlab function

1 vue (au cours des 30 derniers jours)
Hans Jørgen Jensen
Hans Jørgen Jensen le 16 Juin 2017
Commenté : Walter Roberson le 28 Août 2017
Hi, I have some control code in a Matlab function, and I would like to add a timer, that starts when a pump turns on, and if the pump runs for more than x hours continuously, a flag is to be raised, and the timer reset. I am not sure how to implement a timer, or the requested functionality in a Matlab function. I have read about the timer object, but not sure if that is the way to do it. Any suggestions of how to do this, or where to find info ? Thanks Hans Jensen

Réponses (1)

Walter Roberson
Walter Roberson le 16 Juin 2017
Yes, timer objects run their callbacks when they fire.
However, if by "matlab function" you are referring to "MATLAB Function Block" in Simulink, then you would use a different approach completely, as you would need to look at the simulated time rather than the real time.
  2 commentaires
Hans Jørgen Jensen
Hans Jørgen Jensen le 28 Août 2017
Hi, thanks for your reply, and sorry for my slow response. Yes, I am referring to a Matlab Function block
Walter Roberson
Walter Roberson le 28 Août 2017
Suppose you wanted the flag to be raise after the pump had run for 1 hour. Now, suppose your simulation turns out to be slower than real time, such as if it took 3 minutes real time to simulate each minute of physics: should the flag be raised after 1 hour of real time, or should it be raised after 1 simulated hour? Or perhaps your simulation is faster than life... may it takes only 1 second real time to simulate 6 seconds of pump. Should the flag still be raised after 1 hour of real time, or should it be raised after 1 simulated hour? If you go into the debugger and spend 20 minutes looking around at the state (maybe you went down for coffee while you thought), then should the flag still be raised after 1 real-time hour even if the simulation is paused at the debugger, or should it be after one simulated hour ?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by