Clear Filters
Clear Filters

How to remove all rows with the same (specific) elements

2 views (last 30 days)
If I have a, say 20x2 matrix, and I want to remove all rows with the entry 0 (column 1), 0 (column 2), how might I do that (and I want to be able to do it without having prior knowledge of the specific locations)?
M=[ 2 2
1 3
5 7
1 2
0 0
1 2
0 0 ]

Accepted Answer

Mischa Kim
Mischa Kim on 2 Jul 2014
Sean, you could use something like
M(~any(M,2),:) = [];

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!