To find the two largest values of a row in a 2D array in Matlab, you can use the sort
function along with the 'descend'
option to sort the row in descending order, and then take the first two elements of the sorted row:
main.m326 chars6 lines
This code will give you the two largest values of the second row of the A
array, which in this example are 6
and 5
, in that order.
gistlibby LogSnag