Parfor Step
    8 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
I am attempting to run a ParFor statement with a step function and Matlab is giving me an error "The range of a parfor statement must be increasing consecutive integers. See Parallel Computing Toolbox, "parfor"." I'm wondering if this is possible or if I have to do some manipulation to my loop to get this to work in parallel. Would someone be able to make a suggestion as to how to modify one of these loops so that it will work in parallel?
Simplified Example
      parfor (i = 1:10:75,8)
          test3(i)= i*3;
      end
Real Example
parfor (i = 1:10:75,8)
    tic
    recnum = min(i+9,length(test));
    datainsert(conn,'dbo.tbl_FactorExposure_Security',{'CUSIP','MktDate','Factor_Exp','Factor_Num'},MyData(i:recnum,:));
    disp(i)
    toc
end
Thanks a lot! Brian
2 commentaires
  Walter Roberson
      
      
 le 11 Juin 2012
				Sorry? What do you intend
for (i = 1:10:75,8)
to mean? Is it intended as 
for i = [1:10:75, 8]
meaning
for i = [1 11 21 31 41 51 61 71 8]
?
Réponse acceptée
  Edric Ellis
    
      
 le 12 Juin 2012
        As the doc states, PARFOR needs to work with unit-step ranges. So you do need to re-work the loop slightly, something like this:
   idx = 1:10:75;
   parfor (i = 1:numel(idx), 8)
     val = idx(i);
     test3t(i) = val * 3;
   end
That example leaves 'test3t' slightly different to 'test3' in your example, you can rearrange things by doing
test3(idx) = test3t;
2 commentaires
  Edric Ellis
    
      
 le 12 Juin 2012
				By the way, the syntax using the extra parentheses around the PARFOR arguments is rarely needed, it's much simpler just to write "parfor i = 1:numel(idx)".
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange
			
	Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


