Ranking numbers in a table and manipulating by division.

I am trying to manually calculate non-exceedance probabilities of each value x. How can I rank the values in this table from smallest to largest and then divide each value by the total number of values (in this case 10). So the highest value (2310) should have a rank of 10 and a non-exceedance probability of 1.
Table = readtable("practice3.xlsx");
x = Table.values
x = 10×1
450 1100 1060 700 350 80 2310 2000 370 50

 Accepted Answer

Possibly this:
Table = readtable("practice3.xlsx");
[~,idx] = ismember(Table.values,sort(Table.values));
Table.ranks = idx;
Table.non_exceedance_prob = idx/size(Table,1)
Table = 10×3 table
values ranks non_exceedance_prob ______ _____ ___________________ 450 5 0.5 1100 8 0.8 1060 7 0.7 700 6 0.6 350 3 0.3 80 2 0.2 2310 10 1 2000 9 0.9 370 4 0.4 50 1 0.1

1 Comment

Thank you for showing me how to sort the data, I was using "ascend" "descend" and it wasn't exactly getting it exactly right.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2022b

Asked:

on 12 Feb 2023

Commented:

on 13 Feb 2023

Community Treasure Hunt

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

Start Hunting!