How do you get Matlab to return a value for how many 1's are in a vector containing just 1's and zeros
이전 댓글 표시
Like if i have greencars=[11111111000000000000] how to i get Matlab to count how many ones there are?
채택된 답변
추가 답변 (3개)
Adrian Jimenez-Galindo
2012년 11월 29일
1 개 추천
You can use Count(greencars, '==1') Hope this helps.
Azzi Abdelmalek
2012년 11월 29일
a=[1 0 1 1 0 0 0]
numel(find(a))
Walter Roberson
2012년 11월 29일
nnz(greencars)
카테고리
도움말 센터 및 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!