Your code does run. You can use the debugger to check this: Set a breakpoint inside the loop (the red dots on the left), then Matlab stops there at the execution. See Matlab: Debug. Now step through the code line by line and examine the local variables in the WorkSpace-browswer or in the command window. Because your assumption "only for k=0 and does not run for the rest" is not correct, but you do not explain, why you assume this, it is difficult to suggest an improvement. Without knowing, what the code should calculate, I cannot guess if it contains a bug.
Perhaps "b=0;" should appear inside the loop. "summa(i) = b" should be sufficient, because summa is predefined with zeros.
Best Answer