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:

http://www.mathworks.co.uk/help/matlab/ref/i.html http://www.mathworks.co.uk/help/matlab/ref/j.html

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

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -