Global variables in 'Attribute Function' block (Simulink - Sim events)

5 views (last 30 days)
I want to use 'Attribute Function' block (Simulink, SimEvents) to set attribute value of entities, but I need a some global variables to store data. How I can do this?
I tried to use 'Data Store' block but I guess there is no ability to use this block for the 'Attribute Function' block.

Accepted Answer

Devdatt Lad
Devdatt Lad on 6 May 2012
Currently, it's not possible to use global data, signal input/output or parameters with the Attribute Function block. The attribute function must be used with attribute input/output only. It's a limitation that we're working to remove.
In the meantime, you can do one of the following:
1. Set the global data as an attribute of the entity so that you can access it in the Attribute Function block.
2. Use the MATLAB Function block instead of the Attribute Function block. For this case, you will have to add an additional Get Attribute before the MATLAB Function to get the attributes that you want to use in your function. You also need an additional Set Attribute block to set the result of the function back as attributes of the passing entity. And finally you wil need a zero delay server block between the Get and Set Attribute blocks to hold each entity while the attribute value is computed.

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!