In order to carry out the whole process of UAV flight simulation quickly and efficiently in Matlab environment, CMEX six degrees of freedom model was introduced to improve the simulation efficiency, task scheduling algorithm was written to realize the switching of multi-mode control laws. In addition to the model, the whole software was programmed in M language which is simple and easy to debug. The control law and the guidance law of a uav were tested in the software, the results show the usefulness of the simulation environment.