Akzeptierte Antwort

Wayne King
Wayne King am 1 Apr. 2012

3 Stimmen

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

Weitere Antworten (2)

hidayet beyhan
hidayet beyhan am 28 Mär. 2020
Bearbeitet: hidayet beyhan am 28 Mär. 2020

1 Stimme

Or you can use for an array:
x = randn(1450,1);
sum(x>0)
Varshitha Gouri
Varshitha Gouri am 7 Jul. 2026 um 3:53

0 Stimmen

function count = positiveEntries(arr)
count = sum(arr > 0);
end

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 1 Apr. 2012

Beantwortet:

am 7 Jul. 2026 um 3:53

Community Treasure Hunt

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

Start Hunting!

Translated by