Run in parallel a script and a real-time simulation
5 views (last 30 days)
Show older comments
Hi everyone!
I will try to explain myself as clear as possible so that you can understand the problem I am facing right now, which maybe has been already solved, in which case I apologize.
I am running a Real-time Simulink Model (very simple one, a sine wave with a gain whose parameter is a variable, 'x1') ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/527689/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/527689/image.jpeg)
I want to change the 'x1' parameter from the gain block 'G1' during the simulation but the main problem I am encountering is that the simulation stops until the scripts ends and it is not simultaneous.
So my question is the following: Is it possible to run a script and a simulink model at the same time so that the variables from the script are fed into the simulink model as block parameters?
Thank you so much!
Kind regards,
Eduardo
0 Comments
Answers (1)
Pratik
on 14 May 2024
Hi Eduardo,
As per my understanding, you are trying to update the parameter of the gain block using a script however the simulation stops before the script ends.
As a workaround, pause the mode, run the script and update the parameter and then continue the simulation. Alternatively SImulink function block can also be used to run the script.
Please find the documentations for more information:
Controlling execution of a simulation: https://www.mathworks.com/help/simulink/ug/controlling-execution-of-a-simulation.html
Matlab function block: https://www.mathworks.com/help/simulink/ug/what-is-a-matlab-function-block.html
I hope this helps!
0 Comments
See Also
Categories
Find more on Target Computer Setup 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!