MATLAB: Negative index of a matrix

negative indexnegative index of a matrix

for n=1:5
for m=-n:n
a(m,n)=m*n
end
end
end
I got an equation like this but I got negative indexes , how can I solve this problem? Thanks for helping.

Best Answer

for n = 1:5
m = -n:n;
for i = 1:numel(m)
A(i, n) = m(i)*n;
end
end