This MATLAB function locates all nonzero elements of array X, and returns the linear indices of those elements in vector ind.
www.mathworks.com