MATLAB: Scalar coefficients for a linear combination of matrices

linear combinationMATLABmatrices

Say I have the equation : aM + bN = C Where M, N and C are matrices and a, b are scalars. How do I find them knowing that C is a linear combination of M and N?

Best Answer

HI Pierre-Luc
[M(:) N(:)]\C(:) produces [a;b]
This assumes that M and N are not proportional to each other, otherwise there are an infinite number of solutions.