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

6 Ansichten (letzte 30 Tage)
How to find the number of ones in each column of a logical matrix?

Akzeptierte Antwort

Star Strider
Star Strider am 11 Feb. 2017
Bearbeitet: Star Strider am 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 Kommentare

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by