Array of SimulationInput objects gets modified upon running with sim command
I am creating an array of SimulationInput objects, ‘simIn’. If I try to run a single simulation, for example using simOut(1) = sim(simIn(1)) to run the first case, why does simIn lose all other array elementes. It changes to a 1×1 SimulationInput object, whereas before the sim command it was a 1×28 object
for casenumber = 1:NumFile
if ~isempty(char(file{FileIdx(casenumber),1}))
if exist(strrep(char(file{FileIdx(casenumber),1}), ‘;’, ”), ‘file’)
%% Setup parallel Simulation
simIn(casenumber)=Simulink.SimulationInput(‘XWB_MSL_EEC’);
simIn(casenumber) = simIn(casenumber).setVariable(‘Experiment’,Experiment);
simIn(casenumber) = simIn(casenumber).setVariable(‘Enable_MSL_Validation_Logging’,Enable_MSL_Validation_Logging);
simIn(casenumber) = simIn(casenumber).setVariable(‘SimStartTime’,0);
simIn(casenumber) = simIn(casenumber).setVariable(‘TimeMode1’,TimeMode1);
simIn(casenumber) = simIn(casenumber).setVariable(‘TimeMode2’,TimeMode2);
simIn(casenumber) = simIn(casenumber).setVariable(‘parallel_casenumber’,casenumber);
simIn(casenumber) = simIn(casenumber).setVariable(‘ModelPath’,ModelPath);
simIn(casenumber) = simIn(casenumber).setVariable(‘toolGitStatus’,toolGitStatus);
simIn(casenumber) = simIn(casenumber).setVariable(‘configGitStatus’,configGitStatus);
simIn(casenumber) = simIn(casenumber).setVariable(‘toolConfigVersion’,toolConfigVersion);
simIn(casenumber) = simIn(casenumber).setVariable(‘configGitInfo’,configGitInfo);
simIn(casenumber) = simIn(casenumber).setVariable(‘switchBatchMode’,switchBatchMode);
simIn(casenumber) = simIn(casenumber).setVariable(‘resultsDir’,resultsDir);
simIn(casenumber) = simIn(casenumber).setVariable(‘switchExportDataToPhobos’,switchExportDataToPhobos);
if ~isempty(Suffix)
simIn(casenumber) = simIn(casenumber).setVariable(‘CurveName’,sprintf(‘%s_%s’,file{FileIdx(casenumber),1},Suffix));
else
simIn(casenumber) = simIn(casenumber).setVariable(‘CurveName’,file{FileIdx(casenumber),1});
end
% Use a temporary variable for the SimIn element to avoid runaway memory usage when using a preSimFcn with parsim
tmpSimIn = simIn(casenumber);
preSimFcnInputs = {file{FileIdx(casenumber)}, tmpSimIn};
simIn(casenumber)=simIn(casenumber).setPreSimFcn(@(x) parsimMSLPreSimFcn(preSimFcnInputs));
simIn(casenumber) = simIn(casenumber).setPostSimFcn(@(y) parsimMSLPostSimFcn(y, tmpSimIn));
else
error([‘Could not find Case "’,strrep(char(file{FileIdx(casenumber),1}), ‘;’, ”),’"!’])
end
end
endI am creating an array of SimulationInput objects, ‘simIn’. If I try to run a single simulation, for example using simOut(1) = sim(simIn(1)) to run the first case, why does simIn lose all other array elementes. It changes to a 1×1 SimulationInput object, whereas before the sim command it was a 1×28 object
for casenumber = 1:NumFile
if ~isempty(char(file{FileIdx(casenumber),1}))
if exist(strrep(char(file{FileIdx(casenumber),1}), ‘;’, ”), ‘file’)
%% Setup parallel Simulation
simIn(casenumber)=Simulink.SimulationInput(‘XWB_MSL_EEC’);
simIn(casenumber) = simIn(casenumber).setVariable(‘Experiment’,Experiment);
simIn(casenumber) = simIn(casenumber).setVariable(‘Enable_MSL_Validation_Logging’,Enable_MSL_Validation_Logging);
simIn(casenumber) = simIn(casenumber).setVariable(‘SimStartTime’,0);
simIn(casenumber) = simIn(casenumber).setVariable(‘TimeMode1’,TimeMode1);
simIn(casenumber) = simIn(casenumber).setVariable(‘TimeMode2’,TimeMode2);
simIn(casenumber) = simIn(casenumber).setVariable(‘parallel_casenumber’,casenumber);
simIn(casenumber) = simIn(casenumber).setVariable(‘ModelPath’,ModelPath);
simIn(casenumber) = simIn(casenumber).setVariable(‘toolGitStatus’,toolGitStatus);
simIn(casenumber) = simIn(casenumber).setVariable(‘configGitStatus’,configGitStatus);
simIn(casenumber) = simIn(casenumber).setVariable(‘toolConfigVersion’,toolConfigVersion);
simIn(casenumber) = simIn(casenumber).setVariable(‘configGitInfo’,configGitInfo);
simIn(casenumber) = simIn(casenumber).setVariable(‘switchBatchMode’,switchBatchMode);
simIn(casenumber) = simIn(casenumber).setVariable(‘resultsDir’,resultsDir);
simIn(casenumber) = simIn(casenumber).setVariable(‘switchExportDataToPhobos’,switchExportDataToPhobos);
if ~isempty(Suffix)
simIn(casenumber) = simIn(casenumber).setVariable(‘CurveName’,sprintf(‘%s_%s’,file{FileIdx(casenumber),1},Suffix));
else
simIn(casenumber) = simIn(casenumber).setVariable(‘CurveName’,file{FileIdx(casenumber),1});
end
% Use a temporary variable for the SimIn element to avoid runaway memory usage when using a preSimFcn with parsim
tmpSimIn = simIn(casenumber);
preSimFcnInputs = {file{FileIdx(casenumber)}, tmpSimIn};
simIn(casenumber)=simIn(casenumber).setPreSimFcn(@(x) parsimMSLPreSimFcn(preSimFcnInputs));
simIn(casenumber) = simIn(casenumber).setPostSimFcn(@(y) parsimMSLPostSimFcn(y, tmpSimIn));
else
error([‘Could not find Case "’,strrep(char(file{FileIdx(casenumber),1}), ‘;’, ”),’"!’])
end
end
end I am creating an array of SimulationInput objects, ‘simIn’. If I try to run a single simulation, for example using simOut(1) = sim(simIn(1)) to run the first case, why does simIn lose all other array elementes. It changes to a 1×1 SimulationInput object, whereas before the sim command it was a 1×28 object
for casenumber = 1:NumFile
if ~isempty(char(file{FileIdx(casenumber),1}))
if exist(strrep(char(file{FileIdx(casenumber),1}), ‘;’, ”), ‘file’)
%% Setup parallel Simulation
simIn(casenumber)=Simulink.SimulationInput(‘XWB_MSL_EEC’);
simIn(casenumber) = simIn(casenumber).setVariable(‘Experiment’,Experiment);
simIn(casenumber) = simIn(casenumber).setVariable(‘Enable_MSL_Validation_Logging’,Enable_MSL_Validation_Logging);
simIn(casenumber) = simIn(casenumber).setVariable(‘SimStartTime’,0);
simIn(casenumber) = simIn(casenumber).setVariable(‘TimeMode1’,TimeMode1);
simIn(casenumber) = simIn(casenumber).setVariable(‘TimeMode2’,TimeMode2);
simIn(casenumber) = simIn(casenumber).setVariable(‘parallel_casenumber’,casenumber);
simIn(casenumber) = simIn(casenumber).setVariable(‘ModelPath’,ModelPath);
simIn(casenumber) = simIn(casenumber).setVariable(‘toolGitStatus’,toolGitStatus);
simIn(casenumber) = simIn(casenumber).setVariable(‘configGitStatus’,configGitStatus);
simIn(casenumber) = simIn(casenumber).setVariable(‘toolConfigVersion’,toolConfigVersion);
simIn(casenumber) = simIn(casenumber).setVariable(‘configGitInfo’,configGitInfo);
simIn(casenumber) = simIn(casenumber).setVariable(‘switchBatchMode’,switchBatchMode);
simIn(casenumber) = simIn(casenumber).setVariable(‘resultsDir’,resultsDir);
simIn(casenumber) = simIn(casenumber).setVariable(‘switchExportDataToPhobos’,switchExportDataToPhobos);
if ~isempty(Suffix)
simIn(casenumber) = simIn(casenumber).setVariable(‘CurveName’,sprintf(‘%s_%s’,file{FileIdx(casenumber),1},Suffix));
else
simIn(casenumber) = simIn(casenumber).setVariable(‘CurveName’,file{FileIdx(casenumber),1});
end
% Use a temporary variable for the SimIn element to avoid runaway memory usage when using a preSimFcn with parsim
tmpSimIn = simIn(casenumber);
preSimFcnInputs = {file{FileIdx(casenumber)}, tmpSimIn};
simIn(casenumber)=simIn(casenumber).setPreSimFcn(@(x) parsimMSLPreSimFcn(preSimFcnInputs));
simIn(casenumber) = simIn(casenumber).setPostSimFcn(@(y) parsimMSLPostSimFcn(y, tmpSimIn));
else
error([‘Could not find Case "’,strrep(char(file{FileIdx(casenumber),1}), ‘;’, ”),’"!’])
end
end
end simulink MATLAB Answers — New Questions