MATLAB: How to find the max of two vectors

maxranksort

a=[4.84 3.55 2.09 4.20 1.14 5.15 2.45 3.41 1.66 2.75 3.87]
b=[ 7 8 8 7 7 9 8 6 5 7 8]
I want to find the max such that the max(a) is in the same column as max(b). I want to find the top 3. First should be column 6 Second should be column 11 Third should be column 1

Best Answer

Do you actually want to sort by sum of columns?
For example:
a = [4.84 3.55 2.09 4.20 1.14 5.15 2.45 3.41 1.66 2.75 3.87];
b = [ 7 8 8 7 7 9 8 6 5 7 8];
[~,idx] = sort(a+b,'descend');
nTopThree = [a(idx(1:3));b(idx(1:3))];
nTopThree =
5.1500 3.8700 4.8400
9.0000 8.0000 7.0000