- that there are infinite entries in the matrix (but these would typically lead to NaN)
- that the matrix has a quite high condition number, leading to overflows in the calculation (NaN might well show up as well). This can include the case where the matrix is singular algebraically but the determinant is not exact zero due to floating point round-off
How to find which equation that have "Warning: Solution does not exist because the system is inconsistent"
15 次查看(过去 30 天)
显示 更早的评论
I have big matrix and want to solve it with "\".
Ax=B so I use
[A,B]=equationsToMatrix(k,q)
x=A\B
but the matrix cannot be solved, the solution of x = Inf
How to know which one equation that makes x dont have solutions?
0 个评论
回答(1 个)
Walter Roberson
2022-12-4
If you get inf on output, there are few possibilities:
Example:
format long g
M = imag(hilbert(magic(5))) / 1e5
rank(M)
cond(M)
M\(1:5).'
If you do not have actual infinite entries then there isn't "one equation" that makes it "not have a solution". Consider for example
[1 2 3
2 4 6
3 5 9]
Which "one equation" makes this not have an answer? You might at first say that it is the [2 4 6] because that is a constant multiple times an earlier row, but you could just as well say that the problem is the [1 2 3] for being a constant multiple of [2 4 6] .
When you use EquationsToMatrix() then you are working with systems of symbolic equations that are probably not inherently ordered. In such cases it could not be considered to be the "fault" of the second matrix that the system is not consistent; if you had happened to enter the equations in a different order then it would have been a different row "at fault".
It is fair to ask which rows are linearly dependent on earlier rows, understanding that does not mean that such rows are "wrong" (could be the other rows fault). I am not sure what a robust solution for that is, but it looks to me as if you can proceed to
[P,r] = rref(M.');
dependent_rows = setdiff(1:size(M,1), r)
This particular example happens to indicate that the last row is the first dependent row, but if you do something like
N = 20;
A = rand(N);
RRR = randperm(N,3)
A(RRR(1),:) = A(RRR(2),:) * 5 - A(RRR(3),:) * 19;
[P,r] = rref(A.');
dependent_rows = setdiff(1:N, r)
dependent_rows == max(RRR)
We were successful in identifying a dependent row. We constructed row 6 as dependent on row 3 and 18, but mathematically that is equivalent to saying that row 18 is dependent on rows 3 and 6 -- which further emphasizes my point earlier that you have to be careful about which equation you blame.
7 个评论
Torsten
2022-12-14
if rank(C) = rank([C,S]), you can solve the system.
if rank(C) = rank([C,S]) -1, the system is inconsistent.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!