Counting the amount of number 1
4 views (last 30 days)
Show older comments
How can I insurt the category name and count the amount of number 1?
For example, I have a matrix but there are only numbers:
1 0 0 0 1 1 1
1 1 0 0 0 0 0
1 1 1 1 1 0 0
0 0 0 1 0 0 1
I want to count the amount of number one from the first low to last. Therefore, computed number should be this:
3 2 1 2 2 1 2
How can I get these numbers?
Thank you for you attention to this question and have a nice day :)
0 Comments
Accepted Answer
David Hill
on 1 Mar 2022
Count=sum(yourMatrix==1);%assuming other than 1's and 0's are possible
0 Comments
More Answers (0)
See Also
Categories
Find more on NaNs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!