You can use the 'assignin' function of MATLAB for this purpose to store the output obtained from a simulation as a unique variable in the base workspace.
A sample code can look like this:
numRuns = 20;
for i = 1:numRuns
simOut = sim('exampleModel'); % a demo model containing Uniform Random Number block
%simOut = Simulink.SimulationOutput:
%output: [1x1 timeseries] - the output name is set to 'output'; default is 'yout'
%tout: [101x1 double] ...
varName = sprintf('output_%s', num2str(i)); %varName gets unique strings every simulation run
% output_1, output_2 ... output_20
assignin('base', varName, simOut.get('output')); %register the created varName in the workspace
end
For more information on the usage of 'assignin', you can refer to the documentation of the same by executing the following command from MATLAB Command Window:
doc assignin
Thanks.
