From: Rahul Singhal on
I am trying to get the cosine similarity between rows in a matrix containing 1's and 0's. I am using the matlab function :

D = pdist(X,'cosine')

where X = matrix

But when i run the command, it gives the following error:

??? 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.

So how can i overcome this error. can somebody help me plz..

Thanks

Rahul
From: Mongkut Piantanakulchai on
I guess the vectors that contain all zeros might cause the problem.
This is because the dot product should be divided by the product of matrix norm (magnitude) which will become zero). Division by zero might cause problem in that function.
Remove all vectors that contains all zeros may help.
If you still need those vectors that contains all zeros then you can choose other similarity measures.