Search code examples
matlabmatrixequations

How Can I Solve Matrix Equation in Matlab


Say I have the following matrix equation

X - B*X*C = D

Where,
X: 3 by 5, to be solved;
B: 3 by 3;
C: 5 by 5;
D: 3 by 5;

Is there any convenient method that I can use for solving the system? fsolve?


Solution

  • In case B or C are invertible, you can check the matrix cookbook section 5.1.10 deals with similar settings:

    X * inv(C) - B * X = D * inv(C)
    

    Can be translated to

    x = inv( kron( eye, -B ) + kron( inv(C)', eye ) ) * d
    

    where x and d are vector-stack of X and D respectively.