Products & Services Solutions Academia Support User Community Company

Learn more about SimEvents   

Varying Parameters Between Simulation Runs Using MATLAB Code

Objective

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.

Procedure

Use a MATLAB program to run simulations repeatedly. A typical procedure is:

  1. 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 ResultDesign Step
    Event-based signalConnect a Discrete Event Signal to Workspace block to the signal line.
    Time-based signalConnect a To Workspace block to the signal line.

  2. (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.

      Alternative   If you want to vary values but do not perform this step, you can use se_randomizeseeds or set_param commands in step 4 of this procedure.

  3. (Optional): Remove plotting and Display blocks to increase simulation speed. When running simulations unattended, you are not viewing plots or displays.

  4. 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.

See Also

  


Free Discrete Event Simulation Technical Kit

Model electronic system architectures, process flows, and logistics as queuing systems or agent-based systems.

Get free kit

Trials Available

Try the latest version of discrete-event simulation products.

Get trial software
 © 1984-2010- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS