Variational approximation to the spectra of systems with confining potentials