Keeping track of displayed matrix values?

So, I had a large matrix (4091252x2) with values ​​like this:

 439105     1053224
  439105     1696241
  439105      580064
  439105     1464748
 1836139     1593258
 1464748      439105
 1464748     1053224
 1464748     1696241
 1464748      580064
  580064      439105

      

which I matched with smaller numbers. However, how would I keep track of the numbers that I display?

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 can I write a function to keep track of the values ​​that I have displayed? For example, 110 = 1? I'm just not sure how to approach the problem and any help would be greatly appreciated, thanks!

+3


source to share


1 answer


It displays fine, so the first output is



[largeMap,~,D] = unique(A);
B = reshape(D,size(A)) ;
smallMap = (1:length(largeMap))';
map = [largeMap, smallMap];

      

+2


source







All Articles