For loop outside parfor loop

2 次查看(过去 30 天)
Caleb_Holt
Caleb_Holt 2017-1-11
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by