Nested for loop Please help!

조회 수: 19 (최근 30일)
savannah Roemer
savannah Roemer 2015년 11월 28일
답변: Walter Roberson 2015년 11월 28일
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

답변 (1개)

Walter Roberson
Walter Roberson 2015년 11월 28일
tx=j+i
x(i,j)=tx

카테고리

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