MATLAB Answers

0

removing rows from matrix which equal particular number

Asked by sermet on 26 Jul 2018
Latest activity Answered by Adam Danz
on 26 Jul 2018
A=[1 2 3;4 5 6;99 7 8;5 5 99;1 2 3;99 99 5];
How can I remove rows include 99 as follows;
B=[1 2 3;4 5 6;1 2 3];
The actual matrix is much more, the above is just an example.

  0 Comments

Sign in to comment.

1 Answer

Answer by Adam Danz
on 26 Jul 2018
 Accepted Answer

The first line identifies rows of A that have 99. The second line removes those rows.
removeIdx = any(A == 99, 2);
A(removeIdx,:) = []

  0 Comments

Sign in to comment.