Ranking Numbers based on Size

3 vues (au cours des 30 derniers jours)
ScGold
ScGold le 12 Fév 2019
Commenté : Jos (10584) le 15 Fév 2019
I have a large dataset of numbers, and am attempting to assign a number to each of them -- ranking smallest to largest.
A = [1 5 0 9 6 4]
The following is an example, where the numbers on the right are from the row vector 'A', and the numbers on the right are "assigned" based on how large the numbers are:
1 -- 2
5 -- 4
0 -- 1
9 -- 6
6 -- 5
4 -- 3
Thank you!
  1 commentaire
Jos (10584)
Jos (10584) le 15 Fév 2019
You might be interested in my recent submission RANKNUM:

Connectez-vous pour commenter.

Réponse acceptée

Jos (10584)
Jos (10584) le 12 Fév 2019
A = [1 5 0 9 6 4]
[~, ~, R] = unique(A)
  1 commentaire
ScGold
ScGold le 13 Fév 2019
Thank you!
An issue I'm having is keeping NaNs as non-values rather than assigning one to them, but will work through this.

Connectez-vous pour commenter.

Plus de réponses (1)

Jos (10584)
Jos (10584) le 12 Fév 2019
Another, computationally simpler option:
A = [1 5 0 9 6 4]
[~, R] = sort(A) ;
R(R) = 1:numel(A)

Catégories

En savoir plus sur Polynomials dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by