How to vectorise this function
Show older comments
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
Answers (2)
NumI = sum(Value < 10000);
Elements = zeros(5000, NumI);
Andrei Bobrov
on 17 Nov 2020
NumI = sum(Value(1:100) < 10000)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!