Count number 1 in the row
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Quynh tran
il 11 Mag 2017
Commentato: madhan ravi
il 20 Feb 2020
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.
0 Commenti
Risposta accettata
Più risposte (3)
Gennaro Arguzzi
il 11 Mag 2017
Modificato: Gennaro Arguzzi
il 11 Mag 2017
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
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!