title: Issue with parfor in Matlab; "UndefinedFunction error thrown to workers" and Matlab crashing
body: <p>I've got some code that works perfectly fine in series, but I'm trying to speed it up by putting it in parallel, and it's giving me fits in multiple places. Here's my code:</p>
  
  <pre><code>parfor q = 1:num_ranges;
      timenumber = squeeze(DATA(q,:,:));
      timenumber_shift = circshift(timenumber, [0 1]);
      for m = 1:total_working_channels;
          timenumberm = timenumber(m,:);
          for n = 1:total_working_channels;
              R_P(m,n,q) = mean(timenumberm.*conj(timenumber(n,:)),2);
              R_V(m,n,q) = mean(timenumberm.*conj(timenumber_shift(n,:)),2);
          end
      end
  end
  </code></pre>
  
  <p>DATA is a complex double of size 1716x32x400. When I try running it like this, Matlab just crashes ("Matlab has encountered an internal problem and needs to close"). Is the array too big to be sent? I have a feeling that that's the issue, but I'm not sure.</p>
  
  <p>To get around that, I've tried changing the location of the parfor command; here's attempt #2:</p>
  
  <pre><code>for q = 1:num_ranges;
      timenumber = squeeze(DATA(q,:,:));
      timenumber_shift = circshift(timenumber, [0 1]);
      parfor m = 1:total_working_channels; %this is line 145!
          timenumberm = timenumber(m,:);
          for n = 1:total_working_channels;
              R_P(m,n,q) = mean(timenumberm.*conj(timenumber(n,:)),2);
              R_V(m,n,q) = mean(timenumberm.*conj(timenumber_shift(n,:)),2);
          end
      end
  end
  </code></pre>
  
  <p>When I do this, Matlab doesn't crash. However, in the command line, it says "Analyzing and transferring files to workers...done.", followed by an error. Here's the error message:</p>
  
  <p>Error using DBFCode12 (line 145). An UndefinedFunction error was thrown on the workers for ''. This might be because the file containing '' is not accessible on the
  workers.  Use addAttachedFiles(pool, files) to specify the required files to be attached.  See the documentation for
  'parallel.Pool/addAttachedFiles' for more details. Caused by: Undefined function or variable "".</p>
  
  <p>I'm pretty well stumped on this one. Why is it saying there's an undefined function (with no name!) on the parfor line?</p>
  
  <p>I'm using version R2014a.</p>