How do you get Matlab to return a value for how many 1's are in a vector containing just 1's and zeros

 채택된 답변

>> 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)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

질문:

2012년 11월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by