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 ビュー (過去 30 日間)
古いコメントを表示
Like if i have greencars=[11111111000000000000] how to i get Matlab to count how many ones there are?
0 件のコメント
採用された回答
Babak
2012 年 11 月 29 日
>> 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 件のコメント
その他の回答 (3 件)
Adrian Jimenez-Galindo
2012 年 11 月 29 日
You can use Count(greencars, '==1') Hope this helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!