% Gaussian wave packet movie. x = -10:0.01:10; tmax = 5; % This is the maximum time kept because after this the % wave function repeats. v = 4; ntime = 50; % number of time steps (times 2) for tcounter = -ntime/2:ntime/2, t = tcounter*tmax/ntime; psi = (2*pi)^-0.25 * (1 + 0.5*i*t)^-0.5 * exp(i*v*(x - 0.5 * v*t)) .* exp(-0.25*((x - v*t).^2)./(1 + 0.5*i*t)); plot(x,abs(psi).^2) xlabel('x') ylabel('|psi|^2') axis([-10 10 0 0.5]) % plot(x,real(psi)) % xlabel('x') % ylabel('real(psi)') % axis([-10 10 -1 1]) % plot(x,imag(psi)) % xlabel('x') % ylabel('imag(psi)') % axis([-10 10 -1 1]) pause(0.5); end