Running sequential simulations in a simulink model

4 views (last 30 days)
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?

Answers (1)

Ryan G
Ryan G on 21 Aug 2012
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 Comments
K E
K E on 21 Aug 2012
Edited: K E on 21 Aug 2012
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 on 22 Aug 2012
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.

Sign in to comment.

Categories

Find more on Event Functions in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!