我是靠谱客的博主 故意小松鼠,最近开发中收集的这篇文章主要介绍MATLAB 并行for运算 - ParforExecute Loop Iterations in Parallel - Parfor,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Memo for MATLAB Parfor.

Execute Loop Iterations in Parallel - Parfor

Main Steps

Step1. Initialization

numCores: number of cores used in loop iterations

%Close the pools, if any
try
fprintf('Closing any pools...n');
parpool close;
catch
%ignore any errors 
end
fprintf('Starting a pool of workers with %d coresn', numCores);
parpool('local',numCores);

Step2. Execution

%matlab can't save/load inside parfor
%accumulate them and then save
parfor i = 1:N
f(i);
end

Step3. Closing

%close the pool
fprintf('Closing the pooln');
parpool close;

References:

  1. Execute loop iterations in parallel - Parfor
  2. MATLAB并行:parfor

最后

以上就是故意小松鼠为你收集整理的MATLAB 并行for运算 - ParforExecute Loop Iterations in Parallel - Parfor的全部内容,希望文章能够帮你解决MATLAB 并行for运算 - ParforExecute Loop Iterations in Parallel - Parfor所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(80)

评论列表共有 0 条评论

立即
投稿
返回
顶部