Logical indexing
ID | STAT-28 |
Title | Use logical indexing instead of linear or subscript indexing where possible. |
Priority | Strongly recommended |
Severity level | 6 |
Description | To speed up your code, use logical indexing instead of linear or subscript indexing where possible. |
Rationale | Logical indexing is faster and more readable. |
Avoid:
index = intersect(find(v > MIN), find(v < MAX));
Instead use:
index = (v > MIN) & (v < MAX);