clear all; close all; clc

% xi = linspace(0,pi/2); 
xi = linspace(0,pi/4); 

I = sqrt(-1); 

C1 = 0.25; G1 = NumericalG(C1,xi); G1_ex = exp(-I*C1*xi); 
C2 = 0.50; G2 = NumericalG(C2,xi); G2_ex = exp(-I*C2*xi); 
C3 = 0.75; G3 = NumericalG(C3,xi); G3_ex = exp(-I*C3*xi); 
C4 = 1.00; G4 = NumericalG(C4,xi); G4_ex = exp(-I*C4*xi); 
C5 = 1.50; G5 = NumericalG(C5,xi); G5_ex = exp(-I*C5*xi); 

figure(1); clf 
plot(xi,abs(G1.TG3), xi,abs(G2.TG3), xi,abs(G3.TG3),...
    xi,abs(G4.TG3), xi,abs(G5.TG3),'LineWidth',2)
l = legend(['C=',num2str(C1)], ['C=',num2str(C2)], ['C=',num2str(C3)],...
    ['C=',num2str(C4)], ['C=',num2str(C5)]); 
set(l,'FontSize',24,'Location','NorthWest')
%set(gca,'FontSize',24,'XTick',0:pi/8:pi/2,...
%    'XTickLabel',{'0','pi/8','pi/4','3pi/8','pi/2'})
set(gca,'FontSize',24,'XTick',0:pi/16:pi/4,...
    'XTickLabel',{'0','pi/16','pi/8','3pi/16','pi/4'})
xlabel('\xi','FontSize',24)
ylabel('|G|','FontSize',24)
v = axis; axis([0,xi(end),v(3),v(4)])
grid on
set(gcf,'color',[1,1,1])


figure(2); clf 
plot(xi,angle(G1.TG3)./angle(G1_ex), xi,angle(G2.TG3)./angle(G2_ex), ....
    xi,angle(G3.TG3)./angle(G3_ex), xi,angle(G4.TG3)./angle(G4_ex) ,...
    xi,angle(G5.TG3)./angle(G5_ex), 'LineWidth',2)
l = legend(['C=',num2str(C1)], ['C=',num2str(C2)], ['C=',num2str(C3)],...
    ['C=',num2str(C4)], ['C=',num2str(C5)]); 
set(l,'FontSize',24,'Location','NorthWest')
%set(gca,'FontSize',24,'XTick',0:pi/8:pi/2,...
%    'XTickLabel',{'0','pi/8','pi/4','3pi/8','pi/2'})
set(gca,'FontSize',24,'XTick',0:pi/16:pi/4,...
    'XTickLabel',{'0','pi/16','pi/8','3pi/16','pi/4'})
xlabel('\xi','FontSize',24)
ylabel('phase error','FontSize',24)
v = axis; axis([0,xi(end),v(3),v(4)])
grid on
set(gcf,'color',[1,1,1])



figure(3); clf 
plot(xi,abs(G1.TG3)./abs(G1_ex), xi,abs(G2.TG3)./abs(G2_ex), ...
    xi,abs(G3.TG3)./abs(G3_ex), xi,abs(G4.TG3)./abs(G4_ex), ...
    xi,abs(G5.TG3)./abs(G5_ex), 'LineWidth',2)
l = legend(['C=',num2str(C1)], ['C=',num2str(C2)], ['C=',num2str(C3)],...
    ['C=',num2str(C4)], ['C=',num2str(C5)]); 
set(l,'FontSize',24,'Location','NorthWest')
%set(gca,'FontSize',24,'XTick',0:pi/8:pi/2,...
%    'XTickLabel',{'0','pi/8','pi/4','3pi/8','pi/2'})
set(gca,'FontSize',24,'XTick',0:pi/16:pi/4,...
    'XTickLabel',{'0','pi/16','pi/8','3pi/16','pi/4'})
xlabel('\xi','FontSize',24)
ylabel('damping error','FontSize',24)
v = axis; axis([0,xi(end),v(3),v(4)])
grid on
set(gcf,'color',[1,1,1])

