Borrar filtros
Borrar filtros

How to iterate through every combination of user's choice of parameters?

4 visualizaciones (últimos 30 días)
I am scripting a parameter study in which the user identifies model parameters to vary as well as that parameter's values, for example:
parameterList(1).name = 'patientWeight' ;
parameterList(1).value = 100:25:300 ;
parameterList(2).name = 'dosage' ;
parameterList(2).value = 1000:1000:50000 ;
I want to perform a model run for all combinations of parameter values. Iterating is easy if the chosen parameters are the same for each study:
for iWeight = 1:length(parameterList(1).value)
for iDosage = 1:length(parameterList(2).value)
% Perform simulation and save results
end
end
But here the parameters and their values differ each time the script is run (next time, user might specify 'patientAge', 'numberOfDoses', and 'yearsOfTreatment'). How do I generate all combinations of parameters values from a changing list? (Would eventually like to use the parallel processing toolbox, if that is relevant.)

Respuestas (1)

K E
K E el 5 de Abr. de 2012
From the file exchange, allcomb works perfectly:
allcomb(parameterList.value)
And I learned that I was looking for a 'cartesian product'.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by