title: Matlab Error in using pdist2 for high dimensional data
body: <p>I have a feature vector of 13 dimensions for m samples. I am trying to find k nearest neighbors of each sample. </p>
  
  <p>I have selected the feature vector required.</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>I have tried calculating the distances for each point </p>
  
  <pre><code>d = pdist2(X,Y,'euclidean');
  </code></pre>
  
  <p>It works fine till here. Now I wanted to find the k = 3 nearest neighbor indexes of each and every sample, so it tried </p>
  
  <pre><code>[idx,dist] = knnsearch(X,Y,'k',3,'distance','euclidean');
  </code></pre>
  
  <p>but it shows an error</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>I have tried with example that mentioned in help . it works fine and I am not able to do when number of samples = 630. 
  Did my coding went wrong ? </p>
  
  <p>I am using Matlab 2015a
  my paths on command</p>
  
  <pre><code>which -all pdist2
  </code></pre>
  
  <p>gives</p>
  
  <pre><code>c:\toolbox\classify\pdist2.m C:\Program Files (x86)\MATLAB\MATLAB Production Server\R2015a\toolbox\stats\stats\pdist2.m % Shadowed
  </code></pre>
  
  <p>any help appreciated ! </p>