MATLAB: I have in trouble with the codes.. help!

helpMATLAB

format long
while C(k) > tol
X(k, :) = [ x1(k), x2(k) ] ;
k = k + 1;
end
line 18: while C(k) > tol
I'm doing HW about fixed point iteration in nonlinear system.
There's an error message on line 18 all the time even I fixed the code.elements
Can you help me?? I just set the C(k) as scalar, but with error; index exceeds the number of array

Best Answer

You increment ‘k’ in the loop, however only ‘C(1)’ exists, not ‘C(2)’ or any beyond that.
That is the problem. I have no idea what you are doing, so I cannot suggest a solution, other than to re-calculate ‘C(k)’ in the loop as well.