So ima trying to get a matrix from a nested loop but i keep getting a one answer SIGMA in the workspace but thanks to the disp(SIGMA) i get a bunch of numbers in the command window. Why are they different?

1 次查看(过去 30 天)
for x=0:30
for y=0:30
SIGMA=(x*y);
end
end

回答(1 个)

Walter Roberson
Walter Roberson 2017-11-27
Change
SIGMA=(x*y);
to
SIGMA(x+1,y+1) = (x*y);

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by