Magnetic gears (MGs) have many advantages over mechanical gears, including high efficiency, no contact, no lubrication, and low noise. Even though MGs are energy-efficient, cogging torque and torque ripple are always challenging, especially in low-speed applications. Generally, the cancellation of cogging torque enhances the performance of the operation of PM machines. This article proposes an approach based on slicing technique through which reduced cogging torque and improved torque density can be achieved in MGs. The two-dimensional finite element method (2D FEM) has been used to analyze the models using Simcenter and MATLAB software packages. The results show that the elimination of cogging torque of the proposed models compared to the base model is 97.53% on the inner rotor, and that of the outer rotor is 42.23%. Also, the torque density is slightly improved by 0.05% on the inner rotor while 0.1% improvement on the outer rotor is obtained.