This paper establishes a simulation model of a simplified power system with transformer differential protection based on an embedded Matlab function block. The differential protection consists of percentage restraint differential protection, second harmonic restraint, differential current instantaneous trip protection and over-excitation protection. The model is able to correctly simulate the transformer’s inrush current and internal and external faults. The results from the simulation show that the circuit breaker correctly operates for a transformer internal fault and provides a good braking effect for an external fault. In addition, the protection model is able to identify the inrush current of the transformer and avoid a protection mis-trip event.