"han " <samuel_han@hotmail.com> wrote in message <hvfklc$f8v$1@fred.mathworks.com>...
> I am calculating the similarity in a big and very sparse matrix which dimensions are 940*1600,
> I use the command of pdist(matrix,'cosine'), however, I got the following error message
> Error using ==> pdist at 174
> Some points have small relative magnitudes, making them effectively zero.
> Either remove those points, or choose a distance other than cosine.
>
> someone who can help me out of this trouble?
> great thanks
As the error message is telling you, some of your row vectors are so small in magnitude relative to others that the 'cosine' metric gives a meaningless result, so 'pdist' is complaining about this and refusing to cooperate.
You say your matrix is sparse. Perhaps some of your row vectors are actually of zero magnitude. The 'cosine' metric requires that a division by the magnitude be performed, but in such vectors that would produce a NaN rather than a valid result.
Roger Stafford
