필터 지우기
필터 지우기

how can I find the rows number that all are zero?

조회 수: 2 (최근 30일)
bilgesu ak
bilgesu ak 2015년 5월 22일
댓글: John D'Errico 2015년 5월 22일
I have a matrix for example:
prec=[ 0 0 0 0; 0 0 0 0; 1 0 0 1; 0 1 0 1];
I want to find the rows number that all the elements are zero i.e. first and second row. I write my cod as:
for i=1:4;
x=find(prec(i,:))==0
end
but it gives wrong answer. How can I write it?
Thanks in advance...

채택된 답변

Guillaume
Guillaume 2015년 5월 22일
find(all(prec == 0, 2))
No need for a loop. Use all.

추가 답변 (1개)

bilgesu ak
bilgesu ak 2015년 5월 22일
Thanks very much, it works!

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by