Solving system of equations using Lu Method and "NaN" results through final matrix
    4 views (last 30 days)
  
       Show older comments
    
Hello All,
I have utilized the lu function to solve a systems of equations with 12 equations and 12 unknowns. I have inputted my A and B matrix, have used the lu function:
[L,U] = lu(A);
to solve for L and U and then running the operation of:
y = L\B
x=U\y
to solve for my 12 X values. However the results matrix after solving for X is a 12X1 matrix with 10 values being "NaN" and the last two being "Inf" and a warning which says "Warning: Matrix is singular to working precision." When solving for y I do get actual values in each row of the 12x1.
Does anyone know why I am getting this warning for my x value? And not getting values for my x but getting values for my y.
0 Comments
Answers (1)
  John D'Errico
      
      
 on 11 Feb 2017
        Your equations form a singular system. Just wanting a solution to exist does not mean there is a solution to all systems of equations.
As far as asking why only ONE of those triangular solves gave you garbage, this is easy if you understand the LU decomposition.
I'll show you by example, for a very singular system:
[L,U] = lu(ones(3))
L =
     1     0     0
     1     1     0
     1     0     1
U =
     1     1     1
     0     0     0
     0     0     0
See that even though the original matrix was singular, having rank only 1, L is NOT singular. So the first solve, computing Y as you did will succeed.
Just linear algebra 101.
0 Comments
See Also
Categories
				Find more on Linear Algebra in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
