# Why crossvalind and cvpartition results are different?

I did a Test on my data set with "cvpartition" and "crossvalind" functions (in MATLAB) with the same parameters and data set, but why the error results are different and which one is correct?

Codes are from MATLAB help just data set has been replaced.

crossvalind:

k=10;
indices = crossvalind('Kfold',lables,k);
cp = classperf(lables);
for i = 1:k
test = (indices == i);
train = ~test;
class = classify(dataset(test,:),dataset(train,:),lables(train,:));
classperf(cp,class,test);
end

cp.ErrorRate


Error Rate is: 0.3322

and cvpartition:

CVO = cvpartition(lables,'k',10);
err = zeros(CVO.NumTestSets,1);
for i = 1:CVO.NumTestSets
trainIdx = CVO.training(i);
testIdx = CVO.test(i);
ytest = classify(dataset(testIdx,:),dataset(trainIdx,:),lables(trainIdx,:));
err(i) = sum(~strcmp(ytest,lables(testIdx)));
end
ErrorRate = sum(err)/sum(CVO.TestSize)


Error Rate is: 0.0342