I’m trying to run a design study (Simulink model) with 2 parameters (par1,par2) sweep. I’d like it to be exhaustive in terms that 1st value/variant of par1 is run against each value/variant of par2, then 2nd value of par1 runs against each value of par1 and so on till all combinations are simulated.
I’d like to run it programmatically creating Simulationinput and using
simOut=sim(simIn).
I have no problem creating Simulationinput object if I’m using only one parameter to sweep through:
Par1_sweep = [6000 7000 8000 10000 11000 12000]
numSims = numel(Par1_sweep);
simIn(1:numSims) = Simulink.SimulationInput(Mdl);
simIn(idx) = simIn(idx).setBlockParameter(Mdl '/MyBlock',...
'Par1', num2str(Cr_sweep(idx)))
simOut = sim(simIn,'ShowSimulationManager','on','ShowProgress','on')
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
The above sentence in red was created when I accidentally clicked "Run". The above code works perfectly well.
Problem is that if I want to add Par2 sweep, I can’t figure out how to properly create simIn
Par1_sweep=[6000 7000 8000]
Par2_sweep=[10000 11000 12000 13000]
numSims = numel(Cr_sweep).*numel(Par2_sweep);
simIn(1:numSims) = Simulink.SimulationInput(Mdl);
simIn(idx) = simIn(idx).setBlockParameter(mdl'/MyBlock',...
'Par1', num2str(Par1_sweep(idx)),setBlockParameter(mdl'/MyBlock', 'Par2', num2str(Par2_sweep(idx)))
Above doesn’t work in terms that it doesn’t create desired simIn array. Any advise on how this should be properly written so that I get exhaustive study of Par1 and Par2 variants is highly appreciated.
Thank you.
Ted