How to vectorise this function

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

Réponses (2)

Stephan
Stephan le 17 Nov 2020
Modifié(e) : Stephan le 17 Nov 2020

0 votes

NumI = sum(Value < 10000);
Elements = zeros(5000, NumI);

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Produits

Tags

Modifié(e) :

le 17 Nov 2020

Community Treasure Hunt

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

Start Hunting!

Translated by