cvparition partitions data for cross-validation. It defines a random partition on data set and uses it to define training and test sets for validating a statistical model.
tbl = array2table(X);
tbl.Y = Y;
n = length(tbl.Y);
hpartition = cvpartition(n,'Holdout',0.3);
hpartition holds the total number of observations, total number of test sets, the size of training set and the size of test size.
To display the indeces which are being used for training, you can use -
To display the indeces which are being used for testing, you can use -
While, using crossval, you can estimate the loss returned by 10-fold cross-validation error estimate.
err = crossval(criterion,X,y,'Predfun',predfun)
To know more about them, you can use the links provided - 1 2