I would suggest you should use table for data analytics.
The following code may help you reduce the number of lines.
up to the end line, the data is sorted by the lable.
data = readtable("outfile.csv");
data.Properties.VariableNames{end} = 'label';
data{:,1:end-1} = normalize(data{:,1:end-1},1);
data = sortrows(data,'label');
wave2_support = data(:,1:9);
table:
if you want to split the data into TEST and TRAIN, then you should try cvpatition:
This function can maintain the ratio of the labels as it is after spliting the data into two.
Best Answer