How to find the number of ones in each column of a logical matrix?

2 次查看(过去 30 天)
How to find the number of ones in each column of a logical matrix?

采纳的回答

Star Strider
Star Strider 2017-2-11
编辑:Star Strider 2017-2-11
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by