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

4 ビュー (過去 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 件のコメント
John D'Errico
John D'Errico 2015 年 5 月 22 日
Or even this...
find(all(~prec,2))

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

その他の回答 (1 件)

bilgesu ak
bilgesu ak 2015 年 5 月 22 日
Thanks very much, it works!

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by