Reputation: 231
I'm trying to run Simulink model and at the same time receiving and processing data in a Matlab script, and sending the result into Simulink to change the behavior of the model.
Since the Matlab scripts should keep receiving and processing data, the only way I can figure out is to use a while(1) loop. However, the simulation seemed to be blocked by the while loop. The simulation time is halted when I run the script. As long as I Ctrl+C to end the script, the simulation continued.
Is there any way to run the simulink simulation and the Matlab script(or function) simultaneously while keeping the interaction between them? Just like executing them in different thread.
Upvotes: 2
Views: 5603
Reputation: 10762
MATLAB (+ toolboxes + Simulink) is fundamentally a single threaded application, so there is no simple way of doing what you want. (In recent years some of the underlying math libraries have become multi-threaded, but that doesn't change the high level picture).
You can do either of the following:
The latter of these is (arguably) the easiest.
Upvotes: 2