timer in matlab function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (1)
Walter Roberson
il 16 Giu 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 Commenti
Walter Roberson
il 28 Ago 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 ?
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!