MATLAB Answers

Run a simulation repeatedly for certain times..

3 ビュー (過去 30 日間)
FG
FG 2020 年 3 月 11 日
コメント済み: FG 2020 年 3 月 11 日
Hi all.. I want to run a simulation repeatedly for certain times with different parameters at each. I have a code as an m file and I can share. Can anyone help me about that ?

  0 件のコメント

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

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 3 月 11 日
This link shows the MATLAB's build-in features to run several simulations: https://www.mathworks.com/help/simulink/ug/introduction_bvnw33f.html. If you have parallel computing toolbox, then they can run in parallel. However, the setup can be a bit involved, check here for example: https://www.mathworks.com/help/simulink/ug/example-of-parallel-simulations-workflow.html
If you want a simple solution, you can write a for loop and use sim function to run several simulations
for i=1:10
% change parameters
sim('model_name')
end
model_name.slx is the same of the simulink model.

  3 件のコメント

FG
FG 2020 年 3 月 11 日
Thanx Ameer.. Would you tell me how could I change for example the active power of a Three Phase Parallel RLC Load that's in simulink library from an m-file ?
Ameer Hamza
Ameer Hamza 2020 年 3 月 11 日
You define a variable in MATLAB workspace, for example
power = 1000;
then in the simulink block, write the name of the variable (power) in the Active power field. When you change the value of power inside for loop, the next simulation will read that value and simulate accordingly. Similarly, you can change other parameters.
FG
FG 2020 年 3 月 11 日
Thnx friend.. I'll let you know when I get it done : )

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

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by