For loop outside parfor loop

2 vues (au cours des 30 derniers jours)
Caleb_Holt
Caleb_Holt le 11 Jan 2017
I would like to run a big parameter sweep, and save out chunks of every 100 parameter runs or so. So I thought to do this using a for loop outside of parfor loop- the for loop counts over the number of chunks there are, while the parfor loop runs the 100 individual parameters in the chunk. For example
function Outputs = ParameterSweep(start, stop)
parameterTotal = stop - start
chunks = round(parameterTotal/100) %So far I have only given start and stop differences that are divisible by 100
runs = parameterTotal/chunks
for runind = 1:runs
parameterStart = start + (runind-1)*chunk
parameterStop = start + runind*chunk
parfor parameterStart:parameterStop
%do calculation here
end
fname = num2str(runind)
save(fname)
end
end

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by