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

8 次查看(过去 30 天)
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.

采纳的回答

Devdatt Lad
Devdatt Lad 2012-5-6
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.

更多回答(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