How to extract the "coefficients" of a symbolic matrix?
8 views (last 30 days)
Show older comments
Given a symbolic square matrix y (Matlab code: syms y [n n] matrix;), for a symbolic matrix of the form y+Ay+yB+CyD+EyF+... (where A, B, C, D, E, F... are numerical matrix), how to separate the numerical matrices such as matrices A, B, C, D, E, F... through Matlab?
Example:
syms y [3 3] matrix;
A=randi(2,3,3);
B=randi(2,3,3);
C=randi(2,3,3);
D=randi(2,3,3);
x=y+A*y+y*B+C*y*D
run the code and then I got:
y*symmatrix([2,1,1;2,1,1;1,1,1]) + symmatrix([2,2,1;1,2,2;2,2,2])*y + symmatrix([1,1,2;1,1,1;1,2,2])*y*symmatrix([2,2,2;2,2,1;1,1,1]) + y
Then my question is: give the x=f(y) like above,how do I get all the matrices where y is multiplied by left and right?
I looked up the functions in the Symbolic Math Toolbox and Googled related questions, unfortunately all I could find was about the coefficients of symbolic polynomials or other expressions, and the "coefficients" of symbolic matrices were hard to find relevant answers.
I would appreciate it if you could help me.
Answers (1)
Steven Lord
on 23 Mar 2023
Let's simplify the problem a bit and see if we can solve this for the expression z = y + A*y + y*B. What happens if either A or B commute with y? Then we could write this as (if A commutes with y) z = y + y*A + y*B which simplifies to z = y*(I+A+B). How would you determine unique matrices A and B that generate your result z? The answer is you don't, not without more information or making an arbitrary choice (like A is the identity I which is guaranteed to commute with y.)
For the 1-D case see this post on Cleve Moler's blog. In Cleve's impossible problem we're trying to find A and B that satisfy 3 = A*(1/2)+(1/2)*B. Obviously (1/2) commutes with both A and B so "the" solution is not unique.
So do you have more information about or constraints on your A, B, C, D, etc. matrices?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!