BUG (??) :pdist x dist x pdist2

Hi all,
I always used pdist to calculate euclidian distance between two points, but suddenly my m.file began to complain that "?? Error using ==> pdist Too many input arguments.". Well, how is possible for one routine that was working fine begin to complain after I tried "dist" in another routine ?
Anyway, I figure it out that maybe pdist is not the best choice for only two points distance. Is "dist" the correct function?
Thanks in advance.
Paulo.

 Réponse acceptée

Wayne King
Wayne King le 15 Oct 2012

0 votes

Without addressing your issue with pdist, you can use norm()
x = [1 -1];
y = [1 1];
norm(x-y,2)
% norm(x-y,1)
Note that norm(x-y,2) is the same as
pdist([x' y'])

5 commentaires

Paulo
Paulo le 16 Oct 2012
Thank you.
But seems that I really have a bug. At my desktop the problem is as above. The function pdist as you pointed does not work. But at my laptop works just fine...!!!
I've already unistalled the Matlab from my desktop twice, but the problem continue: at the deskotop I keep having error message, than I copy the same m. file to the laptop and...works normally...
Any suggestions!!????????
Thank you guys!
Richard Brown
Richard Brown le 16 Oct 2012
can you post your code?
Star Strider
Star Strider le 16 Oct 2012
Modifié(e) : Star Strider le 16 Oct 2012
I suggest you run this line from the Command Window on your desktop computer:
which pdist -all
What is the result?
You might also compare it with the result of running the same line on your laptop.
Paulo
Paulo le 16 Oct 2012
Richard Brown about 10 hours ago
can you post your code?
____________ Richard,
Even with the code suggested by Wayne I was getting those results...
_________ Star Strider,
You solved it! I found a pdist.m file that was not supposed to have this name. I deleted and now things back to normal!!!!
Thank you very much all! Kind regards, Paulo.
Star Strider
Star Strider le 16 Oct 2012
I'm glad I could help!
Since your code worked on your laptop and not your desktop, I guessed you had to be shadowing pdist on your desktop.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by