- Decide on the number of folds k you want to use for cross-validation.
- Randomly shuffle and partition the data into k folds.
- For each fold, designate one part as the validation set and the rest as the training set. The ‘setdiff’ and ‘subset’ functions can be used for finding the training indices by excluding validation indices and partitioning the data into training and validation sets, respectively. You may refer to the following documentation links for more insights:
- https://www.mathworks.com/help/matlab/ref/double.setdiff.html
- https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.imagedatastore.subset.html