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

4 vues (au cours des 30 derniers jours)
bilgesu ak
bilgesu ak le 22 Mai 2015
Commenté : John D'Errico le 22 Mai 2015
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...

Réponse acceptée

Guillaume
Guillaume le 22 Mai 2015
find(all(prec == 0, 2))
No need for a loop. Use all.

Plus de réponses (1)

bilgesu ak
bilgesu ak le 22 Mai 2015
Thanks very much, it works!

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by