title: Matlab product of vectors in third dimension
body: <p>I hope my problem has a very simple solution. I just can't find it:</p>
  
  <p>Assume you have two vectors (one a column vector, one a row vector) A, B:</p>
  
  <pre><code>A = [1,2,3]
  B = [4;5;6]
  </code></pre>
  
  <p>if we multiply them as follows, we get a matrix:</p>
  
  <pre><code>&gt;&gt; B*A
  ans =
   4     8    12
   5    10    15
   6    12    18
  </code></pre>
  
  <p>Now my problem is: I have two 3D matrices of sizes <code>m ×  n × p</code> and <code>m ×  n × q</code></p>
  
  <p>Imagine along dimensions <strong>m</strong> and <strong>n</strong> we have pixels and for each pixel we have a vector (length p or q).
  Now what I want, is to multiply <strong>for every corresponding pixel</strong> the vectors of the two images, such that for every pixel I get a <strong>matrix</strong> and thus in total a 4D Matrix in the end.</p>
  
  <p>How do I do this efficiently?</p>