I have two MATLAB vectors, one of them a simple ascending order vector, such as the following one:
ind = [1 2 3 4];
and another one of the same size as ind
, but whose numbers can vary:
vec=[46 91 9 10];
Those two vectors are in some correspondence with one another, so I would like to be able to create a mapping M such that M(46) = 1
, M(91) = 2
, and so on. Of course, a solution using a full matrix M would, in general, be very wasteful since it would assume a matrix whose size is equal to the biggest possible value of vec
. How might I be able to compress this mapping?
Essentially I'm looking for the MATLAB equivalent of what would otherwise be solved with a Python dict
or a C++ std::map<int, int>
.