title: Fast associative arrays or maps in Matlab
body: <p>I need to build a <em>fast</em> <strong>one-to-one mapping</strong> between two large arrays of integers in Matlab. The mapping should take as input an element from a pre-defined array, e.g.:</p>
  
  <pre><code>in_range    = [-200   2  56   45 ... ];
  </code></pre>
  
  <p>and map it, by its index in the previous array, to the corresponding element from another pre-defined array, e.g.:</p>
  
  <pre><code>out_range   = [-10000 0  97   600 ... ];
  </code></pre>
  
  <p>For example, in the case above, <code>my_map(-200)</code> should output <code>-10000</code>, and <code>my_map(45)</code> should output <code>600</code>.</p>
  
  <p>I need a solution that</p>
  
  <ol>
  <li>Can map very large arrays (~100K elements) relatively efficiently.</li>
  <li>Scales well with the bounds of <code>in_range</code> and <code>out_range</code> (i.e. their <code>min</code> and <code>max</code> values)</li>
  </ol>
  
  <p>So far, I have solved this problem using Matlab's external interface to Java with <strong>Java's HashMaps</strong>, but I was wondering if there was a Matlab-native alternative.</p>
  
  <p>Thanks!</p>