Inverse of non-square matrix, pinv not working....
4 views (last 30 days)
Show older comments
In my physics work, I need to solve for B in the matrix equation A=B*C, where A has dimensions 90000x252 and C has dimensions 64x252, so B should have dimensions 90000x64.
My thought was that A'=C'*B' so then I could use pinv to solve pinv(C')*A'=B' so B=(pinv(C')*A')'
While I understand this would not be a unique solution the problem that I am having is that the result I get for B seems to be incorrect. When I test this by multiplying B*C, I get a matrix which (other than having the same dimensions) does not resemble A.
Any help on this matter would be greatly appreciated. Thanks
0 Comments
Answers (1)
Walter Roberson
on 5 Aug 2011
You should probably be using the mldivide ('\') operator rather than pinv() and matrix multiplication:
B = A.' \ C.' ;
3 Comments
Walter Roberson
on 6 Aug 2011
I had the operations the wrong way around: it should have been
B = C.' \ A.'
A shorter way of expressing that is
B = A / C
But yes, B*C will not then be the same as A.
For example, let
A = reshape(1:45,9,5);
C = reshape(sqrt(1:20),4,5);
B = A / C;
then if you compare A*pinv(C) to B you will find the differences are on the order of +/- 1E-9; the algebraic tests will all be consistent to within tolerance. But B*C will differ from A by up to 0.235 . It's an algebraic fact of life that you will not get an exact reconstruction when you work with non-square matrices.
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!