I'm trying to iterate over a matrix and for some reason I can't seem to generate the new matrix. It just spits out the last value of the iteration.
Looking at other posts I think I have something wrong with the indices of the matrix, but I can't quite figure it out.
Solved! Go to Solution.
The result of a program is the last statement executed. In your case that's the assignment of the last element to the array omega. So the result is that last element.
If you add just omega after the for loop, as what MFra showed, you get the entire array.
Note that there is a specific keyword: 'return' that you can use to define the result of a function. Put anywhere in the function, the item placed as the argument to 'return' is the result of the program. Also be aware that 'return' also stops execution of the program. So if you use it within a program construct (If, For or whatever) the program stops there.
But putting it on the last line of a program certainly is no crime.