Triggering functions in Event Actions @ SimEvents
Show older comments
Consider functions that take/give Tables as input/output like e.g:
function [ScaledTable] = ScaleMyTable(Table, Multiplier)
ScaledTable = Table.*Multiplier;
end
%
function [Table] = ClearTableColumn(ScaledTable, Column)
Table = RefTable(:,Column) = [];
end
I have a server in a SimEvents model. I would like to use Event Actions to call custom functions that operate on tables by using entities attributes, and operate on enties attributes by using values from tables. For example:
%% Entry Action:
ScaledTable = ScaleMyTable(Table, entity.Attribute1);
entity.Attribute3 = max(ScaledTable(:, entity.Attribute2));
Table = ClearTableColumn(ScaledTable, entity.Attribute4)
The simulation won't run because apparently some MATLAB workspace-defined classes like tables, structs etc. are not supported in Event Actions, and I don't understand how to circumvent the problem. I have tried using a MATLAB function block connected to "From Workspace/To Workspace" blocks and trigger that function from Event Actions, but the error message is the same.
"Error in [...] block. See Entry action line [...].
Caused by: Data type of parameter [...] is not supported in event actions [...]."
Further down the line there are gates controlled by signals; these signals are obtained by "From Workspace" blocks which reference columns of these tables, converted to timeseries. So, my goal(s) are something like:
- Use an Event Action to trigger a function that receives a Table as an input and give a Table as an output
- Do something with a Table (like assign a certain table entry to an entity's attribute)
- Making sure that the Table is updated at runtime so that the timeseries that control the entity gates further down the line are updated as well
What am I missing here? Is this just a flawed design, and do I have to tackle the problem another way? Thanks.
Accepted Answer
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!