Depolarized fields inside a magnetodielectric sample interfere with the accurate measurement of sample characteristics in a cavity perturbation method. These depolarized fields occur due to the polarization of the test sample, depending on the volume and shape of the sample, in the electromagnetic field. To characterize the magnetodielectric sample more accurately, we proposed an advanced rectangular cavity (RC) perturbation method. In this method, we investigated the change in the resonant frequency and Q-factor of a cavity which depends on the volume, and shape of the sample, and depolarized fields within the sample. The depolarizing factor for calculating the permittivity and permeability of the sample is derived by separating the uniform and depolarized fields within the sample when the sample is inserted in the cavity. These separations of fields play an important role to improve the measurement accuracy. The proposed unified RC perturbation technique is validated initially by measuring the resonant frequency and quality factor and then calculating the complex permittivity and permeability at the TE10l mode. The standard dielectric material (Al2O3) and magnetic material (YIG) samples are measured with the vector network analyzer. The measurement was performed when the magnetodielectric sample having various shapes and volumes inserted into the RC resonator. In comparison with the previous cavity perturbation methods, the permittivity and permeability have been calculated more accurately with various shapes of the test sample, and we also found that the ratio of the maximum sample volume to the cavity for various samples increases about 40%. Based on the proposed method, for a cube-shaped sample, we obtained the complex permittivity and permeability consecutively at each resonance mode without any physical relocation of the test sample. Therefore, the test sample is capable of continuous more accurate and more effective measurement in the desired frequency band without relocation using the proposed technique.