File Exchange

image thumbnail

Integer to Integer map using logical indexing

version (920 Bytes) by Sathyanarayan Rao
Logical indexing is used to map integer from one set to another

1 Download

Updated 30 Aug 2017

View License

Given two sets of integer, integer is mapped from one set to another. The author acknowledges Stephen Cobeldick
for his suggestion on using ismember to perform same task
[~,idx] = ismember(A,map2);
B = map1(idx);

Cite As

Sathyanarayan Rao (2020). Integer to Integer map using logical indexing (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)


For tiny problems with max(map2) < 1000 a look up table is efficient also:

LUT = nan(1, max(map2));
LUT(map2) = map1;
mapped = LUT(original)

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux