Hannu-Pekka Komsa homepage
Assistant Professor at University of Oulu
Here you can find a miscellaneous collection of Matlab scripts, mostly to help interact with VASP or just general. No guarantee of their correctness. For documentation, see the header of the script.

For the electrostatic correction in the case of charged defects at surfaces/interfaces, there is an example here.
For the electrostatic correction in the case of charged defects in 2D materials, there is an example here.