- The matrix A itself is changing during the execution of the loop. Check if the matrix is varying inside the loop due to some reason.
- Numerical inconsistencies in the calculations can cause variation in the results. “eig” uses approximate numerical nethods for calculating eigen values and eigen vectors. To achieve more precision in the results consider using the “eigs” command as it uses more advanced algorithms for computing eigen values and eigen vectors. On the other hand you can also consider using the “balanceOption” input argument in “eig” command to perform diagonal scaling on the matrix to get more accurate results.
- https://www.mathworks.com/help/matlab/ref/balance.html
- https://www.mathworks.com/help/matlab/ref/eig.html?a#btgapg5-1-balanceOption