MATLAB: How to find the Nth high number in a matrix A find max valeu matrix 5th nth arrayMATLAB Hi guys, I need to find the 5th high number of a matrix. Using the max() function I can only have the 1st one. Thanks for helping! Best Answer As Iain suggested, sort is a great way to go, but as you mention that you have a matrix, you might want to sort every element of the matrix:sorted = sort(values(:));sorted(end-4) Related SolutionsMATLAB: Finding the 10 lowest values Let's say you have a matrix of 10x10: x=rand (10,10);Sort it by the columns in ascending order: y=sort (x,1, 'ascend')*Now take the 5 first rows - these are the lowest values in every column: z=y(1:5, :) MATLAB: How to find unique values The ‘Uvals’ array should have the information you want:D = load('cat cat matlab2.mat');a = D.a;non_empty = cellfun(@(x)~isempty(x), a);[r,c] = find(non_empty);for k1 = 1:max(c) idx = r(c == k1); vals = a(idx,k1); Uvals{k1} = unique(vals); % Unique Valuesend Related QuestionHow can i find row position for minimum value that changes every cycle. each cycle has 100 data points( 100*1 matrix).How to pull out rows with a unique value in a specified columnHow to remove repeating elements from an arrayIf i have two of matrix how to sort themHow to select 2nd largest number (or largest if no 2nd largest)Matrix with double values
Best Answer