Running sequential simulations in a simulink model

8 次查看(过去 30 天)
I have a simulink model with a set of about 10 parameters. I also have a set of about 15 different sets of parameters, I am trying to design some form of script that will run the model on the first set of parameters, then the next, etc until it runs the last set of parameters and halts. However, I'm not really sure were to start with this, does anyone have any ideas?

回答(1 个)

Ryan G
Ryan G 2012-8-21
It sounds like you are trying to do parameter sweeps. You can utilize functions such as set_param to change between runs and then utilize the sim command to run and collect data inside a for loop.
  2 个评论
K E
K E 2012-8-21
编辑:K E 2012-8-21
Oliver, there is an example of a parameter sweep at the very end of this tutorial. See also 'Simulating from the MATLAB Command Line' in this tutorial. You may want to use the function allcomb.m to generate all the combinations of parameters, for example if you want to run some parallel simulations, see here. If you have the Parallel Processing toolbox and want to speed up your parameter sweeps, note that you can't nest the loops, so allcomb may be useful. I wish Simulink had some kind of built-in GUIs to make running and saving output from extensive parameter sweeps easier for beginners (like me).
Oliver McEnteggart
Oliver McEnteggart 2012-8-22
Thank you both for the information. I realise I was a bit ambiguous with some of my wording when I was talking about parameters I didn't mean things such as gain, ODE solver etc. What I was referring to are constant blocks whose values are defined in the model or base workspace i.e. something like spring stiffness.
So effectively I already have the code that sets the values of theses 'constants' but what I am looking for is a way of incorporating these different sets of code into one script that will run the model once with each set of constants.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Event Functions 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by