Can't get "collect" to extract the determinant of the inverse of a symbolic matrix.

1 view (last 30 days)
I often invert complex symbolic matrices and end up with an impossibly complex result because matlab divides each term in the inverse by the determinant of the matrix. I'd like to extract the determinant as a common factor, but collect doesn't seem to work. For example, consider
syms a b c d
myMatrix = [a,b;c,d];
myInv = inv(myMatrix);
simple(myInv)
This returns
[ d/(a*d - b*c), -b/(a*d - b*c)]
[ -c/(a*d - b*c), a/(a*d - b*c)]
None of the commands invoked by "simple" do anything to the matrix. I'd like to find something that would return:
[ d,-b;-c,a]/(a*d-b*c)

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 24 Sep 2012
myInv/det(myInv)
  1 Comment
Leo Simon
Leo Simon on 24 Sep 2012
Wow, that was easy, thanks! Actually for my purposes, I think
inv(myMatrix/det(myMatrix))
is what I want, so that for a complex matrix expression I don't have to generate the nasty myInv and then get rid of the determinant.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!