User`s guide

13 Real-Time Workshop Rapid Simulation Target
13-10
incorrect simulation results. In this case, where model structure has changed,
you must regenerate the code for the model.
The
rsim target allows you to alter any model parameter (of type double)
including parameters that include side-effects functions. An example of a
side-effects function is a simple Gain block that includes the following
parameter entry in a dialog box:
gain value: 2 * a
In general, the Real-Time Workshop evaluates side-effects functions prior to
generating code. The generated code for this example retains only one memory
location entry, and the dependence on parameter
a is no longer visible in the
generated code. The
rsim target overcomes the problem of handling side-effects
functions by replacing the entire parameter structure,
rtP. You must create
this new structure by using
rsimgetrtp.m. and then save it in a MAT-file. For
the
rsimtfdemo example, type
zeta = .2;
myrtp = rsimgetrtp(‘modelname’);
save myparamfile myrtp;
at the MATLAB prompt.
In turn,
rsim can read the MAT-file and replace the entire rtP structure
whenever you need to change one or more parameters — without recompiling
theentiremodel.
For example, assume that you have changed one or more parameters in your
model, generated the new
rtP vector, and saved rtP to a new MAT-file called
myparamfile.mat.Inordertorunthesamersimtfdemo model and use these
new parameter values, execute the model by typing:
!rsimtfdemo -p myparamfile.mat
load rsimtfdemo
plot(rt_yout)
Note that the p is lower-case and represents “Parameter file.”