Reputation: 3737
So I had a large matrix(4091252x2) with large values like this:
439105 1053224
439105 1696241
439105 580064
439105 1464748
1836139 1593258
1464748 439105
1464748 1053224
1464748 1696241
1464748 580064
580064 439105
that I mapped down to smaller numbers. However, how would I keep track of the numbers that I mapped?
For example, assuming that I have a matrix like
A = [110 503
402 110
300 900
300 402]
and mapped it to:
B = [1 4
3 1
2 5
2 3]
using:
[~,~,D] = unique(A);
B = reshape(D,size(A))
How could I write a function to keep track of the values that I mapped? For example that 110 = 1? I'm just not sure how to approach the problem, and any help would be greatly appreciated, thank you!!
Upvotes: 3
Views: 66
Reputation: 3440
It maps in order so first output
[largeMap,~,D] = unique(A);
B = reshape(D,size(A)) ;
smallMap = (1:length(largeMap))';
map = [largeMap, smallMap];
Upvotes: 2