I tried to be diligent in the search for documentation and am empty.
I am trying to define or exclude terms in an expression in matrix form. My problem seems to be different from polynomial factoring (since I plan to implement a function phi(x,y,z) = a_1 + a_2*x + a_3*y + a_4*z)
import sympy
from sympy import symbols, pprint
from sympy.solvers import solve
phi_1, phi_2, x, a_1, a_2, L = symbols("phi_1, phi_2, x, a_1, a_2, L")
phi = a_1 + a_2*x
shape_coeffs = solve([Eq(phi_1, phi).subs({x:0}), Eq(phi_2, phi).subs({x:L})], (a_1, a_2))
pprint(shape_coeffs)
phi = phi.subs(shape_coeffs)
pprint(phi)
This works as expected, however, I would like to include this in matrix form, where:

I tried factor(), cancel(), as_coefficient()without success. On paper, this is a trivial problem. What am I missing in a sympy solution? Thank.
Valid Method: Taken as an Answer
C_1, C_2 = symbols("C_1, C_2", cls=Wild)
N = Matrix(1,2, [C_1, C_2])
N = N.subs(phi.match(C_1*phi_1 + C_2*phi_2))
phi_i = Matrix([phi_1, phi_2])
display(Math("\phi(x)_{answered} = " + latex(N) + "\ * " + latex(phi_i)))
