Ranking Numbers based on Size

4 ビュー (過去 30 日間)
ScGold
ScGold 2019 年 2 月 12 日
コメント済み: Jos (10584) 2019 年 2 月 15 日
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 件のコメント
Jos (10584)
Jos (10584) 2019 年 2 月 15 日
You might be interested in my recent submission RANKNUM:

サインインしてコメントする。

採用された回答

Jos (10584)
Jos (10584) 2019 年 2 月 12 日
A = [1 5 0 9 6 4]
[~, ~, R] = unique(A)
  1 件のコメント
ScGold
ScGold 2019 年 2 月 13 日
Thank you!
An issue I'm having is keeping NaNs as non-values rather than assigning one to them, but will work through this.

サインインしてコメントする。

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2019 年 2 月 12 日
Another, computationally simpler option:
A = [1 5 0 9 6 4]
[~, R] = sort(A) ;
R(R) = 1:numel(A)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by