Why linsolve cannot solve this very simple equation?
    8 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Mr M.
      
 el 19 de Abr. de 2021
  
    
    
    
    
    Respondida: Steven Lord
    
      
 el 19 de Abr. de 2021
            A = [4,2,2; 5,1,3; 6,0,4];
B = [60; 70; 80];
X = linsolve(A,B)
The solution should be 6, 7, 11, since:
4x6 + 2x7 + 2x11 = 60
5x6 + 1x7 + 3x11 = 70
6x6 + 0x7 + 4x11 = 80
But I get the following answer:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.401487e-18.
X = [0; 10; 20]
Why?
0 comentarios
Respuesta aceptada
  Stephan
      
      
 el 19 de Abr. de 2021
        
      Editada: Stephan
      
      
 el 19 de Abr. de 2021
  
      To solve this, the rank should be 3. Row 1 and 3 are not linear independent.
A = [4,2,2; 5,1,3; 6,0,4]
B = [60; 70; 80];
r1 = rank(A)
r2 = rank([A, B])
linsolve gives a correct solution, because there are more then 1 solutions, due to the rank:
>> X = linsolve(A,B)
Test = A*X
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.401487e-18. 
X =
     0
    10
    20
Test =
    60
    70
    80
0 comentarios
Más respuestas (1)
  Steven Lord
    
      
 el 19 de Abr. de 2021
        The vector [6; 7; 11] is a solution to the problem but it is not the only solution.
A = [4,2,2; 5,1,3; 6,0,4];
B = [60; 70; 80];
sol1 = [6; 7; 11];
check = A*sol1-B; % should be close to 0
[sol1, check]
N = null(A); % A*N is close to the 0 vector
sol2 = sol1 + N; % Since A*sol1 = B and A*N = 0, A*(sol1+N) = B+0 = B
check2 = A*sol2-B; % should also be close to 0
[sol2, check2]
sol3 = sol1 + 42*N; % A*(sol1+42*N) = A*sol1 + 42*A*N = B+0 = B
[sol3, A*sol3-B] % Also close to 0
0 comentarios
Ver también
Categorías
				Más información sobre Linear Algebra en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


