Error in using pdist2 , error in Exhaustive​Searcher/k​nnsearch

1 回表示 (過去 30 日間)
Raady
Raady 2016 年 8 月 2 日
編集済み: Raady 2016 年 8 月 3 日
Hello I have a feature vector of 13 dimensions for m samples.I am trying to find the nearest neighbor of the each sample.
[m,~] = size(featurevector);
X = [];
Y = [];
for i = 1: m-1
if (featurevector(i,14) == 3)
X = [X;featurevector(i,1:13)];
Y = [Y;featurevector(i,1:13)];
end
end
I can get the distances values matrix which gives the distances of all the points when using
d = pdist2(X,Y,'euclidean');
but i want the indexs which 3 neighbors are near to each data point so i tried
[idx,dist] = knnsearch(X,Y,'k',3,'distance','euclidean');
but it shows an error
Error using pdist2
Too many input arguments.
Error in ExhaustiveSearcher/knnsearch (line 207)
[dist,idx] = pdist2(obj.X,Y, distMetric, arg{:}, 'smallest',numNN);
Error in knnsearch (line 144)
[idx, dist] = knnsearch(O,Y,'k',numNN, 'includeties',includeTies);
I expect the result to be an array showing the nearest neighbor for each point in the featurevector. Can any one suggest where I went wrong ?
  3 件のコメント
Raady
Raady 2016 年 8 月 2 日
c:\toolbox\classify\pdist2.m C:\Program Files (x86)\MATLAB\MATLAB Production Server\R2015a\toolbox\stats\stats\pdist2.m % Shadowed
Raady
Raady 2016 年 8 月 2 日
編集済み: Raady 2016 年 8 月 2 日
I am using Matlab 2015a

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2016 年 8 月 3 日
Your third party file c:\toolbox\classify\pdist2.m is interfering with use of the pdist2 from the Statistics toolbox. You need to rename or delete c:\toolbox\classify\pdist2.m or remove that directory from your MATLAB path.
  1 件のコメント
Raady
Raady 2016 年 8 月 3 日
編集済み: Raady 2016 年 8 月 3 日
I used Matlab2007a before, I guessed the uninstallation would have remove all of those. Thank you so much it worked !

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeClassification Ensembles についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by