Using i and j as variables in Matlab -
Using i and j as variables in Matlab -
i
, j
popular variable names (see e.g., this question , this one).
for example, in loops:
for i=1:10, % something... end
as indices matrix:
mat( i, j ) = 4;
why shouldn't used variable names in matlab?
because i
, j
both functions denoting imaginary unit:
so variable called i
or j
override them, potentially silently breaking code complex maths.
possible solutions include using ii
, jj
loop variables instead, or using 1i
whenever i
required represent imaginary unit.
matlab variables naming-conventions
Comments
Post a Comment