How to define mask parameter for attribute function in SimEvents

4 ビュー (過去 30 日間)
Rob
Rob 2013 年 6 月 2 日
コメント済み: Grant 2014 年 7 月 25 日
Hi,
I work with SimEvents in Simulink. In my model I have two Attribute Function blocks. Just now I found out that Attribute functions can also use Mask parameters from its mask. Then I checked which parameters are defined in my two Attribute block masks. The older one have one mask parameter named Mask parameter 2 with value of 2. Newer one have no mask parameter. Both have Edit mask (Ctrl-M) disabled. How can I edit mask parameters for attribute function block?
Thanks for bothering with my problems.
  2 件のコメント
Rob
Rob 2013 年 6 月 4 日
Hello,
Since there is no answer I suppose that not many of you needed additional parameter passed into attribute function...
Or is my question to vague? Basically I need additional parameter to pass into Attribute function. I have item's attributes, which will be used in the Attribute function - but they are not enough. How to get that extra variable into Attribute function?
Stephen Mc Ateer
Stephen Mc Ateer 2013 年 7 月 2 日
bump!
The answer to this question would also help me.

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

採用された回答

Stephen Mc Ateer
Stephen Mc Ateer 2013 年 7 月 2 日
Okay here's how I solved it. Maybe there's issues with this approach, but it worked for me.
The trick is to turn the mask parameter into an attribute.
  1. Create a mask with a mask parameter, mask_param = 1
  2. Inside the mask, use a set attribute box with, Name -> attribute_param, Value From -> Dialog, Value -> mask_param
  3. Now you can use attribute_param inside the Attrubute Function box
There must be a better way, since this involves a lot of possibly unnecessary assignments.
  1 件のコメント
Grant
Grant 2014 年 7 月 25 日
As far as I know, there is no way to remove an attribute from an entity, so this solution can cause problems with memory in a system with many entities.
An alternative that I've used is to:
  1. Place a MATLAB Function block inside of a Function-Call Subsystem
  2. Use a Get Attribute block to select the necessary parameters from the entity and connect them through the subsystem to the MATLAB Function block as inputs
  3. Connect that Get Attribute block to an Entity Departure Function Call Generator and use this function call to trigger the subsystem
  4. Connect that to a 0 service time Server block (to avoid a race condition)
  5. Connect to a Set Attribute block to set the appropriate attributes that gets the values from ports connected to the output of the MATLAB Function block through the subsystem.
The MATLAB Function block may have a mask created an have parameters passed through a mask of the Function-Call Subsystem.
I believe this significantly slows down the simulation, but these are your only two options. There is no good way to do this, which is frustrating.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by