Prev: Adding constrains to a nonnegative least-squares solution
Next: How can i compare two pictures in Matlab?!
From: darthshak on 3 Jul 2010 03:35 An immediate solution which comes to mind : If you want to find the M largest values of vector A: 1) Sort the original array and store the result in B 2) Find the Mth largest value(which is in the (N-M+1)th location). 3) Using find() again, locate the indices of all elements greater than the above element. Code: B = sort(A); smallest = B(N-M+1); indices = find(A >= smallest); Hope it helps. Do let me know if you have a more elegant way! |