Negative index of a matrix

1 visualizzazione (ultimi 30 giorni)
Burak
Burak il 2 Ago 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.

Risposta accettata

Thorsten
Thorsten il 2 Ago 2016
Modificato: Thorsten il 2 Ago 2016
for n = 1:5
m = -n:n;
for i = 1:numel(m)
A(i, n) = m(i)*n;
end
end

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by