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

 Accepted Answer

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

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Asked:

on 29 Nov 2012

Community Treasure Hunt

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

Start Hunting!