Using matrices to solve a system of equations