MATLAB: How to save the number of iterations in while loop

gauss-seidelnumber of iterations

I'm implementing a code to solve linear algebraic system with Gauss-Seidel algorithm. I need to save the number of iterations that are done by the while loop in the iterative process. how can i do?

Best Answer

Set up a counter variable.
Example:
count = 0;
while -CONDITION-
-DO CALCULATIONS-
-UPDATE CONDITION VARIABLE-
count = count + 1;
end