MATLAB: Best way to split data into random partitions

histogramMATLAB

I am new to Matlab and still a student. For an assignment, I am stuck on this part.
Create 5 random partitions of the data, splitting each of the classes into 60% training and 40% testing.
I have two classes, Class One and Class Two.
How would I be able to do this?
classOne and classTwo is 10000×2 double histogram

Best Answer

I would use the dividerand function in the Deep Learning Toolbox.
For example
[trainInd,valInd,testInd] = dividerand(3000,0.6,0.2,0.2);
Just set the validation percentage to 0 if you don't need it.