title: Convert nested for loop using ismember to match columns of two arrays into a parfor loop
body: <p>I have the following nested for loop that uses <code>ismember</code> to identify the locations where two arrays have the same value. I am doing this so that I can find the data associated with my smaller array <code>tp</code> (see below).</p>
  
  <pre><code>% xw is a 1xM array of position data
  % yw is a 1xN ...
  % zw is a 1xP ...
  TP = combvec(xw',yw',zw')';    % you must have the deep learning toolbox to use this for the latest version of Matlab 2018b
  in = inpolyhedron(f,v,TP);     % I would have done inpolyhedron(f,v,Xw,Yw,Zw) where Xw, Yw, and Zw are meshgrids from xw, yw, and zw but doing so exceeds the maximum array size in MatLab.
  tp = TP(in,:);  Ltp = length(tp);
  in3 = zeros(N,M,P);
  
  for l=1:Ltp
     for ii=1:M
        for jj=1:N
           for kk=1:P
               if ismember(tp(l,:),TP,'rows')
                  in3(jj,ii,kk) = ismember(tp(l,:),TP,'rows');
               end
           end
        end
     end
  end
  
  a = A(in3);     % A is a NxMxP array
  % a should also be a NxMxP array with the majority of the points being zero, and the points corresponding to tp should be non-zero.
  </code></pre>
  
  <p>I tried applying what was described <a href="https://stackoverflow.com/questions/13444745/converting-nested-for-loops-to-parfor-loop-matlab">here</a> but I'm not sure how to make it work because I am using <code>ismember</code> and because I'm filling a 3D array.</p>
  
  <p>This works fine using a <code>for</code> loop but I'd like to make the process faster and I think a <code>parfor</code> loop is the best option.</p>