How to make a matlab script that runs simulink model to run parallel instances of the model
Mostra commenti meno recenti
I have a working matlab script to manage the run of a simulink model. Now I would like to transform the script to run several instances of the model (with a different random seed, fors statistical purposes).
Values in Model Block Dialogs are set by using Matlab workspace, i.e., before launching
out = sim(model)
I set all of the needed params in the script.
To translate the script to run several instances in parallel where the only difference is the change of "seed" in the "Colored Noise" block, I proceeded as follow:
simIn(1:Nproc) = Simulink.SimulationInput(model);
for idx = 1:Nproc
Seed = SeedPool(idx);
simIn(idx) = simIn(idx).setVariable('Seed',num2str(Seed));
end
parallel_out = parsim(simIn);
but I got several errors and I don't understand why.
First, it looks like the variables in workspace are not available anymore to the different simIn(idx) (I get "Unrecognized function or variable ..." error). However, if I explicitly set for any simIn(idx) the said variables by, e.g.,
simIn(idx) = simIn(idx).setVariable('Delay',num2str(Delay));
and similar for the other params, I start getting very strange errors like:
- Mask parameters must be scalar values
- Invalid setting in ... for parameter ...
- Matrix dimensions must agree
After searching the doc and the web the whole day, I gave it up.
This is very frusrtating because the script works well if I perform a simulation at a time.
Any suggestion?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Simulink Functions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!