What is the fastest way to run same simulink model multiple times ?

28 views (last 30 days)
omar khater
omar khater on 14 Jul 2019
Commented: omar khater on 15 Jul 2019
If I have a large dataset say 6000 rows of data that I need to evaluate simulink model at each point
Currently I use for loop and use simout for each time to update simulink with each new value for my parameters.
I think there is more elegent approaches to do this task.
My simulink model uses components from Powerelctronics library. I assign each parameter with symbolic value that gets updated from Matlab workspace. This works fine with 6000 rows of data despite some affordable time. But more than that needs more elegent approaches.
Any suggestions will be appreciated.

Accepted Answer

Jonas
Jonas on 15 Jul 2019
Edited: Jonas on 15 Jul 2019
What is exactly the issue you are having with this approach? The speed, or the way you save and load data?
  • If you want to run it faster, you can parallelize the simulations with the Parallel Computing Toolbox and a parfor-loop. Each instance of the simulation will run on a separate processor thread. This will give you significant speed increases.
  • If data management is the issue, you may want to use the Simulink Test Toolbox to manage the parameter sweep, but I am not really sure you will benefit a lot from this since you have set up a way to run the simulations already.
I would in fact perform a parameter sweep on Simulink simulations in a very similar way as you are doing right now.
  4 Comments
omar khater
omar khater on 15 Jul 2019
Another thing that I would like to try is here
but when I open the used example sldemo_parallel_rapid_accel_sims_script
it gives me this error. I double checked that I have this compiler installed
ldemo_parallel_rapid_accel_sims_script
[15-Jul-2019 19:21:05] Checking for availability of parallel pool...
[15-Jul-2019 19:21:05] Loading Simulink on parallel workers...
Analyzing and transferring files to the workers ...done.
[15-Jul-2019 19:21:07] Configuring simulation cache folder on parallel workers...
[15-Jul-2019 19:21:07] Running SetupFcn on parallel workers...
[15-Jul-2019 19:21:11] Cleaning up parallel workers...
Error using sldemo_parallel_rapid_accel_sims_script (line
121)
Error executing SetupFcn
Caused by:
Error using build_rapid_accel_target
Failed to build model 'sldemo_raccel_engine_idle_speed'
using LCC in rapid accelerator mode, please consider
using a different compiler instead. For details on
supported compiler versions, see
http://www.mathworks.com/support/compilers/current_release
Error using slbuild_private
It appears as though pwd (H:\MatlabScripts) contains
an existing build folder, while the root build folder
in Simulink.fileGenControl is set to another folder.
The build folder in pwd may shadow build artifacts in
the root build folder and cause unexpected errors.
Consider CDing to a folder that does not contain an
existing build folder prior to initiating a build.
The Build Process will terminate.
Error using build_rapid_accel_target
Failed to build model 'sldemo_raccel_engine_idle_speed'
using LCC in rapid accelerator mode, please consider
using a different compiler instead. For details on
supported compiler versions, see
http://www.mathworks.com/support/compilers/current_release
Error using slbuild_private
It appears as though pwd (H:\MatlabScripts) contains
an existing build folder, while the root build folder
in Simulink.fileGenControl is set to another folder.
The build folder in pwd may shadow build artifacts in
the root build folder and cause unexpected errors.
Consider CDing to a folder that does not contain an
existing build folder prior to initiating a build.
The Build Process will terminate.

Sign in to comment.

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!