I am developing a MATLAB code to compute and plot the intensity distribution at the interface between air and a semi-infinite photonic crystal, aiming to visualize surface waves using the Transfer Matrix Method (see attached figure). While I’ve studied the underlying theory, I’ve found the coding part a bit tricky. If anyone has a sample code or any guidance, I would greatly appreciate your help.