How to update a matrix variable

I was trying to implemnt a data driven thermal model in pybamm. It requires to evolve a hidden state which can be something like this: h_t=(A * h_t-1 + B * input) * dt + h_t-1, this hidden state is a matrix, I am just wondering if there is a way to create a thermal submodel which calculate the hidden state in rhs.