Dear all, I have this range:
x=[0 0 0 1 0 1 0 0]
I want to count number 1 in this row. Could you help me? Thanks.

 Réponse acceptée

Quynh tran
Quynh tran le 11 Mai 2017

0 votes

Thanks everybody, I had my solution
count=sum(x)

Plus de réponses (3)

Gennaro Arguzzi
Gennaro Arguzzi le 11 Mai 2017
Modifié(e) : Gennaro Arguzzi le 11 Mai 2017

0 votes

z=[0 0 0 1 0 1 0 0];
a=length(z);
b=0;
for i=1:a
if(z(i)==1)
b=b+1;
end
end
KSSV
KSSV le 11 Mai 2017

0 votes

x=[0 0 0 1 0 1 0 0] ;
nnz(x)
find(x==1)
x(x==1)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by