
clear

t_0 = 0; t_f = 5; N = 50; M = 500;
[u_up,u_exact,x,t] = explicit_upwind(@f,t_0,t_f,M,N);
for j=1:60, 
    plot(x,u_up(:,j),'.-'), 
    axis([0,2*pi,-1,2]), 
    title('explicit upwind','FontSize',16);
    figure(1), 
    pause(1), 
end
display('hit any key for more')
pause
c = 1/2;
for j=1:length(t),
    % plot the exact solution
    plot(x,u_exact(:,j),'r-','LineWidth',2);
    hold on,
    plot(x,u_up(:,j),'-','LineWidth',2),
    hold off;
    axis([0,2*pi,-1,2]),
    title('explicit upwind','FontSize',16);
    figure(1),
end
display('hit any key for more')
pause

[u_cd,u_exact,x,t] = centered_difference(@f,t_0,t_f,M,N);
for j=1:60, 
    plot(x,u_cd(:,j),'.-'), 
    axis([0,2*pi,-1,2]), 
    title('centered difference','FontSize',16);
    figure(1), 
    pause(1), 
end
display('hit any key for more')
pause

clf
for j=1:length(t), 
    % plot the exact solution
    plot(x,u_exact(:,j),'r-','LineWidth',2);
    hold on,
    plot(x,u_cd(:,j),'-'), 
    hold off
    axis([0,2*pi,-1,2]),
    title('centered difference','FontSize',16);
    figure(1), 
end
display('hit any key for more')
pause

[u_lf,u_exact,x,t] = lax_friedrichs(@f,t_0,t_f,M,N);
for j=1:60, 
    plot(x,u_lf(:,j),'.-'), 
    axis([0,2*pi,-1,2]), 
    title('Lax Friedrichs','FontSize',16);
    figure(1), 
    pause(1), 
end
display('hit any key for more')
pause
c = 1/2;
for j=1:length(t),
    % plot the exact solution
    plot(x,u_exact(:,j),'r-','LineWidth',2);
    hold on,
    plot(x,u_lf(:,j),'-','LineWidth',2),
    hold off;
    axis([0,2*pi,-1,2]),
    title('Lax-Friedrichs','FontSize',16);
    figure(1),
end
display('hit any key for more')
pause

j = 60;
plot(x+c*t(j),u_lf(:,1),'r-','LineWidth',2);
hold on,
plot(x,u_lf(:,j),'-','LineWidth',2),
plot(x,u_up(:,j),'k-','LineWidth',2),
axis([0,2*pi,-1,2]),
title('Explicit Upwind: Black, Lax-Friedrichs: Blue','FontSize',16);
figure(1)
hold off

display('hit any key for more')
pause

[u_lw,u_exact,x,t] = lax_wendroff(@f,t_0,t_f,M,N);
for j=1:60, 
    plot(x,u_lw(:,j),'.-'), 
    axis([0,2*pi,-1,2]), 
    title('Lax-Wendroff','FontSize',16);
    figure(1), 
    pause(1), 
end
display('hit any key for more')
pause
c = 1/2;
for j=1:length(t),
    % plot the exact solution
    plot(x,u_exact(:,j),'r-','LineWidth',2);
    hold on,
    plot(x,u_lw(:,j),'-','LineWidth',2),
    hold off;
    axis([0,2*pi,-1,2]),
    title('Lax-Wendroff','FontSize',16);
    figure(1),
end
display('hit any key for more')
pause

[u_bw,u_exact,x,t] = beam_warming(@f,t_0,t_f,M,N);
for j=1:60, 
    plot(x,u_bw(:,j),'.-'), 
    axis([0,2*pi,-1,2]), 
    title('Beam-Warming','FontSize',16);
    figure(1), 
    pause(1), 
end
display('hit any key for more')
pause
c = 1/2;
for j=1:length(t),
    % plot the exact solution
    plot(x,u_exact(:,j),'r-','LineWidth',2);
    hold on,
    plot(x,u_bw(:,j),'-','LineWidth',2),
    hold off;
    axis([0,2*pi,-1,2]),
    title('Beam-Warming','FontSize',16);
    figure(1),
end
display('hit any key for more')
pause
    
