nlast=500;
xini=-2.0;xlast=3.0;NN=200;
Deltax=(xlast-xini)/NN;iini=0;
ilast=IntegerPart[(xlast-xini)/Deltax];c=0.005;k=10;x0=0.0;
Deltat=Deltax/c;
r=c*Deltat/Deltax;


f[x_]:=Exp[-k*(x-x0)^2];
Plot[f[x],{x,xini,xlast},PlotRange->All];
For[i=iini,i≤ilast,i++,
x[i]=xini+(i-1)*Deltax;
y[i,-1]=f[x[i]];
y[i,0]=f[x[i]];
];(*end for i*)

txy[0]=Table[{x[i],y[i,-1]},{i,iini,ilast}];
ListPlot[txy[0],(*Joined->True,*)PlotRange->All]

(*For[n=0,n≤ nlast,n++,
y[iini-1,n]=0;y[ilast+1,n]=0;
];(*end for n*)
*)


For[n=0,n≤ nlast,n++,
For[i=iini+1,i≤ ilast-1,i++,
x[i]=xini+Deltax*(i-1);
y[i,n+1]=2(1-r^2)*y[i,n]-y[i,n-1]+r^2(y[i+1,n]+y[i-1,n]);
(*Print[{n+1,i,y[i,n+1]}]*)
];(*end for i*)
y[iini,n+1]=0;y[ilast,n+1]=0;
txy[n+1]=Table[{x[i],y[i,n+1]},{i,iini,ilast}];
];(*end for n*)
(*ListPlot[txy[3]]*)

Manipulate[
ListPlot[txy[n],PlotRange->{{xini,xlast},{-2,2}}],{n,0,nlast,1}
](*end manipulate*)