How to vectorise this function

조회 수: 1 (최근 30일)
Master Blabla
Master Blabla 2020년 11월 17일
편집: Stephan 2020년 11월 17일
How to vectorize this function:
NumI = 0;
for i=1:100
if Value(i) < 10000
NumI = NumI +1;
end
end
Elements = zeros(5000, NumI);
%% Value - array of float values

답변 (2개)

Stephan
Stephan 2020년 11월 17일
편집: Stephan 2020년 11월 17일
NumI = sum(Value < 10000);
Elements = zeros(5000, NumI);

Andrei Bobrov
Andrei Bobrov 2020년 11월 17일
NumI = sum(Value(1:100) < 10000)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by