How to define mask parameter for attribute function in SimEvents

2 次查看(过去 30 天)
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
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 CenterFile Exchange 中查找有关 Discrete-Event Simulation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by