MATLAB #ParallelComputing

Simple Introduction

In MATLAB we just need to use ‘parfor’ to realize parallel computing. Here is a simple example

1
2
3
4
5
6
7
poolnum=10; % numbers of kernels
kernum=parpool(poolnum)
parfor l=1:numloop
%do something here
end
delete(kernum)
%the delete step is very important because in cluster we may use more than a dozen cores.If we stop the program directly without closing the parallel pool, the cluster may crash or take a long time to become normal.