Effective matrix models for deconfinement in SU(N) and G(2) gauge theories