Pergunta

Anyone have an idea why this isn't working? I'm trying to run a parfor loop. I can do the exact same code using a simple for loop, but I need to use this with the parfor for a massive dataset.

parfor n = [1:rows]

   MeanIV(n,1) = mean([LastIV(n,1); BidIV(n,1);AskIV(n,1)])

   if isnan(MeanIV(n)) == 1    
      SubIV = dated.IV(n)    
      MeanIV(n,1) = SubIV    
   else    
      MeanIV(n,1) = mean([LastIV(n,1); BidIV(n,1);AskIV(n,1)])    
   end 

   dated.MeanIV = double(MeanIV)

end

I get this error " The variable MeanIV in a parfor cannot be classified."

Foi útil?

Solução

It is most likely the line

dated.MeanIV = double(MeanIV)

that is the problem.

parfor will try to "slice" MeanIV, i.e. send individual rows to different workers. However, at the dated line, you need the entirety of the array.

Move the line after the end of the parfor loop, and it will work.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top