cross-validation in MATLAB in similar spirit to the Python counterpart