필터 지우기
필터 지우기

Symbolic matrix algebra calculation

조회 수: 1 (최근 30일)
Wouter
Wouter 2014년 9월 26일
댓글: Roger Stafford 2014년 9월 26일
I want to do some algebra with matrices. However when I would create
A = sym('A',2)
B = sym('B',2)
and then
A*B
Then
[ A2_2/(A1_1*A2_2 - A1_2*A2_1), -A1_2/(A1_1*A2_2 - A1_2*A2_1)]
[ -A2_1/(A1_1*A2_2 - A1_2*A2_1), A1_1/(A1_1*A2_2 - A1_2*A2_1)]
Roles out. While I still want it to be A*B. Now I cannot use normal symbolic variables since they change the order of the multiplication, which is normally not allowed with matrices.
syms a b
(a + b)*b
becomes
b*(a + b)
Which is not correct for matrices. Is it possible to create symbolic variables which do not change the order?

답변 (1개)

Roger Stafford
Roger Stafford 2014년 9월 26일
편집: Roger Stafford 2014년 9월 26일
If you use the form a = sym('a',n) or a = sym('a',[m.n]) to declare symbolic vectors or matrices, I seriously doubt that the order of multiplication with other such symbolic vectors or matrices will ever be reversed, so that is presumably what you have to do to handle your algebra. Note that without such detailed descriptions as to size, matlab would not be able to recognize when a proposed multiplication was improper due to non-matching inner dimensions.
  댓글 수: 3
Roger Stafford
Roger Stafford 2014년 9월 26일
I think you mean you don't want that output when you type inv(A)*A or A*inv(A). The output you mentioned can't happen unless you have defined B as B = inv(A). (Note that in this case it is legitimate to reverse the order of multiplication - A*B is indeed then equal to B*A.)
Roger Stafford
Roger Stafford 2014년 9월 26일
I don't know how you can avoid getting the expanded form displayed when you type A*B. However if you write
C = A*B;
with a semicolon you should not see an expansion displayed just as is the case with numerical variables.

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by