MATLAB: Run a Simulink model N-times and store the output of each run

monte-carlo simulationsimulink

In order to do a Monte Carlo simulation, I want to run a simulink model (containing a random generator) N-times and store the output of each run. After N runs, I want to take the RMS value of these runs and plot this result. I think I have to use a 'for' loop, but i'm not sure what the rest of the matlab code has to look like?

Best Answer

Hello,
Something like the following will do.
for i = 1:N
sim(ModelName);
save(['result' num2str(i)])
end
Hope it helps.