A new algorithm is presented to calculate the degrees of freedom (DOFs) of spatial complex mechanisms by using the coefficient matrix of the linear constraint equations. A joint constraint matrix is firstly put forward for each kind of joint to formulate linear constraint equations in terms of spatial fine displacements of joint acting point with respect to joint frame. Two kinds of transformation are then proposed to rewrite all the constraint equations in terms of a set of fine displacements of all bodies and it leads to a set of homogeneous linear equations. The rank of the resulting coefficient matrix stands for the number of effective constraints and therefore the DOFs of the mechanism can be easily figured out. The proposed method can be widely used to solve the problem of DOFs for many spatial complex mechanisms, which may not be correctly solved with traditional approaches. Besides, the proposed method is very easy for implementation.