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

7 次查看(过去 30 天)
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