How to extract the "coefficients" of a symbolic matrix?

9 次查看(过去 30 天)
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.
  1 个评论
Paul
Paul 2023-3-23
I thought we might be able to get there with children, but I was wrong
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
x = 
children(x)
Incorrect number or types of inputs or outputs for function 'children'.

请先登录,再进行评论。

回答(1 个)

Steven Lord
Steven Lord 2023-3-23
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?
  1 个评论
TRI
TRI 2023-3-25
Unfortunately, the problem I need to deal with with matlab is that X is just a general symbolic matrix, generally non-commutative, with no exact numeric characteristics

请先登录,再进行评论。

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by