Running Simulink in Parellel

1 view (last 30 days)
Matthew
Matthew on 24 Apr 2014
Commented: Matthew on 24 Apr 2014
I have a question regarding running Simulink in a parfor loop on a single (local) machine. Right now the program runs fine in a regular for loop, but in converting it over for parellel processing, I am running into a problem of transparency on a m-file inside the loop. Unfortunately, switching this non-function m-file to a function would be extremely cumbersome, as there are hundreds of variables defined in this file that need to be passed in and out of any setup function, since the Simulink model needs to see all the variable names as they currently are. This also makes converting these variables into a data structure also off the table, as I would just have to unpackage the structure back into its original variable names in the parfor loop.
Thus, my question is, is there a more efficient way of writing this script short of just pasting all the individual code into the text of the loop? I can do this, but that adds hundreds if not thousands of lines of code to the file. For the most part, the scripts to be run either set variables or else load mat files (which I know need to be handled differently in parfor loops). Otherwise, they are all completely ready to be run in parallel.
Additionally, I seem to be running into the problem that the variables I define in the parfor loop are not being seen by the simulink model. The variables are defined in both the loop and outside it, so I'm not sure why this is a problem (I tried defining them just outside the loop, and that did not work). Some of the varibles are modified by the simulation, and some are not. Any help on this would also be appreciated.
  1 Comment
Matthew
Matthew on 24 Apr 2014
Figured it out! All I needed was the line
evalin('base',' filename')
and it will read the file to all the base workers directories and not the client directory.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements 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!