title: How do I create a parallel loop?
body: <p>You'd think this would be simple question, but I can't find the solution. Take the following loop:</p>
  
  <pre><code>A = zeros(1,10000000);
  parfor i = 1:length(A)
      A(i) = i;
  end
  </code></pre>
  
  <p>This only runs on a single core on my computer, although it's readily parallelisable (or at least it should be). I am using Matlab 2012b, and I've tried looking for documentation on how to create parallel loops but can't find any (the matlab docs just show examples of how to create these loops, not how to actually run them in parallel).</p>
  
  <p>I've tried looking up how to modify parallel computing toolbox settings, but none of them work since they're all for Matlab 2013 (I'm using 2012b). If someone could provide an example of a trivial, parallelisable loop that <em>actually runs in parallel</em> I would be very grateful!</p>
  
  <p>Note: I have checked and the parallel computing toolbox is installed, although I have no way of knowing if it is enabled, or how to enable it, since the documentation doesn't seem to provide an answer to this for my version (I typed <code>preferences</code> into the command prompt but didn't see it there).</p>
  
  <p>EDIT: I got it working by doing this:</p>
  
  <pre><code>matlabpool('open',4);
  A = zeros(1,10000000);
  parfor i = 1:length(A)
      A(i) = i;
  end
  matlabpool('close');
  </code></pre>
  
  <p>... but I don't really know why this works, whether I have close the pool every time, what a pool actually is (I've read the <a href="http://www.mathworks.com.au/help/distcomp/parpool.html">documnentation</a>, still don't get it), and how <code>matlabpool</code> differs from <code>parpool</code>...</p>