## Takes in the previous and the present profiles and iterates to find ## the profile in the next time step. function ynext=propagate(ynow,yprev,r) ## Quick and dirty way to fix boundary conditions -- for each step ## they are the same as the previous step. ynext=ynow; for i=2:length(ynow)-1 ynext(i) = 2*(1-r^2)*ynow(i)-yprev(i)+r^2*(ynow(i+1)+ynow(i-1)); endfor endfunction