m=1209;
n =1000;
imgf = zeros(m,n);
parfor i = 1:m-n
for j = 1:m-n
imgf(i,j) = 100;
end
end
disp(['m-n version',string(imgf(1,1))]);
m=1209;
n =1000;
imgf = zeros(m,n);
k1 = m-n;
k2 = m-n;
parfor i = 1:k1
for j = 1:k2
imgf(i,j) = 100;
end
end
disp(['k=m-n version ',string(imgf(1,1))]);
上述代码中,parfor是使用CPU并行计算实现程序计算
在matlab2018b中
在matlab 2022b中,如下