timer in matlab function

1 visualización (últimos 30 días)
Hans Jørgen Jensen
Hans Jørgen Jensen el 16 de Jun. de 2017
Comentada: Walter Roberson el 28 de Ag. de 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

Respuestas (1)

Walter Roberson
Walter Roberson el 16 de Jun. de 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 comentarios
Hans Jørgen Jensen
Hans Jørgen Jensen el 28 de Ag. de 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 el 28 de Ag. de 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 ?

Iniciar sesión para comentar.

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by