This paper introduces a method for incorporating matlab-script based power electronics filtering and control algorithm into Simulink environment. By doing so, the filter and control performance is very much close to reality when being implemented in microcontroller. This further shortens the distance between simulation and physical implementation. It provides circuit and its control designer with hands-on experiences. It could also reduce time used in troubleshooting when implementing prototype. Its plausibility has been proved by applying it to active power filter.Index Terms-Active power filter, digital filter, power inverter, simulink.