Réponse acceptée

Wayne King
Wayne King le 1 Avr 2012

3 votes

x = randn(1450,1);
indices = find(x>0);
length(indices)
or
count = length(nonzeros(x(x>0)));

Plus de réponses (2)

hidayet beyhan
hidayet beyhan le 28 Mar 2020
Modifié(e) : hidayet beyhan le 28 Mar 2020

1 vote

Or you can use for an array:
x = randn(1450,1);
sum(x>0)
Varshitha Gouri
Varshitha Gouri le 7 Juil 2026 à 3:53
function count = positiveEntries(arr)
count = sum(arr > 0);
end

Catégories

En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by