Filter löschen
Filter löschen

How to check if any row has 0?

18 Ansichten (letzte 30 Tage)
Beibit Sautbek
Beibit Sautbek am 8 Aug. 2016
Beantwortet: Azzi Abdelmalek am 8 Aug. 2016
If I have matrix A=
0 0 0 5
1 1 4 3
1 3 4 5
2 0 0 5
I need to find that rows which has 0.
A result should show rows 1 and 4, which there are some zeros.
Could anyone help me?!

Akzeptierte Antwort

Stephen23
Stephen23 am 8 Aug. 2016
Bearbeitet: Stephen23 am 8 Aug. 2016
>> idx = any(A==0,2) % logical index
idx =
1
0
0
1
>> find(idx) % subscript index
ans =
1
4

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 8 Aug. 2016
A=[0 0 0 5;1 1 4 3;1 3 4 5;2 0 0 5]
out=find(~all(A,2))

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by