Is it possible to use Simulation Data Inspector while running simulations in parallel?
8 views (last 30 days)
Show older comments
MathWorks Support Team
on 23 Jun 2021
Edited: MathWorks Support Team
on 29 Aug 2024
I have a script that uses "parsim" to sweep through a set of test cases for my model in Simulink. I have an SDI view that I would like to load for each test case and save that SDI view. I am able to create a figure of the view using the Simulink.sdi.loadView command for one test case.
I would like to load a different SDI view for each test case and save the plot from SDI.
However I'm having trouble figuring out the correct sequence of MATLAB commands to do this for all the other test cases when I simulate with "parsim", since there's no opportunity for me to run the Simulink.sdi.loadView command and save the figure during the "parsim" function while it is running.
Accepted Answer
MathWorks Support Team
on 29 Jul 2024
Edited: MathWorks Support Team
on 29 Aug 2024
Rather than opening SDI as part of the parsim workflow, we recommend saving the data and opening it in SDI once the parallel simulations are complete.The Parallel Computing Toolbox workers run a "headless" version of MATLAB (with no graphical user interface), so launching the Simulink Data Inspector in a PostSimFcn is not supported at this time.
However, it is possible to automatically open data from parsim runs in SDI once the simulations finish running, by enabling PCT support on SDI using the following command:
Simulink.sdi.enablePCTSupport('all')
This command need only be run once. If you then run your simulation in parallel 10 times, the logged signals from all 10 runs will open in SDI automatically when the whole parsim command finishes running. You can then upload new SDI views using "Simulink.sdi.loadView" and take snapshots of each run as desired.
For more information on the "enablePCTSupport" parameter, please run the below command in the command window of installed MATLAB version to get release specific documentation:
>> web(fullfile(docroot, 'simulink/slref/simulink.sdi.enablepctsupport.html'))
If you prefer not to enable PCTSupport on SDI, you can start a new SDI run after the parallel simulations finish, and upload the data from your Simulation Output. Any logged signals will be saved in a "logsout" variable within each Simulation Output.
This workflow is described in the following documentation page and code snippet adapted for your use-case: https://www.mathworks.com/help/simulink/ug/record-and-inspect-signal-data-programmatically.html#CreateARunAndViewTheDataExample-2
for i = 1:10
in(i) = Simulink.SimulationInput('modelname');
end
out = parsim(in, 'ShowProgress', 'on')
% once parsim is complete, if enablePCTSupport is on, SDI will open automatically
% otherwise, start a new SDI run:
Simulink.sdi.view
Simulink.sdi.loadView('default.mldatx'); % example only, can load a non-default view for visualizing the data
for i = 1:length(out)
parsimRun = Simulink.sdi.Run.create;
%Use the add function to add the data you created in the workspace to the empty run.
add(parsimRun,'vars', out(1,i).logsout);
end
Please follow the below link to search for the required information regarding the current release:
https://www.mathworks.com/help/0 Comments
More Answers (0)
See Also
Categories
Find more on Run Multiple Simulations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!