In this paper, we have presented an analytical solution to extract the effective properties of acoustic metamaterials from the measured complex transmission and reflection coefficients when the metamaterial and impedance tube have different sizes. We have first modeled this problem as a bilayer metamaterial located inside a duct and treated the air gap as a separate domain. Then we have mathematically proved that the effective properties of acoustic metamaterial can be obtained by solving a set of eight linear equations when the dimensions are known. Finally, we have evaluated the proposed method with results from numerical simulations. It is shown that the proposed method can calculate the effective refractive index and impedance with an error of below 1\%. This method provides an efficient approach to analyzing the effective properties of acoustic metamaterials of various sizes.