Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Early exit from parfor loop?
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
spasmous

Posts: 303
Registered: 12/10/05
Early exit from parfor loop?
Posted: Apr 12, 2012 5:39 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I am looping over N files in a filesystem looking for M files with a
certain property. Sometimes they are found early and I can exit the
loop, however when using parfor there is no easy way to do this.

E.g. consider this code:

mydir = dir;
N = numel(dir);
myfiles = {}; % store filenames that pass <test>

parfor j = 1:N

if <test>
myfiles{j} = mydir(j);
end

end

The result is a cell array with some non-empty elements. This searches
all N files but if I want it to stop when it finds M=2 files, there
doesn't seem to be a way. This is probably well known behavior, but
I'm posting just in case anyone has a workaround... :)



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.