MATLAB Answers

A
0

pdist2 function

Asked by A
on 7 Feb 2012
Latest activity Commented on by Steven Lord
on 28 Oct 2019 at 13:42
I'm trying to use the pdist2 function and keep getting this error: "??? Undefined function or method 'pdist2' for input arguments of type 'double'" The 'double' part changes depending on what data type I use, so that part can be ignored.
The statistics toolbox is in my path and I can do "help pdist2" and have the help file come up.
I have tried the examples within the help file and this still doesn't work.
The only thing I can think of is there is a function within pdist2 called partialSort, but no matter how much searching I do, I see no matlab function for this???
Anyone know why my pdist2 doesn't work?

  3 Comments

Sean de Wolski
on 8 Feb 2012
Does regular pdist run?
A
on 8 Feb 2012
No, pdist doesn't run either. I checked ver('stats') and it says: Statistics Toolbox Version 7.4 (R2010b)
It also shows the license number. So i'm pretty sure the toolbox is installed correctly.
Other functions in the toolbox do not work either... I'm waiting on a Matlab rep to contact me, but was hoping to get it fixed in the mean time.
Sean de Wolski
on 8 Feb 2012
I would guess it's not installed correctly. Is it on your path?
>>path

Sign in to comment.

3 Answers

Answer by Benjamin Schwabe on 7 Feb 2012

Okay, my MATLAB does not know a pdist2 function, only pdist. (I am using MatLabd r2009b)
Could it be that simple?
Otherwise, in which folder is the pdist2.m file? Add this to the path or change working directory accordingly.

  1 Comment

A
on 8 Feb 2012
i'm using r2010b and pdist2 was added to this version

Sign in to comment.


Answer by Chathurika on 20 Feb 2013

if you don't have a working pdist2, use the following code..it could be little slower than pdist2..but works fine..
pairwise distance between rows of matrix A and B....A and B should have same no of columns....output D is a 2D matrix with ij entry giving distance between ith row of A and jth row of B....distance used is L1 norm..
tmpB(1,:,:)=B';
x=repmat(tmpB,[size(A,1),1,1]);
y=repmat(A,[1,1,size(x,3)]);
D(:,:)=sum(abs(x-y),2);

  0 Comments

Sign in to comment.


Answer by ROCKTIM JYOTI DAS on 28 Oct 2019 at 6:56

how to compare two histogram of images

  1 Comment

Steven Lord
on 28 Oct 2019 at 13:42
This isn't related to the original question. Please ask it as its own question. When you ask it as its own question, you should provide more details about how you want to compare the histograms (just answer "Are they the same?", answer "How many bins are different?", answer "How much does each bin differ between the two images?", etc.)

Sign in to comment.