Can someone help me understand how this loop works?
Show older comments
n=4;
A = ones(n);
for i= 1:n
for j= 1:n
if (i>2) && (j>2)
A(i,j) = A(i-1,j) + A(i,j-1);
elseif (i<3) && (j<3)
A(i,j) = A(i+1,j) + A(i,j+1);
end
end
end
A
1 Comment
Ruslan Khoguev
on 23 Nov 2015
Accepted Answer
More Answers (0)
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!