Ranking Numbers based on Size

조회 수: 9 (최근 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!

채택된 답변

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 CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by