Matrix models, gauge theory and emergent geometry