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

6 visualizzazioni (ultimi 30 giorni)
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 Commento
dpb
dpb il 9 Ago 2025
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.

Accedi per commentare.

Risposta accettata

Paul
Paul il 9 Ago 2025
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 Commento
Sian
Sian il 11 Ago 2025
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!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su System Composer in Help Center e File Exchange

Tag

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by