필터 지우기
필터 지우기

How can I simplify the result of a symbolic expression with it's coefficients to an expression that only uses the variable names?

조회 수: 3 (최근 30일)
Hello,
I would like to use the symbolic toolbox to validate some equations and I was wondering if it is possible to simplify a result so that it does not show all coefficients but only the defined symbol names. The example only shows a simplified version of the problem, the actual equations are more complex.
Example:
a = sym("a", [3 3])
b = sym("b", [3 3])
c = sym("c", [3 1])
result = a*b*c
Result:
c1*(a1_1*b1_1 + a1_2*b2_1 + a1_3*b3_1) + c2*(a1_1*b1_2 + a1_2*b2_2 + a1_3*b3_2) + c3*(a1_1*b1_3 + a1_2*b2_3 + a1_3*b3_3)
c1*(a2_1*b1_1 + a2_2*b2_1 + a2_3*b3_1) + c2*(a2_1*b1_2 + a2_2*b2_2 + a2_3*b3_2) + c3*(a2_1*b1_3 + a2_2*b2_3 + a2_3*b3_3)
c1*(a3_1*b1_1 + a3_2*b2_1 + a3_3*b3_1) + c2*(a3_1*b1_2 + a3_2*b2_2 + a3_3*b3_2) + c3*(a3_1*b1_3 + a3_2*b2_3 + a3_3*b3_3)
But what I actually would like to see is:
a*b*c

채택된 답변

Walter Roberson
Walter Roberson 2017년 11월 3일
There is no operation for that in the Symbolic Toolbox. Internally, the symbolic engine MuPAD has no provision for the generalized notion of a "matrix" that might be matrix-multiplied as a whole: the symbolic engine only knows about arrays that are populated with something and whose individual elements are acted on.
  댓글 수: 3
Chris B
Chris B 2017년 11월 4일
This is an important information, thank you. I did not know that the symbolic toolbox does not respect the properties of matrices. Is there a way to define that matrix multiplications are non-commutative? Or is there another toolbox that is more suitable for this task?
Walter Roberson
Walter Roberson 2017년 11월 4일
I think it just might be possible to go into the symbolic engine (MuPAD) and tell it to define a new DOMAIN and then fill in function "slots" for each desired operation. It might be a bit tricky to have objects of that DOMAIN cross back and forth between MATLAB and the symbolic engine, but I think something usable might be possible.
When I looked at this a few months ago, I seem to recall that I did have trouble with the print slots (character representation for the MATLAB side), but it has been long enough that I no longer recall exactly what I did.

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by