MATLAB: Do I receive an error when I supply a sparse matrix to the FIND function in MATLAB 7.5 (R2007b)

errorfindMATLABsparse

When I execute the following command:
k = 1;
I = find(sparse([1 2]), k);
I receive the following error:
??? Error using ==> find
Too many input arguments.

Best Answer

This enhancement has been incorporated in MATLAB R2008a.
For previous MATLAB releases, the ability to find the first (or last) "k" elements of a sparse matrix using the FIND function is not available.
To work around this issue, you can find all elements using the one input syntax with FIND:
I = find(sparse([1 2]));
and then extract only the elements you need:
I = I(1:k);