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

6 vues (au cours des 30 derniers jours)
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)

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 24 Sep 2012
myInv/det(myInv)
  1 commentaire
Leo Simon
Leo Simon le 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by