This paper presents a heuristic approach to overcome the harmonic elimination problem in multilevel inverters. Particle Swarm Optimization is applied to solve the transcendental equations characterizing the harmonic contents so as to eliminate some lower order harmonics while producing the required fundamental voltage. The optimum switching angles are determined for a unipolar and fundamental frequency switching scheme. This technique can be used for any multilevel inverters with any number of levels; as an example in this paper, 7 and 11-level cascaded inverters are considered. The possible solution sets in linear modulation range are given for both inverters and the computational results are validated with the simulation studies. The obtained results show that the method does effectively suppress any number of specific harmonics and the output voltage waveform has low total harmonic distortion.