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

조회 수: 5 (최근 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