How do you get Matlab to return a value for how many 1's are in a vector containing just 1's and zeros
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Like if i have greencars=[11111111000000000000] how to i get Matlab to count how many ones there are?
0 Commenti
Risposta accettata
Babak
il 29 Nov 2012
>> greencars=[1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0]
>> numer_of_ones = sum(greencars)
0 Commenti
Più risposte (3)
Adrian Jimenez-Galindo
il 29 Nov 2012
You can use Count(greencars, '==1') Hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!