Negative index of a matrix

1 view (last 30 days)
Burak
Burak on 2 Aug 2016
Edited: Walter Roberson on 4 Aug 2016
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.

Accepted Answer

Thorsten
Thorsten on 2 Aug 2016
Edited: Thorsten on 2 Aug 2016
for n = 1:5
m = -n:n;
for i = 1:numel(m)
A(i, n) = m(i)*n;
end
end

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!