How can you assign entity attribute values from a changing variable (simeventes)

2 次查看(过去 30 天)
I have a simevents model representign manufacturing of a single type product with 14 different colors.
The value of the entity should be assigned as an order of that color comes in. I want to do this from a variable that can be changed. Is there any way to change the value of an attribute from an outside source? I have tried it with a server but those do not accept inputs except for service time.
I have also tried it uding a function subsystem using a terminator to assign the value but it does not seem to work to read and write from simulink to the workspace.
I have also tried to assign it using the data store blocks but the entity generator does not seem to accept that value.
What I essentially need is the functionality of the legacy block from 'assign attribute' using a signal port.

回答(1 个)

Altaïr
Altaïr 2025-5-16
编辑:Altaïr 2025-5-16
Variables in the base workspace can be accessed from the event actions of the Entity Generator. Additionally, mask-specific parameters, MATLAB variables, and parameters in the model workspace are also available from the event actions section. For further details, the following command provides more information:
web(fullfile(docroot, 'simevents/ug/event-action-languages.html#bvckoh2'))
A variable can be placed in the base workspace, and the assignin function can be used within a MATLAB Function block to set its value during simulation. However, this may not be of much use as the updated value will not be reflected in the Entity Generator, as base workspace parameters used in Simulink are intended to remain constant throughout the simulation. Also, since assignin does not support code generation, it needs to be defined as coder.extrinsic. An alternative here is to use Dashboard Blocks:
web(fullfile(docroot, 'simulink/ug/tune-and-visualize-your-model-with-dashboard-blocks.html'))
However, If the variation of the entity's attribute value is simple enough, I recommend defining a Simulink Function that outputs the entity's attribute value. This Simulink Function can be called within the Entity Generator to set the attribute value, as illustrated below.
Alternatively, modifying the Entity Generator block to accept the attribute's value as input is another option, especially for more complex or permanent use cases. More information on this can be found with the following command:
web(fullfile(docroot, 'simevents/ug/custom-entity-generator-block-with-signal-input-1.html'))

类别

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