function lax_wendroff(r);

M = 1000;
N = 50;

u = zeros(N,M);
u(:,1:M/2) = 0;
u(:,M/2+1:M) = 1;

for n = 1:N
    up1 = [u(n,2:M) u(n,1)];
    un1 = [u(n,M) u(n,1:M-1)];
    u(n+1,:) = u(n,:) + r/2*(up1 - un1) + (r^2)/2*(up1 - 2*u(n,:) + un1);
end

figure;mesh(u(:,M/2-100:M/2+100));
figure;plot(u(N,M/2-100:M/2+100));hold on;plot(u(1,M/2-100:M/2+100),'r');
axis([0 250 -0.5 1.5]);
title('Lax-Wendroff');
xlabel('x');
ylabel('u(x)');
legend('n = 50','n = 0');