How do you read an attribute from one part of a composite entity

2 ビュー (過去 30 日間)
Mats
Mats 2020 年 5 月 18 日
回答済み: Krishna Akella 2020 年 12 月 1 日
I have two entities that create a new composite entity. After that creation I will need to access an attribute from one of these entities in the composite entity. How do I do that?

採用された回答

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020 年 5 月 19 日
編集済み: Abdolkarim Mohammadi 2020 年 5 月 19 日
Composite entities retain the hierarchical structure of the constituent entities. There are two ways:
(1) Directly method. If you name your constituent entities E1 and E2, you can access the original attributes by using entity.E1.Attribute.
(2) Indirect method. You can first split the composite entity and read their attributes separately. I have implemented both methods in the attached model.
  2 件のコメント
Mats
Mats 2020 年 5 月 20 日
Thanks, just as i expected. I realized now when I read your answer that my problem was a bit more specific.
I am trying to use a Entity Selector with a composite entity and that is what doesn't work. It does not seem to accept composite entities.
Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020 年 5 月 20 日
編集済み: Abdolkarim Mohammadi 2020 年 5 月 20 日
Now the best way to implement this is the MATLAB Discrete-Event System block, where you can programatically define any discrete-event system. The entity selector block itself is implemented as a MATLAB Discrete-Event System block. There you can define that, for instance, when an entity arrives into the first input port into Storage 1, the block iterate over Storage 2 to do whatever is desired on every entity in that storage using eventIterate method.

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

その他の回答 (1 件)

Krishna Akella
Krishna Akella 2020 年 12 月 1 日
Hi Mats,
Entity Selector block is expected to work with both composite entities as well as batched entities. I think the attribute name for the 'key' entity is not set correctly. Probably 'P.PA.nuffra' should read differently?
I have attached a similar model as yours (R2020a) and I am able to simulate it and the results also seem to be as expected.
Thanks & regards,
Krishna

カテゴリ

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