In most multiple-input multiple-output (MIMO) communication systems, e.g., Massive MIMO, the antenna spacing is generally no less than half a wavelength. It helps to reduce the mutual coupling and therefore facilitate the system design. The maximum array gain is the number of antennas in this settings. However, when the antenna spacing is made very small, the array gain of a compact array can be proportional to the square of the number of antennas -a value much larger than the traditional array. To achieve this so-called "superdirectivity" however, the calculation of the excitation coefficients (beamforming vector) is known to be a challenging problem. In this paper, we derive the beamforming vector of superdirective arrays based on a novel coupling matrix-enabled method. We also propose an approach to obtain the coupling matrix, which is derived by the spherical wave expansion method and active element pattern. The full-wave electromagnetic simulations are conducted to validate the effectiveness of our proposed method. Simulation results show that when the beamforming vector obtained by our method is applied, the directivity of the designed dipole antenna array has a good agreement with the theoretical values.