|  |  | 
|---|
| ID | STAT-29 | 
| Title | Vectorize loops where feasible. | 
| Priority | Strongly recommended | 
| Severity level | 6 | 
| Description | Instead of looping over the elements of arrays, apply operations to them in their entirety. Use scalar and implicit expansion, if applicable. | 
| Rationale | Vectorized loops are faster, more robust, more readable, and more maintainable. | 
dataResult = false(size(dataset));
for iElem = 1 : numel(dataset)
    if dataset(iElem) < limit(iElem)
        dataResult(iElem) = true;
    else
        dataResult(iElem) = false;
    end
end
dataResult = dataset < limit;