Say I have a vector of size 1-by-x called X. I need to keep the 10 percent largest elements of X and set all other elements equal to zero. This is easy with using sort:
X = sort(abs(X),'descend');
DIM = floor(length(X)*(0.1));
X(DIM+1:end) = 0;
but disturbing the order of the original vector X is not allowed (or if I disturb the original order, after zeroing out, I should recover the original order which I don't know how to). How can this be done?