We report calculations of the electric-field gradients ͑EFGs͒ in pure and doped CeMIn 5 ͑M = Co, Rh, and Ir͒ compounds and compare with experiment. The degree to which the Ce 4f electron is localized is treated within various models: the local-density approximation, generalized gradient approximation ͑GGA͒, GGA+ U, and 4f-core approaches. We find that there is a correlation between the observed EFG and whether the 4f electron participates in the band formation or not. We also find that the EFG evolves linearly with Sn doping in CeRhIn 5 , suggesting the electronic structure is modified by doping. In contrast, the observed EFG in CeCoIn 5 doped with Cd changes little with doping. These results indicate that nuclear quadrupolar resonance is a sensitive probe of electronic structure.