- #1

- 1,233

- 17

## Main Question or Discussion Point

**Building a matrix using "while" loops? (MATLAB)**

Hello

Here is my code:

Code:

```
i = 1;
j = 1;
S = zeros(11,11);
while i < 12
while j < 12
S(i,j) = Test1(a(i,j),b(i,j),c(i,j));
j = j + 1;
end
i = i + 1;
end
```

My code is only calculating the first row of S, ie. S(2,1) = 0 still. I don't know why the program is ending without adding 1 onto i and repeating the loop, I can only imagine the "while" loop is the wrong way of going about this?

Thanks for any help,

Mike