Create Scripts for Batch and Monte Carlo Simulations
The RSim target is for batch simulations in which parameters and input signals vary for
multiple simulations. New output file names allow you to run new simulations without
overwriting prior simulation results. You can set up a series of simulations to run by
creating a .bat
file for use on a Microsoft®
Windows® platform.
Create a file for the Windows platform with a text editor and execute it by typing the file name, for
example, mybatch
, where the name of the text file is
mybatch.bat
.
rapidsim -f rapidsim.mat=run1.mat -o results1.mat -tf 10.0 rapidsim -f rapidsim.mat=run2.mat -o results2.mat -tf 10.0 rapidsim -f rapidsim.mat=run3.mat -o results3.mat -tf 10.0 rapidsim -f rapidsim.mat=run4.mat -o results4.mat -tf 10.0
In this case, batch simulations run using four sets of input data in files
run1.mat
, run2.mat
, and so on. The RSim executable
program saves the data to the files specified with the -o
option.
The variable names containing simulation results in each of the files are identical. Therefore, loading consecutive sets of data without renaming the data once it is in the MATLAB® workspace results in overwriting the prior workspace variable with new data. To avoid overwriting, you can copy the result to a new MATLAB variable before loading the next set of data.
You can also write MATLAB scripts to create new signals and new parameter structures, as well as to save
data and perform batch runs using the bang command (!
).
For details on running simulations and available command-line options, see Run Rapid Simulations. For an example of a rapid simulation batch script, see the example Run Batch Simulations Without Recompiling Generated Code.