Q-switching pulse and mode-locked square-wave pulse generated in a fiber ring laser based on nonlinear polarization rotation