MATLAB: Split the matrix for training a dataset based on the value in y axis using MATLAB

MATLABtraining set

I have a data set with matrix 168*1 and would like to extract training set based on the y axis value.
X – axis is the value from 0 to 180 (no. of cycle)
y – axis is the value from 0 to 2.1 (capacity)
I am looking to split the data set based on the value in y axis 1.4
any suggest ?
Note: I am able to split based on the percentage
numTimeStepsTrain = floor(0.7*numel(data));

Best Answer

It will split the dataset into two dataset x1, y1, and x2, y2. x1, y1 corresponds to value of y<1.4
index = y<1.4;
x1 = x(index);
y1 = y(index);
x2 = x(~index);
y2 = y(~index);