Indexing back into an array the same size as one that was just sorted
3 views (last 30 days)
I'm trying to first sort each row of a 3X3 array. And then take the subscripts of the two largest numbers in each row and pull them out.
A = magic(3);
[~, IDX] = sort(A, 2, 'descend');
And then use IDX to pull out the largest 2 numbers in each row in array A, leaving me with and array sized 3,2.