Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
How to find the number of ones in each column of a logical matrix?

Risposta accettata

Star Strider
Star Strider il 11 Feb 2017
Modificato: Star Strider il 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 Commenti

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Operating on Diagonal Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by