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.

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 7 Jun. 2012

14 Stimmen

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

2 Kommentare

Anthony Mukanya
Anthony Mukanya am 17 Aug. 2015
Verschoben: Voss am 24 Mär. 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
Alyaa Ghazi
Alyaa Ghazi am 24 Mär. 2024
great,it's very useful

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Gefragt:

am 7 Jun. 2012

Verschoben:

am 24 Mär. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by