Nevermind, I figured out the solution. It was because of the way I was accessing the elements of the vector. If I use expand to turn my vector into the same dimension as the matrix, it works. Thank you.