How can I simplify the result of a symbolic expression with it's coefficients to an expression that only uses the variable names?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Chris B
el 2 de Nov. de 2017
Comentada: Walter Roberson
el 4 de Nov. de 2017
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
0 comentarios
Respuesta aceptada
Walter Roberson
el 3 de Nov. de 2017
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 comentarios
Walter Roberson
el 4 de Nov. de 2017
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.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!