title: Matlab Cross-Validation error in calculating performance of model
body: <p>I am trying to perform cross-validation on my models with multiple classification classes but I am getting errors when trying to update my classperf on each fold. I am getting this error "Index vector has invalid values."</p>
  
  <p>My code is as below:</p>
  
  <pre><code>K = 5; 
  N = size(DataSet, 1); 
  idx = crossvalind('Kfold', N, K); 
  cp = classperf(trainLabel);
  for i = 1:K
       ... 
       %Long codes for svmtrain &amp; svmclassify
       ...
       cp = classperf(cp, Group, trueTestLabel); %error on this line
  end
  cp.CorrectRate
  </code></pre>
  
  <p>where trainLabel is a 120 x 1 double consisting of the ground-truth score for all of the items; Group is the results obtained from svmclassify in 20 x 1 double; and trueTestLabel is the ground-truth score for the testing class in 20 x 1 double form obtained using the following function:</p>
  
  <pre><code>trueTestLabel = trainLabel(idx == i, end);
  </code></pre>
  
  <p>I have tried converting "Group" and "trueTestLabel" into cells by using num2cell function as such:</p>
  
  <pre><code> cp = classperf(cp, num2cell(Group), num2cell(trueTestLabel ));
  </code></pre>
  
  <p>but instead, I got a different error saying "When the class labels of the CP object are numeric, the output
  of the classifier must be all non-negative integers or NaN's." </p>