MATLAB: How to deletes rows after a certain row

genetic algorithm

I got a 100*1 matrix and i sort them as descendibg order. After that i want to delete the worse half of the matrix to get a 50*1 matrix how could i get it?

Best Answer

Try this:
Data = randi(99, 100, 1); % Create Data
Sorted_Data = sort(Data, 'descend'); % Sort Descending
Keep_Data = Sorted_Data(1:50); % Data To Be Kept