function D = pdist2( X, Y, metric ) ↑ Error: Function definition not supported in this context. Create functions in code file.
1 view (last 30 days)
function D = pdist2( mX,mY, metric )
if( nargin<3 || isempty(metric) ); metric=0; end;
D = distEucSq( X, Y );
D = sqrt(distEucSq( mX, mY ));
D = distL1( mX, mY );
D = distCosine( mX, mY );
D = distEmd( mX, mY );
D = distChiSq( mX, mY );
error(['pdist2 - unknown metric: ' metric]);
Walter Roberson on 2 Apr 2020
You cannot copy and paste that into the command line. You would need to store it in a file named pdist2.m
You will also need to define distEucSq and other related functions.
That code appears to be part of Piotr's "Classify Toolbox". You should install that https://github.com/pdollar/toolbox or you can probably get it from the Add-Ins Manager; https://www.mathworks.com/matlabcentral/fileexchange/56689-pdollar-toolbox