필터 지우기
필터 지우기

How to check if any row has 0?

조회 수: 18 (최근 30일)
Beibit Sautbek
Beibit Sautbek 2016년 8월 8일
답변: Azzi Abdelmalek 2016년 8월 8일
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?!

채택된 답변

Stephen23
Stephen23 2016년 8월 8일
편집: Stephen23 2016년 8월 8일
>> idx = any(A==0,2) % logical index
idx =
1
0
0
1
>> find(idx) % subscript index
ans =
1
4

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 8일
A=[0 0 0 5;1 1 4 3;1 3 4 5;2 0 0 5]
out=find(~all(A,2))

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by