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
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
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!