MATLAB: How to find X smallest numbers in a Matrix

loopmatrix

I have a 480 by 640 matrix, and I would like to find 4 smallest number ( or closest values to zero).

Best Answer

Xs=sort(X(:));
FourSmallest = Xs(1:4);