A method of writing symbolically the transfer matrix of a compartmental model