For loop outside parfor loop

2 views (last 30 days)
Caleb_Holt
Caleb_Holt on 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

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!