I am becoming acquainted with solving basic linear problems in matlab iteratively. So, I apologize for this very basic question.
I am writing a program to solve Ax=f, for a randomly generated matrix (say, of size 6).
I want to extract to break A into M and N, where A=M-N.
I have written a code for this, and I would like to determine the number of iterations that are required before the solution converges. However, my solution does not converge! It blows up to infinity. I have checked to make sure the matrix is non-singular, and I think I have the iterative scheme correct. I would be very grateful if someone could please check my work and let me know where I might be going wrong. Here is my code:
A = randn(scale,scale);
fprintf('Matrix is singular');
fprintf('Matrix is non singular');
x(:,k+1)=M\-N*(x(:,k) + f)
Added a condition:
fprintf('Conditions do not hold')
However, there are times when the random matrix A satisfied this condition, and runs through the while look, and still blows up! Any ideas?