title: lookup table in matlab
body: <p>I am trying to implement a kind of lookup table in MATLAB.</p>
  
  <p>I have data generated from a script with three variables swept, let's say <code>var_a, var_b, var_c</code>. These are nested sweep, (<code>var_a</code> -> <code>var_b</code> -> <code>var_c</code>)
  And there are 10 outputs, <code>out_01, out02, ..., out10</code>.</p>
  
  <p>Now I have arranged the each output as <code>out_01 = f(var_a,var_b,var_c)</code>, i.e., simply rearranging the data similar to nested loop.</p>
  
  <p>My question is, how can I build a lookup table for such data? 
  I will give input like get <code>out_01</code> @ certain <code>var_a(X), var_b(Y), var_c(Z)</code>. </p>
  
  <p>I have tried the following.</p>
  
  <pre><code>    idx1_var_a   = max(find(data.var_a &lt;= options.var_a));
      idx2_var_a   = min(find(data.var_a &gt;= options.var_a));
  
      idx1_var_b = max(find(data.var_b &lt;= options.var_b));
      idx2_var_b = min(find(data.var_b &gt;= options.var_b));
  
      idx1_var_c = max(find(data.var_c &lt;= options.var_c));
      idx2_var_c = min(find(data.var_c &gt;= options.var_c));
  
      Y1 = interpn(data.var_c,data.var_b,data.var_a,data.out_01,data.var_c(idx1_var_c),data.var_b(idx1_var_b),data.var_a(idx1_var_a))
  
      Y2 = interpn(data.var_c,data.var_b,data.var_a,data.out_01,data.var_c(idx2_var_c),data.var_b(idx2_var_b),data.var_a(idx2_var_a))        
  
      if Y1 == Y2
          Y = Y1
      else        
          Here I am unable to figure how to interpolate between these two output values,Y1, and Y2!!
      end
  </code></pre>
  
  <p>Any help is welcome.</p>