Using a "global" variable in Simevents

6 ビュー (過去 30 日間)
Paul
Paul 2020 年 9 月 2 日
コメント済み: tarnim nos 2023 年 8 月 29 日
I am returning to Matlab and Simevents after a long time away and much has changed. Two questions:
  1. I am building a simple manufacturing model using Simevents. I am using entity-specific attributes. I addition I would like some Event Actions to be able to access what I'm calling (possibly wrongly) global variables. i.e. multiple blocks can access the same variable. This might be a counter for a particular type of product for example. Could someone please point me in the right direction?
  2. Possibly related to above how do I access simulation time within the blocks?
Many thanks for your help

採用された回答

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020 年 9 月 2 日
1) You can create it with set and get functions. They are nothing but two Simulink functions, where the output of the Set is connected to the input of the Get. When you want to assign a new value to this variable, you use the following code:
SetVariable(NewValue);
And when you want to query the variable, you can use:
GetVariable();
For a counter, you first get the old value, increment it, and then set the new value.
2) You should create a Simulink function, which has a Digital Clock block in it. When you needed to get the simulation time, you simply use:
GetSimulationTime();
  2 件のコメント
Paul
Paul 2020 年 9 月 3 日
thanks a million
tarnim nos
tarnim nos 2023 年 8 月 29 日
Hello, is it possible to provide more details on how to implement this in simevents blocks, i.e. the entity generator. Thank you so much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete-Event Simulation についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by