For loop outside parfor loop

2 visualizzazioni (ultimi 30 giorni)
Caleb_Holt
Caleb_Holt il 11 Gen 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

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by