How to define mask parameter for attribute function in SimEvents

4 views (last 30 days)
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 Comments
Rob
Rob on 4 Jun 2013
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?

Sign in to comment.

Accepted Answer

Stephen Mc Ateer
Stephen Mc Ateer on 2 Jul 2013
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 Comment
Grant
Grant on 25 Jul 2014
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Discrete-Event Simulation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!