Nested for loop Please help!

1 view (last 30 days)
savannah Roemer
savannah Roemer on 28 Nov 2015
Answered: Walter Roberson on 28 Nov 2015
clear
clc
x=zeros(10,10);
for j=1:10;
for i=1:10;
x=j+i
x(i,j)=x
i=i+1
end
j=j+1
end
so my result matrix would look like
2 3 4 5 6 7 8 9 10 11
3 4 5 6 7 8 9 10 11 12
4 5 6 7 8 9 10 11 12 13
5 6 7 8 9 10 11 12 13 14
6 7 8 9 10 11 12 13 14 15
7 8 9 10 11 12 13 14 15 16
8 9 10 11 12 13 14 15 16 17
9 10 11 12 13 14 15 16 17 18
10 11 12 13 14 15 16 17 18 19
11 12 13 14 15 16 17 18 19 20

Answers (1)

Walter Roberson
Walter Roberson on 28 Nov 2015
tx=j+i
x(i,j)=tx

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!