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

3 ビュー (過去 30 日間)
john
john 2025 年 2 月 9 日
コメント済み: karthik kumar k 2025 年 3 月 4 日
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 件のコメント
john
john 2025 年 2 月 20 日
thanks
karthik kumar k
karthik kumar k 2025 年 3 月 4 日
Thanks

サインインしてコメントする。

その他の回答 (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.
  1 件のコメント
john
john 2025 年 2 月 9 日
there is no event based statistics block, at least at the academic version of 2024b

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by