Using i and j as variables in MATLAB

Because i and j are both functions denoting the imaginary unit:

So a variable called i or j will override them, potentially silently breaking code that does complex maths.

Possible solutions include using ii and jj as loop variables instead, or using 1i whenever i is required to represent the imaginary unit.

Leave a Comment