| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimEvents |
| Contents | Index |
| Learn more about SimEvents |
| On this page… |
|---|
For parameter sweeps or Monte Carlo analysis, you can vary or tune parameters from one simulation run to the next. Following is a procedure that you can use in the MATLAB environment to vary parameters between simulation runs. Alternatively, to vary parameters between runs of a rapid simulation executable, see Varying Parameters Between Rapid Simulation Runs.
Use a MATLAB program to run simulations repeatedly. A typical procedure is:
Design your model so that in the MATLAB workspace, it records the signals that represent relevant simulation results. These signals are the results that you want to save or analyze after running the simulation.
| Simulation Result | Design Step |
|---|---|
| Event-based signal | Connect a Discrete Event Signal to Workspace block to the signal line. |
| Time-based signal | Connect a To Workspace block to the signal line. |
(Optional): Design the model to accepts values of the parameters that you want to provide or vary when you run the simulation. In the block dialog box, set the value to the name of a variable. In step 4 of this procedure, your code must define the variable before each simulation run.
(Optional): Remove plotting and Display blocks to increase simulation speed. When running simulations unattended, you are not viewing plots or displays.
Execute MATLAB code that runs the simulation and analyzes the results. Typical constructs include:
for loop, to repeat simulation runs.
se_randomizeseeds and se_getseeds commands, to change random number sequences between simulation runs and store the seeds for future reference. For details, see Varying Simulation Results by Managing Seeds.
set_param commands, to vary parameters or other aspects of the model between simulation runs.
sim command to run the simulation. To learn more about sim, see Running a Simulation Programmatically in the Simulink documentation.
save or array-building commands that store results from each simulation run, without overwriting results of earlier simulation runs.
![]() | Choice of Environment for Varying Parameters Between Simulation Runs | Varying Parameters Between Rapid Simulation Runs | ![]() |

Model electronic system architectures, process flows, and logistics as queuing systems or agent-based systems.
Get free kit| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |