Replacing all the elements of one matrix with new values (one to one mapping)
3 次查看(过去 30 天)
显示 更早的评论
I have a large matrix of size 50000×3. I would like to replace the values of the elements with a new values. To illustrate my problem, for example, let's say F is as follows.
F = [22 60 100;
11 13 14;
10 12 15;
16 15 17;
17 18 25;
13 19 20;
20 30 22;
10 11 12]
unique(F)' = 10 11 12 13 14 15 16 17 18 19 20 22 25 30 60 100
Now I want to assign new values to each element of F. The assignment is such that the lowest value of F maps to 1, the second lowest value maps to 2. It continues with an increment of 1 until it reaches the highest value in F. In the example above, I want to assign 1 to 10, 2 to 11, ..., and 16 to 100 and construct a new F as follows:
Fnew = [12 15 16;
2 4 5;
1 3 6;
7 6 8;
8 9 13;
13 10 11;
11 14 12;
1 2 3]
unique(Fnew)' = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Could someone instruct me how to construct such a matrix from F?
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!