MATLAB Answers

How to use parallel processing with varying internal variable

1 view (last 30 days)
Shashi
Shashi on 5 Dec 2013
Edited: Matt J on 5 Dec 2013
This is a simple code, i am uploading for illustration. Can somebody suggest how to use all the four cores of a system with varying internal variables, as given in the code below:
b = 2; bi = zeros(10,1);
matlabpool open
parfor i = 1:100 %#ok<PFUNK>
a(i) = b+ bi(i);
b(i+1) = a(i);
end
matlabpool close
Regards

  0 Comments

Sign in to comment.

Answers (1)

Matt J
Matt J on 5 Dec 2013
Edited: Matt J on 5 Dec 2013
The first thing would be to re-express the body of the loop as something parallelizable, in your case
parfor i = 1:100
a(i) = b*i;
end

  0 Comments

Sign in to comment.

Sign in to answer this question.