Why is my simulation signal logging output is empty in parfor loop (but not in for loop)?
11 views (last 30 days)
I am running a simulation in Rapid Accelerator mode with the intention of running it in a parfor loop. I am running MATLAB r2015a (64 bit) on Windows 7.
Following the Simulink documentation for rapid simulation in a parfor loop, I build the model with
rtp = Simulink.BlockDiagram.buildRapidAcceleratorTarget(myModel);
Then I duplicate rtp with repmat and alter the relevant parameters in each.
rtp = repmat(rtp,numRuns,1);
for ii = 1:numRuns
% Change the parameters in rtp(ii)
I run the model with the sim command inside the loop
(par)for ii = 1:numRuns
simout = sim(myModel,'SimulationMode','rapid',...
logsout = simout.get('logsout')
% Do some analysis on the data in logsout
If I use a for loop, logsout is the Simulink.SimulationData.Dataset that I expect. If I use a parfor loop, logsout is an empty array.
I don't have a model I can share that duplicates this behavior, and the documentation doesn't mention it so I expect it doesn't happen for all models. Have other users experienced this? Is there something I should have set to allow signal logging in the parfor loop?
Walter Roberson on 17 May 2016
You need to index logsout by your loop control variable for MATLAB to recognize that it is a sliced output variable.
Tanguy on 1 Jun 2017
Edited: Tanguy on 1 Jun 2017
I had the exact same bug (empty output in parfor loop). It appeared that parfor loop doesn't use the same pathdef than for loop... And a buggy function in shadow was used instead (two functions with the exact same name in my Matlab path). I had this bug with Matlab R2016b . linux.
Hope it can help