How to find the number of ones in each column of a logical matrix?
3 views (last 30 days)
Show older comments
Rightia Rollmann
on 11 Feb 2017
Commented: Star Strider
on 11 Feb 2017
How to find the number of ones in each column of a logical matrix?
0 Comments
Accepted Answer
Star Strider
on 11 Feb 2017
Edited: Star Strider
on 11 Feb 2017
Use the sum function.
Example:
A = logical(randi([0 1], 10,5)); % Create Data
Ones_In_Each_Column = sum(A) % Sum The Columns
EDIT — Added ‘Example’ code.
4 Comments
More Answers (0)
See Also
Categories
Find more on Particle & Nuclear Physics 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!