Compensated pulsed alternator (CPA) is considered one of the most potential pulsed power supplies for electromagnetic railguns, due to its high energy density and power density. In this paper, a co-simulation method of a CPA powered railgun system is proposed. The railgun model was constructed on the Matlab/Simulink platform. In order to obtain a more accurate simulation result of the railgun launching process, the kinetic resistance is taken into account in the process of building the railgun model. The CPA model is set up in FLUX2-D so as to calculate the dynamic inductance of the alternator precisely. The coupling module between the two software packages is utilized to achieve the co-simulation of the CPA powered railgun system. The simulation results indicate that the optimum length (the displacement of the projectile exiting the muzzle while the current exactly reduces to zero) of the barrel has the relation with trigger moment of alternator. The muzzle velocity of the projectile would decrease when the trigger moment was delayed or the distance between the breech and the armature becomes farther.