Use of Simulink Signal Logging and SimScape Logs with Parallel

Hi,
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?
Regards,
Jack

 Accepted Answer

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');

4 Comments

Hi Guy,
Thank you pointing in the correct direction.
I can now successfully extract the Simulink signal log 'logsout' from parallel simulations.
However, I am still having trouble extracting the SimScape log 'simlog'. It does not appear as a field of my single output variable 'simout' (as 'logsout' does). Could this be a size issue due to the large number of SimHydraulics blocks in my model?
Regards,
Jack
I am sorry. I just realized there is a problem with the Simscape "simlog". It is not included in the single-output. To get it, you should be able to execute this line just after SIM:
simlogs{idx} = evalin('base', 'simlog');
Is there a way to save simlog to a file like a mat file? This is not related to using the parallel toolbox but this seems like the right place to ask this question. Thanks, Aditya
If you get no answers, you could post this as a new question so that it is more likely to be seen.

Sign in to comment.

More Answers (1)

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.

Asked:

on 10 Apr 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!