function Ms = MatrixTE (eps1, mu1, eps2, mu2, lambda, kx) //Transfer TE matrix of interface: //eps1, mu1 - relative permittivity and permeability of the left enviroment //eps2, mu2 - relative permittivity and permeability of the right enviroment //lambda - wavelength in vacuum //kx - x-component of the wavevector k0 = 2*%pi/lambda; kz1 = sqrt(eps1.*mu1.*k0.^2 - kx.^2); kz2 = sqrt(eps2.*mu2.*k0.^2 - kx.^2); chi = (kz1./kz2).*(mu2./mu1); Ms = 0.5*[1 + chi, 1 - chi; 1 - chi, 1 + chi]; endfunction function Ml = MatrixHom (eps, mu, h, lambda, kx) //Transfer matrix of the homegeneous layer with the thickness h //eps, mu - relative permittivity and permeability //h - thickness //lambda - wavelength in vaccum //kx - x-component of the wavevector k0 = 2*%pi/lambda; kz = sqrt(eps.*mu.*k0.^2 - kx.^2); Ml = [exp(%i*kz.*h), 0; 0, exp(-%i*kz.*h)]; endfunction function R = OneLayPerpReflectivity(eIn, muIn, eOut, muOut, e, mu, h, lambda) M = MatrixTE(e, mu, eOut, muOut, lambda, 0); M = M*MatrixHom(e, mu, h, lambda, 0); M = M*MatrixTE(eIn, muIn, e, mu, lambda, 0); R = conj(-M(2,1)./M(2,2))*(-M(2,1)./M(2,2)); endfunction function n = RefIndexInterp(Workdir, File, newX) M = fscanfMat (Workdir + "\" + File); nRe = interp(newX, M(:,1), M(:,2), splin(M(:,1), M(:,2))); nIm = interp(newX, M(:,1), M(:,3), splin(M(:,1), M(:,3))); n = nRe + %i*nIm; endfunction function S = DataInterp(Workdir, File, newX) M = fscanfMat (Workdir + "\" + File); S = interp(newX, M(:,1), M(:,2), splin(M(:,1), M(:,2))); endfunction