MATLAB: Does the second matrix start with zeros

matrix for loop

for i=-10:10
if i<0
a(i+11)=i;
if i>0
b(i+10)=i;
end
end
end
Out of curiosity, why, if I print b, would the matrix start with 10 zeros?

Best Answer

MATLAB assigns zero to the previous indices, for better understanding:
clear a
a(11) = 1; % now you will see elements from 1-10 are filled with zeros, if a doesn’t exist already in the workspace
Perhaps what you want is:
ii = -10 : 10;
a = ii(ii < 0)
b = ii(ii >= 0)