For loop outside parfor loop
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!