Loop vectorization

IDSTAT-25
TitleVectorize loops where feasible.
PriorityStrongly recommended
Severity level10
DescriptionInstead of looping over the elements of arrays, apply operations to them in their entirety.
RationaleVectorized loops are faster, more robust, more readable, and more maintainable.

Avoid:

dataResult = false(size(dataset));

for iElem = 1 : numel(dataset)
    if dataset(iElem) < limit(iElem)
        dataResult(iElem) = true;
    else
        dataResult(iElem) = false;
    end
end

Instead use:

dataResult = dataset < limit;