MATLAB: Filter matrix according to column

filter matrix

i have a matrix 10×60. It consists of entries with the number 0 or 1. I want to filter out all the rows, where the last five columns (55:60) have only 1 and no zero.

Best Answer

Try this:
M = randi([0 1], 10, 60); % Create Matrix
M(5, 55:60) = ones(1,6); % Row 5 Meets Criteria
row = all(M(:,55:60) == 1, 2); % Logical Vector, ‘1’ = Meets Criterion For Removal
Result = M(~row,:);