MATLAB: Extract 5 highest value of a vector extractindices If I want to extract the indices of the 5 highest value of a avg vector (30×1 for example) how can I do? ind = find(avgDE… ) Best Answer [a,ii] = sort(avgDE,'descend');outidx = ii(1:5); Related SolutionsMATLAB: Highest frequency Please try the mode function: x = mode(A);HTH. MATLAB: Selecting the highest value I don't understand why the first row of your result is not1 2 03 .6 98as 98 is bigger than 90. Assuming you've made a mistake, the following code works, though there may, as ever, be neater methods:data = [1 3 .5 .6 89 1 2 03 .6 98 1 8 .3 .3 90 2 3 .2 .5 87 2 87 02 1 89 10 12 01 .3 87 10 12 03 07 99 10 0.3 0.5 10 78];indexcol = 1;valuecol = 5;indexlist = data(:,indexcol);indexes = unique(indexlist);results = zeros(length(indexes), size(data,2));for k = 1:length(indexes) rows = find(indexlist == indexes(k)); [unused, maxsubsetrow] = max(data(rows, valuecol)); maxrow = rows(maxsubsetrow); results(k, :) = data(maxrow, :);enddisp(results); Related QuestionLocation of 10 highest valuesFinding highest values in stringHow to find the 5th highest value in a matrixArray loop to find highest valueHow to give ranking from highest to lowestFind highest third of values in dateset
Best Answer