MATLAB: “For improved robustness, consider replacing i and j by 1i” – Is this an error

erroriMATLABreplace

I would like to know if the red line is an error. It says that: "For improved robustness, consider replacing i and j by 1i". I need to replace or I can just leave it as it is? Thanks

Best Answer

Matlab uses i and j for imaginary i, or sqrt(-1). This lead to a lot of issues because i and j are often used as counter variables for the for and while loops. Example:
for i = 1:10
plot(ano3, medial5(i-7), 'k'); %Did you mean imaginary i or counter variable i?
end
In your case, it depends on if i is the imaginary i or a variable i. If imaginary i, take their advice and use 1i, or you may end up spending hours looking for the i bug. If variable i, you must declare i before hand, or it'll assume i = 1i.