MATLAB: Retrun largest numbers array Can you help me how to retrun the larget numbers from the array as in the same order of that array? for example i have A = 8 , 3, 4 , 1 , 5 , 6 , 2 , 7 , 9. I want to return largest 3 number in the same order as A like that B = 8 , 7 , 9. Best Answer >> [~, idx] = sort(A);>> B = A(sort(idx(end-2:end)))) Related SolutionsMATLAB: How to sort an array in descending order Try this:[rows, columns] = size(X)sorted_X = reshape(sort(X(:), 'descend'), [columns, rows])'It gives you the exact result you showed. It sorts all the elements, regardless of what row or column they started in, then reshapes from a vector back into the shape of the original X matrix. MATLAB: FETCH LARGEST NUMBERS 1. Take the capslock off.2. Sort your array in descending order. Use the SORT function.3. Take the first 3 numbers in the sorted array. Related QuestionTo know what number is not available in an array.How to select 2nd largest number (or largest if no 2nd largest)Sorting in descending order by rowHow to reverse a subarray of an arrayLargest Candidate RuleHow to sort an array in descending order without using the sort functionLargest connected component(circular)
Best Answer