title: How to use a look up table in MATLAB
body: <p>I need to perform an exponential operation of two parameters (one set: t, and the other comes from the arrays) on a set of 2D arrays (a 3D Matrix if you want). 
      f(t,x) = exp(t-x)
  And then I need to add the result of every value in the 3rd dimension. Because it takes too much time using <code>bsxfun</code> to perform the entire operation I was thinking of using a look up table.</p>
  
  <p>I can create the table as a matrix <code>LUT</code> (2 dimensional due to the two parameters), then I can retrieve the values using <code>LUT(par1,par2)</code>. But accessing on the 3rd dimension using a loop is expensive too.</p>
  
  <p>My question is: is there a way to implement such mechanism (a look up table) to have a predefined values and then just using them accessing from the matrix elements (kind of indexing) without loops. Or, how can I create a look up table that MATLAB handles automatically to speed up the exponential operation?</p>
  
  <p>EDIT:
  I actually used similar methods to create the LUT. Now, my problem actually is how to access it in an efficient way. </p>
  
  <p>Lets said I have a 2 dimensional array <code>M</code>. With those values that I want to apply the function <code>f(t,M(i,j))</code> for fixed value <code>t</code>. I can use a loop to go through all the values (i,j) of M. But I want a faster way of doing it, because I have a set of M's, and then I need to apply this procedure to all the other values.</p>
  
  <p>My function is a little bit complex than the example I gave:</p>
  
  <pre><code>pr = mean(exp(-bsxfun(@rdivide,bsxfun(@minus,color_vals,double(I)).^2,m)./2),3);
  </code></pre>
  
  <p>That is my actual function, as you can see is more complex than the example I presented. But the idea is the same. It does an average in the third dimension of the set of M's of the exponential of the difference of two arrays.</p>
  
  <p>Hope that helps.</p>