Nested for loop Please help!

1 visualización (últimos 30 días)
savannah Roemer
savannah Roemer el 28 de Nov. de 2015
Respondida: Walter Roberson el 28 de Nov. de 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

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Nov. de 2015
tx=j+i
x(i,j)=tx

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by