I have a 1450x1 array. I want to count how many positive entries in array?

 채택된 답변

Wayne King
Wayne King 2012년 4월 1일

3 개 추천

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

추가 답변 (1개)

hidayet beyhan
hidayet beyhan 2020년 3월 28일
편집: hidayet beyhan 2020년 3월 28일

1 개 추천

Or you can use for an array:
x = randn(1450,1);
sum(x>0)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2012년 4월 1일

편집:

2020년 3월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by