I'm trying to split data into a training and testing set. The data X is a 150x4 matrix of 150 data points with 4 features each. I did this to create an index vector to randomly select 100 out of 150 data points for training:
trainIndices = zeros(length(X),1);
trainIndices(randperm(150,100)) = 1
Then I tried doing this to select the rows where trainIndices == 1
:
X_train = X(trainIndices,:);
But I'm getting an error Subscript indices must either be real positive integers or logicals.
What am I doing wrong here?