How to measure the time an entity is in a system? (simulink)

3 visualizaciones (últimos 30 días)
john
john el 9 de Feb. de 2025
Comentada: karthik kumar k el 4 de Mzo. de 2025
When an entity is generated from the entity generator until it's termination from the entity terminator block it spends some time in the system. How can I calculate that time and is there a way at the end of the simulation to get an average time that an entity spends in the system?

Respuesta aceptada

john
john el 10 de Feb. de 2025
So I found out the solution myself and posting it in case anyone needs it. You add a simulink function (lets name it: start) inside the function delete everything it has and you add a digital clock block, which then you connect to an out1 block. You then create another simulink function(lets name it finish),(delete everything it has) with another digital clock block, an In1 block, a substract block and an out1 block. Connect the digital clock to the + of the substract block and the In1 to the - of the substract block and then the substract to the out1. Now connect the outport of the first function (start) to the input port of the other (finish). Last step: you need to call these functions, go to the entity creator --> event actions --> exit--> and add the name of the function, start(). Now go to the entity terminator --> event actions --> entry-> and add the name of the function, finish(). You can add a scope after the function finish. You can also add a mean block and then a display to calculate the average number of all the values you have obtained.
  3 comentarios

Iniciar sesión para comentar.

Más respuestas (1)

karthik kumar k
karthik kumar k el 9 de Feb. de 2025
To calculate the time an entity spends in the system and get the average time at the end of the simulation:
Add an "Event-Based Statistic" Block:
  • Connect it between the Entity Generator and the Entity Terminator blocks.
Configure the "Event-Based Statistic" Block:
  • Set the Statistics parameter to Time in Block.
  • This automatically measures how long each entity spends in the system.
Monitor the Average Time:
  • The block will provide the average time spent in the system at the end of the simulation.
  1 comentario
john
john el 9 de Feb. de 2025
there is no event based statistics block, at least at the academic version of 2024b

Iniciar sesión para comentar.

Categorías

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

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by