delete rows which contain at least 1 zero

Hi there I have a large matrix A. I want to delete every row which contains at least 1 zero in the row.

 Accepted Answer

out = A(all(A,2),:);
or
out=A;
out(any(A==0,2),:) = [];

2 Comments

Anthony Mukanya
Anthony Mukanya on 17 Aug 2015
Moved: Voss on 24 Mar 2024
Thanks Andrei,
I tried what you suggested and it worked.
Now I would like to know what I should do keep the last row even if it contains a zero. The reason for this is because the entry on the nth row and jth must be zero.
Thanks
great,it's very useful

Sign in to comment.

More Answers (0)

Categories

Asked:

on 7 Jun 2012

Moved:

on 24 Mar 2024

Community Treasure Hunt

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

Start Hunting!