Skip to content
Snippets Groups Projects
Commit 3f928c36 authored by William Stonewall Monroe's avatar William Stonewall Monroe
Browse files

Initial commit of an example displaying the use of parfor in matlab.

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)
parent 930d911e
No related branches found
No related tags found
No related merge requests found
% 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
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment