title: How to use distance function dtw in clasifier fitcknn
body: <p>(Matlab R 2019b)</p>
  
  <p>I used <code>@dtw</code> function as distance function in <code>fitcknn</code> classifier. 
  The error massage says that the dimensions of two arrays of input to <code>dtw</code> are not the same.</p>
  
  <p>I changed the function <code>dtw</code> to show the dimensions of the arrays and I found that the first print is correct (both x and y are one dimension) but the second print is not. After that the error message appears.</p>
  
  <p>This is the code:</p>
  
  <pre><code>function [Mdl,Y,pred,gav,gavClass] = test_fitcknn()
      %Tests fitcknn
      % 2020-05-02
      load Y.mat Y;
      load pred.mat pred ;
      Mdl=fitcknn(pred,Y,'Distance',@dtw);
      gav=mean(pred);
      gavClass=predict(Mdl,gav);
  end
  </code></pre>
  
  <p>And this is the error message:</p>
  
  <pre><code>Error in test_fitcknn (line 8)
      gavClass=predict(Mdl,gav);
  
  Caused by:
      Error using dtw (line 91)
      The number of rows between X and Y must be equal when X and Y are matrices
  
   pred is the input data 60X156 real
   Y is 60X1 cell output  character string  
  </code></pre>
  
  <p>I have saved data in this way:</p>
  
  <pre><code>save y.mat y
  save pred.mat pred
  </code></pre>
  
  <p>Best regards
  Alavi</p>