fill() in parfor loop

4 views (last 30 days)
seb
seb on 18 Apr 2012
I've got ~200,000 polygons to be plotted with fill().
for i=1:size(data,1);
x=data(i,3:2:9);
y=data(i,4:2:10);
f=fill(x,y,data(i,2));
hold on;
end
It works well but takes a bit of time. When I use 'matlabpool open local 4' and change 'for' to 'parfor', I've got no figure output. Any solutions please?
  1 Comment
Sean de Wolski
Sean de Wolski on 18 Apr 2012
Do you actually expect to be able to differentiate 200000 polygons?

Sign in to comment.

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 18 Apr 2012
Hi,
you should be able to call fill with the corresponding matrices directly, something like
f = fill(data(:, 3:2:9)', data(:, 4:2:10)', data(:,2)');
Titus
  2 Comments
seb
seb on 18 Apr 2012
Many thanks Titus, it's much quicker as run time is 34s:112s! I really shouldn't have abused for loops.
Titus Edelhofer
Titus Edelhofer on 19 Apr 2012
Hi Seb, your welcome. You might mark the question then as answered, if you think it is ...

Sign in to comment.

More Answers (1)

Edric Ellis
Edric Ellis on 18 Apr 2012
Unfortunately, you cannot use a PARFOR loop in this way. The workers cannot create graphics on your client.
  1 Comment
seb
seb on 18 Apr 2012
Many thanks Edric. Still wondering if there's any other way to speedup this tedious job, without parfor.

Sign in to comment.

Categories

Find more on Parallel Computing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!