Inverse of non-square matrix, pinv not working....

4 views (last 30 days)
Si
Si on 5 Aug 2011
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

Answers (1)

Walter Roberson
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
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.
Si
Si on 6 Aug 2011
Ok, I had tried B = A/C but that wouldn't work because C was nearly singular,s o I got very incorrect answers. I had been able to get somewhat decent reconstructions but they weren't working for my application, so I was just hoping I could find some way to improve on them....

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!