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.

 採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 6 月 7 日

14 投票

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

2 件のコメント

Anthony Mukanya
Anthony Mukanya 2015 年 8 月 17 日
移動済み: Voss 2024 年 3 月 24 日
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 2024 年 3 月 24 日
great,it's very useful

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMultidimensional Arrays についてさらに検索

質問済み:

2012 年 6 月 7 日

移動済み:

2024 年 3 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by