Running Simulink in Parellel

1 次查看(过去 30 天)
Matthew
Matthew 2014-4-24
评论: Matthew 2014-4-24
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 个评论
Matthew
Matthew 2014-4-24
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by