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

조회 수: 1 (최근 30일)
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)

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 24일
myInv/det(myInv)
  댓글 수: 1
Leo Simon
Leo Simon 2012년 9월 24일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by