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 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