From: Andy on
I have access to MATLAB now, and I ran your script, but it did not produce the error you said. Instead, it produced an index out of bounds error because you don't do any error-checking in your code to check the sizes of things. Also, you seem to have thrown periods in front of lots of operators unnecessarily (but maybe not, I suppose it depends on the expected input).

When I run your script, sigma has size 1x501 and so does e_r. Therefore, c1 has size 1x501, and, inside your first double-for loop, you try to access c1(2,2), which results in an error. Assuming that e_r is always a 1xNz vector (as you have in your script), and assuming e_0 is always a scalar constant, this loop will always return this error because you start with ii and jj equal to 2.