title: Find indices in a 3D matrix
body: <p>I have 2 3D matrices:</p>
  
  <pre><code>A=[19,18,17;16,15,14;13,12,11];
  
  A(:,:,2)=[9,8,7;6,5,4;3,2,1];
  
  B=sort(A,3);
  </code></pre>
  
  <p>With output</p>
  
  <pre><code>A(:,:,1) =
  
  
  19 18 17
  
  16 15 14
  
  13 12 11
  
  
  A(:,:,2) =
  
  
  9 8 7
  
  6 5 4
  
  3 2 1
  
  
  B(:,:,1) =
  
  
  9 8 7
  
  6 5 4
  
  3 2 1
  
  
  B(:,:,2) =
  
  
  19 18 17
  
  16 15 14
  
  13 12 11
  </code></pre>
  
  <p>and I want to find the 3rd coordinate of one of the matrices of <code>B</code> in <code>A</code>.</p>
  
  <p>so</p>
  
  <pre><code>find(A==B(:,:,1))
  </code></pre>
  
  <p>the answer is</p>
  
  <pre><code>ans =
  
  
  
  10
  
  11
  
  12
  
  13
  
  14
  
  15
  
  16
  
  17
  
  18
  </code></pre>
  
  <p>However, I want the answer to be <code>2</code>, because this matrix is in the second position in the third dimension of <code>A</code>: <code>A(:,:,2)</code></p>
  
  <p>How do I do this?</p>
  
  <p>I tried <code>find(A(~,~,:)==B(:,:,1))</code> but that gave an error.</p>