I've recently started using the Parallel Computing Toolbox for running parallel simulations in Simulink (including SimScape). Previously I was utilising the Simulink signal logging option and SimScape logging option to log simulation data to two log objects (nominally logsout for Simulink and simlog for SimScape). The examples, including a demo model, for parallel simulations in Simulink only seem to show how to extract the model output and time trace ( yout and tout) from the workers. I cannot figure out how to extract the simulations logs from the workers. I imagine there is a way to route all signal data to the model output, and extract the data from there, however my model is multi-domain with a significant amount of physical modelling blocks (SimHydraulics) and I would like to be able to access the Simulink and SimScape logs from parallel runs.
Can anybody help me with this issue?
No products are associated with this question.
The following documentation page explain how to use the Single-Output Syntax for the sim Command:
This single-output syntax has been designed especially for calling SIM within PARFOR.
using that, you will call sim:
SimOut = sim('model', 'ReturnWorkspaceOutputs', 'on');
and everything will be stored in simOut. If logging both "logsout" for Simulink signals and and "simlog" for Simscape, you will be able to extract the data with a syntax like:
myVar1 = simOut.get('logsout'); myVar2 = simOut.get('simlog');
I am sure there is a better approach, but a workaround would be to save a mat file containing each simulation's results. This could be done using a Matlab script to run the set of simulations; outputting desired simulation results to the Workspace using the To Workspace block; choosing a distinct mat file name within the Matlab script; and saving the mat file. A post-processing script could load all the mat files, for example to plot engine temperature vs. motor constant (if that was what was varying across the simulations). As a cheat with no Parallel toolbox, prior to each simulation create the uniquely named mat file that will contain the results, for example saving some dummy information. Then do not run the simulation if the file already exists. This allows several concurrent sessions of matlab/simulation to work through the set of simulations.