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

3 次查看(过去 30 天)
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?

采纳的回答

john
john 2025-2-10
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 个评论

请先登录,再进行评论。

更多回答(1 个)

karthik kumar k
karthik kumar k 2025-2-9
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.

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by