%%My attempt to do FDTD with a staggered grid

I=200;
IPLM=210;
i=[1:I]; iplm=[I+1:IPLM]; it=[i,iplm];
ih=[2:200];
il=[1:199];

%Electric Field Magnetic Field
ez=zeros(1,200); hy=zeros(1,200);
imp=37.7;

%Perfectly absorbing boundary condition
alphamax=.1;
alpha=alphamax*((iplm-I)./I).^2;
plot(alpha);
pause
nsteps=1000;

for t=0:nsteps

hy(il)=hy(il)+(ez(ih)-ez(il))./imp;

ez(ih)=ez(ih)+imp.*(hy(ih)-hy(il));

ez(1)=exp(-(t-30.)*(t-30)/100);

plot(i,hy,i,ez);
pause(.1);

end