title: How do I weigh images and then add them up efficiently in MATLAB?
body: <p>I need a kind of volume-vector 'dot product' of sorts. Here is the problem:</p>
  
  <p>I have a <code>2x3x4</code> volume, which is a nothing but a bunch of <code>4</code> <code>2x3</code> images one after the other. Let's call it volume <code>vol</code>. </p>
  
  <p>I also have a <code>4x1</code> vector, and let us call it <code>vec</code>.</p>
  
  <p>I want my output to be a weighted sum of each image. Thus my output will be a <code>2x3</code> image. It will be formed by taking:</p>
  
  <pre><code>output = vol(:,:,1).*vec(1) + vol(:,:,2).*vec(2) + vol(:,:,3).*vec(3) + vol(:,:,4).*vec(4)
  </code></pre>
  
  <p>I can put this in a for-loop, but I was wondering if there was an easier way of doing it. </p>
  
  <p>Thanks. </p>