How to vectorise this function

2 Ansichten (letzte 30 Tage)
Master Blabla
Master Blabla am 17 Nov. 2020
Bearbeitet: Stephan am 17 Nov. 2020
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

Antworten (2)

Stephan
Stephan am 17 Nov. 2020
Bearbeitet: Stephan am 17 Nov. 2020
NumI = sum(Value < 10000);
Elements = zeros(5000, NumI);

Andrei Bobrov
Andrei Bobrov am 17 Nov. 2020
NumI = sum(Value(1:100) < 10000)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by