-
William Stonewall Monroe authored
Apparently in 2018a, it is not necessary to add parpool, but it will start up the parpool when parfor is used (initializing it with 12 threads)
3f928c36
parforExample.m 384 B
% Testing number of prime numbers in a given range
final=10^7; %upper limit
close all
%clear all
tic
count=[];
ratios=[];
l=[];
out=[];
disp('Please wait.. Finding number of primes.... ')
a=0;
parfor i=1:final
c=isprime(i);
if c==1
i;
a=a+c;
end
end
a;
ratio=a/final;
l=[l,final];
count=[count,a];
ratios=[ratios,ratio];
out=[l',count',ratios'];
toc