Shaibal Ahmed
Shaibal Ahmed

Reputation: 189

Delete non-zero rows in MATLAB

I have used the following code in MATLAB to delete the zero rows,

zero_rows = A(all(A,2),:);

I would like to know how to delete the non-zero rows.

Upvotes: 1

Views: 68

Answers (1)

aarbelle
aarbelle

Reputation: 1033

Just use the not sign ~ or use any

non_zero_rows = A(~all(A,2),:);

or

zero_rows = A(any(A,2),:);

Upvotes: 2

Related Questions