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

 Akzeptierte Antwort

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

Weitere Antworten (3)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 29 Nov. 2012

Community Treasure Hunt

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

Start Hunting!

Translated by