solve A*x=B
12 views (last 30 days)
Show older comments
Sajjad Malik
on 18 Sep 2018
Commented: Sajjad Malik
on 18 Sep 2018
size of A is 566*664 and B is 566*1.......I tried every function like mldivide, A\b, linsolve but after getting x, when I multiply A with x it does not give me B Matrix.....What should be the reason? Is matrix wrong?
Please note that Rank of Matrix A is 461
0 Comments
Accepted Answer
James Tursa
on 18 Sep 2018
Edited: James Tursa
on 18 Sep 2018
Sounds like you have inconsistent equations. The A\B calculation is doing the best that it can under these circumstances. E.g.,
>> A = [1 2 3;2 4 6] % <-- 2nd row is 2*1st row, so rank deficient
A =
1 2 3
2 4 6
>> B = [1;2] % <-- this particular B is consistent with both rows of A
B =
1
2
>> x = A\B
Warning: Rank deficient, rank = 1, tol = 4.4686e-015.
x =
0
0
0.3333
>> A*x % <-- works because equations are consistent
ans =
1
2
>>
>> B = [1;3] % <-- this particular B is not consistent with the rows of A
B =
1
3
>> x = A\B
Warning: Rank deficient, rank = 1, tol = 4.4686e-015.
x =
0
0
0.4667
>> A*x % <-- does not work because of the inconsistency. This is the best that backslash can do
ans =
1.4000
2.8000
How are your A and B variables being calculated?
4 Comments
James Tursa
on 18 Sep 2018
Look at my examples closely. When you have dependencies in the equations then you will need to have consistent right-hand-side values to match those dependencies in order to be able to find a solution. In my first example I did have that and I was able to find a solution such that A*x matched the B result. But in my second example the B values were not consistent with the dependencies in the A matrix. In this case the A\B is doing the best that it can, but it can't give you what you want because you didn't give it a system that could be solved like you want. It appears to me that this is what might be going on in your system of equations. You have dependencies among them (you admit that up front because your system is rank deficient), but the right-hand-side B values for these dependencies are not consistent. At least not consistent enough for you to get an answer that you are willing to accept.
More Answers (0)
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!