How to apply IF statement to entity attribute
17 ビュー (過去 30 日間)
古いコメントを表示
Hello, I'm new to Matlab and Simulink. Right now my entity have two attributes, entity.FeePaid and entity.Age. I want to set rule where if (entity.FeePaid > 2.3) && (entity.Age > 1) only then it can enter queue else the entity will be dropped. I've tried using IF and SWITCH but it cannot retrieve the attribute. I'm trying to use ENTITIES GATE but I have no idea how to configure it (still trying to look for solution). Anyone has any idea how to solve this or what I'm doing wrong? I'm using Matlab R2019a. Thanks in advance.
3 件のコメント
回答 (1 件)
Ashok
2024 年 11 月 22 日 11:10
編集済み: Ashok
2024 年 11 月 22 日 11:10
From the attached screenshot, it looks like two different entity types, 'Attacker' and 'Legitimate', are being combined into a single queue using an 'Entity Input Switch' block. This approach isn't feasible. More details can be found here:
Regarding filtering entities based on attribute values, the 'Simulink Function' block allows for implementing functions, including relational expressions, using Simulink blocks. The attached file 'example_R2019a.slx' demonstrates this.
In the example, the 'User Entity Gen' subsystem generates entities of type 'User' with attributes (FeePaid, Age). These entities can have two possible attribute combinations: (0, 0) or (5, 2).
When an entity enters 'Entity Server 1', the 'Check_fn' function is called, passing the entity's attributes as arguments.
The 'Simulink Function' block, 'Check_fn', applies the logical condition (FeePaid > 2.3) && (Age > 1) and outputs a control signal.
This control signal directs the 'Entity Output Switch' to send the entity down the appropriate path. The rest of the model is for visualizing the filtered entities. Signal viewers inside the 'recordOutEntityFeeAge' function display the 'FeePaid' and 'Age' attributes of the filtered entities.
For more information about the 'Simulink Function' block, run the following command in the MATLAB Command Window.
web(fullfile(docroot, 'simulink/slref/simulinkfunction.html'))
I believe this will assist you!
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!