Hi Zhukun,
You could use another vector y to store the values in the vector x and compare the updated x vector to the vector y in each iteration to determine the updated and unupdated values. This idea is illustrated below:
while k<=MaxIter
y = x; % y contains the values of vector x which were updated in the previous iteration.
for i=1:n
x(i)=(b(i)-A(i,1:i-1)*x(1:i-1)-A(i,i-1:n)*x0(i+1:n))/A(i,i);
x0=x;
if norm(A*x-b)/norm(b)<=TOL
disp(x);
info=info+1;
end
end
% At this point, x contains the values updated in the current iteration whereas y
% has the values updated in the previous iteration.
info=-1;
k=k+1;
end
You can also have a look at a similar case: Link
Hope this helps!