Partition functions for matrix models and isomonodromic tau functions