How to define mask parameter for attribute function in SimEvents

2 vues (au cours des 30 derniers jours)
Rob
Rob le 2 Juin 2013
Commenté : Grant le 25 Juil 2014
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 commentaires
Rob
Rob le 4 Juin 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?
Stephen Mc Ateer
Stephen Mc Ateer le 2 Juil 2013
bump!
The answer to this question would also help me.

Connectez-vous pour commenter.

Réponse acceptée

Stephen Mc Ateer
Stephen Mc Ateer le 2 Juil 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 commentaire
Grant
Grant le 25 Juil 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Discrete-Event Simulation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by