Reuse of iterator variables
ID | FCNS-13 |
Title | Do not reuse iterator variables within a function. |
Priority | Strongly recommended |
Severity level | 5 |
Description | Do not reuse iterator variables within the same function. Limit the scope of an iterator variable to its for loop. |
Rationale | Prevents renaming all iterators when only the one for a specific loop must be renamed. Also improves readability. |
Avoid:
for iNode = 1 : numel(nodes)
...
end
for iNode = 1 : 2 : 11
...
end
Instead use:
for iNode = 1 : numel(nodes)
...
end
for iValue = 1 : 2 : 11
...
end