A time-domain simulation of the second stage of frequency stabilization in Matlab has been built. Matlab has equation solvers that have variable steps, depending of the complexity of the solution: thus, simulating a fast loop with a unity gain of 300 kHz together with two other loops with unity gains of 1 kHz and 80 Hz is possible. Saturations in the Pound-Drever-Hall signal and at the output of the second stage electronics have been included.