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

3 Ansichten (letzte 30 Tage)
john
john am 9 Feb. 2025
Kommentiert: karthik kumar k am 4 Mär. 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?

Akzeptierte Antwort

john
john am 10 Feb. 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 Kommentare

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

karthik kumar k
karthik kumar k am 9 Feb. 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 Kommentar
john
john am 9 Feb. 2025
there is no event based statistics block, at least at the academic version of 2024b

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by