Generating Exaustive Parameter Combinations
Ältere Kommentare anzeigen
Hi Everyone.
I want to create many Simulink.SimulationInput Objekts to simulate with many parameters.
To achieve this I am looking for a way to create exhaustive combinations of parameters.
I have not yet decided but thought, that structs might be usefull here. So far the Idea looks like this:
%function simIn = createSimIn(ModelName,Parameters)
% ParameterNames = fieldnames(Parameters);
% simIn(1:length(Parameters)) = Simulink.SimulationInput(ModelName);
% for i = 1:length(Parameters)
% for ii = 1:length(ParameterNames)
% simIn(i) = simIn(i).setVariable(ParameterNames(ii),Paramters(i).(ParameterNames(ii)),'Workspace',simIn(i).ModelName);
% end
% end
%end
To get this running I would need a way to create a struct with and exhaustive combination of the parameters.
Lets say I have parameters:
a = 1:5;
b= 0:0.1:0.4;
Example = struct('a',num2cell(a),'b',num2cell(b))
I would want to create a struct that contains an exhaustive combinations, for a known number of parameters and equal lengths i can do:
Example = struct('a',num2cell(sort(repmat(a,1,length(b)))), ...
'b',num2cell(repmat(b,1,length(a),1)))
But I would want to do it for an arbitrary number of parameters and arbitrary multiplicities for the parameters. Is there an easier way to do this?
2 Kommentare
Jan
am 29 Nov. 2022
What about using meshgrid or loops?
Florian Rössing
am 30 Nov. 2022
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Interactive Model Editing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!