Fast associative arrays or maps in Matlab

I need to build a quick one-to-one mapping between two large arrays of integers in Matlab. The mapping should take as an input element from a predefined array, for example:

in_range    = [-200   2  56   45 ... ];

and match it by its index in the previous array with the corresponding element from another predefined array, for example:

out_range   = [-10000 0  97   600 ... ];

For example, in the above case, it my_map(-200)should output -10000, but it my_map(45)should output 600.

I need a solution that

  • You can match very large arrays (~ 100 thousand elements) relatively efficiently.
  • Scales well with borders in_rangeand out_range(i.e., values ​​of minand max)

So far I have solved this problem using the Matlab frontend for Java with Java HashMaps , but I was wondering if there is an alternative to Matlab.

Thank!

+5
source share
1 answer

Recent versions of Matlab have hashes . I use 2007b and they are not available, so I use structs whenever I need a hash. Just convert integers to valid field names with genvarname .

+4
source

All Articles