Hi Celia,
I understand that you would like to update variables using Simulink. To achieve this, you can create a Simulink Model Workspace.
To manipulate model workspace variables, you can use MATLAB commands on a “Simulink.Workspace” variable. Please refer to the following documentation for guidance on how to accomplish this in your specific case:
- https://www.mathworks.com/help/simulink/slref/simulink.modelworkspace.html
- https://www.mathworks.com/help/simulink/ug/change-model-workspace-data.html#f4-140177
Regarding where to place these commands, it depends on your scenario. If the variables only change at the end of the simulation and should be used for the next simulation, you can put the commands in the "StopFcn" callback.
If the variables change EVERY time step during the simulation, try putting it in a MATLAB function block since this would execute every time step.
Hope this information helps you in resolving your query!