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

27 ビュー (過去 30 日間)
omar khater
omar khater 2019 年 7 月 14 日
コメント済み: omar khater 2019 年 7 月 15 日
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.

採用された回答

Jonas
Jonas 2019 年 7 月 15 日
編集済み: Jonas 2019 年 7 月 15 日
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 件のコメント
omar khater
omar khater 2019 年 7 月 15 日
I have tried parfor loop but I have one problem.
In each loop iteration I need to update my parameters, I don't know why it flags in error that my parameters are not defined when calling simulink. It runs with i=7 and i=21 and then flags this error. I don't know why.
The solution here
reduces the time signifcantly but I have some one question
why does It run only 2 workers? Can I set it to more workers? How?
I have processor with 4 cores
cores.JPG
omar khater
omar khater 2019 年 7 月 15 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNaming Conventions についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by