So I have a large matrix(4091252x2) that looks something like this:
439105 1053224
439105 1696241
439105 580064
439105 1464748
1836139 1593258
1464748 439105
1464748 1053224
1464748 1696241
1464748 580064
580064 439105
Basically, the matrix represents calls made from one person to another, represented by a personID (439105 calls 1053224). What I want to do is scale down this matrix so that the smallest personID = 1, and 2 for the next lowest personID, 3 for next lowest personID after that, etc. For example if the matrix looked like this:
110 503
402 110
300 900
300 402
402 110
I would want it mapped to:
1 4
3 1
2 5
2 3
3 1
The problem is that I'm a beginner to Matlab, and I have no idea how to do this. I looked into reshape and sub2ind but I don't really think thats what I'm looking for. How would I accomplish this in Matlab?
Any help would be greatly appreciated, thanks!
You can use the third output of unique
for this purpose, it just needs reshaping.
A=[110 503
402 110
300 900
300 402]
[~,~,D]=unique(A);
reshape(D,size(A))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With