MATLAB: Finding largest values in matrix matrixmax I would like to find the 10 largest values in a 90×90 matrix, and their indices. Any suggestions? Thanks, Yaniv Best Answer A = randn(90);Nmax = 10; % get Nmax biggest entries[ Avec, Ind ] = sort(A(:),1,'descend');max_values = Avec(1:Nmax);[ ind_row, ind_col ] = ind2sub(size(A),Ind(1:Nmax)); % fetch indicesYou can of course also use a while loop and pick out one value at a time. 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: Retrun largest numbers >> [~, idx] = sort(A);>> B = A(sort(idx(end-2:end)))) Related QuestionUse indeces of a column to sort another columnLargest Candidate RuleLooking for clever way to generate multiple submatrices.FETCH LARGEST NUMBERSHow to select 2nd largest number (or largest if no 2nd largest)Second largest peak value
Best Answer