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

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일

1 개 추천

find(all(prec == 0, 2))
No need for a loop. Use all.

추가 답변 (1개)

bilgesu ak
bilgesu ak 2015년 5월 22일

0 개 추천

Thanks very much, it works!

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

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

질문:

2015년 5월 22일

댓글:

2015년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by