Looking for an efficient way to run Simulink on thousands of independent files

6 次查看(过去 30 天)
I'm running Simulink using some rather complex in-house code, so my ability to modify it extensively is limited, but I can modify it. The structure is as below, and I'm looking for a better/faster way to run through it:
  • I have a folder that contains 5000 data files, all completely independent from each other: run1.mat, run2.mat, etc. These are all time-based systems.
  • The in-house code loads up one of these mat files, loops through a range of specified time points (10s, 20s, 30s, etc) and at each time point pulls data from this mat file, updates a large number of variables located in the base workspace, then recompiles the Simulink model before finally storing the output data.
To "parallelize" this, this code also has the ability to kick off other matlab sessions within itself, giving each session a different range of run numbers to evaluate. This works but has a lot of overhead, eventually running entirely out of memory when doing too many. I do have access to an HPC and would like to utilize it where possible.
My question is if I can utilize any of the Simulink parallelization capabilities to fit my situation? Considering Simulink pulls from the base-level workspace variables and my tool can update them from anywhere within its 30 script collection, it's not exactly feasible to just do some updates in a parfor loop and do it that way. At least I don't think.
Thanks
  1 个评论
dpb
dpb 2025-8-9
It would seem you would have to have a way to create independent copies of the necessary data contained in the workspace in order to be able to distribute it.

请先登录,再进行评论。

采纳的回答

Paul
Paul 2025-8-9
If I'm understanding the workflow correctly, it seems like you could set up a loop to read in each mat file and set the appropriate field of each element of a Simulink.SimulationInput. Once you have that array, then you can use either parsim or batchsim (assuming the Parallel Computing Toolbox is available) depending on other needs. More generally start from Run Mutliple Simulations for much more dicussion and details.
  1 个评论
Sian
Sian 2025-8-11
Thank you for at least pointing me in the right direction and getting me some stuff to look at. Since the code is in-house I haven't gotten the chance to really dive into the math of it, but the setup procedure I understand pretty well. But regardless, getting parsim or batchsim working (in my opinion) would be greatly beneficial. And yes, we do have the parallel toolbox available, so that shouldn't be an issue.
Thanks!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 System Composer 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by