% Test of the Green's function, gf.
% The plots demonstrate the need for the anti-alias filter.

[G,t,fft_G,G2,fft_G2] = gf(@D_lowpass, 100, 1e-7);

LineWidth = 2

figure(1)
hold off
plot(t, real(G), 'b-', 'linewidth',LineWidth)
hold on
plot(t, imag(G), 'r-', 'linewidth',LineWidth)
title("Green's Function for Lowpass Filter, RC = 1\\mu s")
xlabel("time, t")
ylabel("Green's function, G(t)")
legend("Re(G)","Im(G)")
hold off
print("test1_G(t).pdf","-dpdf")

figure(2)
hold off
plot(t, real(G2), 'g-', 'linewidth',LineWidth)
hold on
plot(t, imag(G2), 'r-', 'linewidth',LineWidth)
title("Anti-Aliased Green's Function for Lowpass Filter, RC = 1\\mu s")
xlabel("time, t")
ylabel("Green's function, G(t)")
legend("Re(G)","Im(G)")
hold off
print("test1_G(t)_antialias.pdf","-dpdf")

figure(5)
hold off
plot(real(fft_G), 'b-', 'linewidth',LineWidth)
hold on
plot(imag(fft_G), 'r-', 'linewidth',LineWidth)
title("Green's Function for Lowpass Filter, RC = 1\\mu s")
xlabel("frequency, \\omega")
ylabel("Green's function, G(\\omega)")
legend("Re(G)","Im(G)")
hold off
print("test1_G(omega).pdf","-dpdf")

figure(6)
hold off
plot(real(fft_G2), 'g-', 'linewidth',LineWidth)
hold on
plot(imag(fft_G2), 'r-', 'linewidth',LineWidth)
title("Anti-Aliased Green's Function for Lowpass Filter, RC = 1\\mu s")
xlabel("frequency, \\omega")
ylabel("Green's function, G(\\omega)")
legend("Re(G)","Im(G)")
hold off
print("test1_G(omega)_antialias.pdf","-dpdf")

