MATLAB: Delete every n rows if less than x

deleterow-column vlaue

Hi I have a m x 14 matrix. I want to consider the first 24 rows. If the value in coulmn 5 in row 14 is less than x, then delete the first 24 rows. I want to repeat this for the rest of the matrix as well, considering 24 rows at a time

Best Answer

Assuming that m is a multiple of 24:
DataM = reshape(Data, 24, [], 14);
Match = (DataM(14, :, 5) >= x);
Result = reshape(DataM(:, Match, :), [], 14);
For teaching with a FOR loop:
Keep = true(1, size(Data, 1));
for k = 1:24:size(Data, 1)
Keep(k:k+23) = (Data(k+4, 14) >= x);
end
Result = Data(Keep, :);