%%% This program produces makes a plot of C(f) on pp.475 of Proakis 2002

clc;clear;close all
Tarrstr = ['-4 / T';'-3 / T';'-2 / T';'-1 / T';'   0  ';'1 / T ';'2 / T ';'3 / T ';'4 / T '];
ystr = ['0.05T^2';'0.1T^2 ';'0.15T^2';'0.2T^2 ';'0.25T^2'];
f = -10:0.1:10;sig2 = 20;
Cff = 0.6*exp( - f.^2/sig2);
figure(1)
plot(f,Cff,'-k ','LineWidth',4);
set(gcf,'Color','w');set(gca,'FontSize',20)
axis off
xlabel('\bf\itf','FontSize',24,'FontWeight','bold');%set(gca,'XTickLabel',Tarrstr); 
ylabel('\it\gamma_m_n  \rmFSK correlation coefficient','FontSize',20,'FontWeight','bold');
%axis ([min(deltaf)*1 max(deltaf)*1.12 min(gammamn)*1.2 max(gammamn)*1.1]);
Tet = -f;
figure(2)
plot(f,Tet,'-k ','LineWidth',4);
set(gcf,'Color','w');set(gca,'FontSize',20)
axis off
xlabel('\bf\itf','FontSize',24,'FontWeight','bold');%set(gca,'XTickLabel',Tarrstr); 
ylabel('\it\gamma_m_n  \rmFSK correlation coefficient','FontSize',20,'FontWeight','bold');
%%% It also plot the graphs of Example 8.1.1
T = 1;t = (0:0.01:1)*T;f = (-4:0.011:4.01)*1;
gTt = 0.5*(1 + cos(2*pi*(t - 0.5*T)/T));
gTt = [zeros(1,10) gTt zeros(1,10)];
t = [(-0.1:0.01:-0.01)*T t (1.01:0.01:1.1)*T];
figure(1)
plot(t,gTt,'-k ','LineWidth',5);
set(gcf,'Color','w');set(gca,'FontSize',20)
axis off
xlabel('\bf\itt','FontSize',24,'FontWeight','bold');%set(gca,'XTickLabel',Tarrstr); 
ylabel('\bf\itg_T \rm\bf(\it t\rm\bf )','FontSize',20,'FontWeight','bold');
axis ([min(t) max(t)*1 min(gTt) max(gTt)*1.05])
GTf = 0.5*T*sinc(f*T)./(1 - f.^2*T^2);GTf = GTf.^2;
%GTf = 0.5*T*sin(pi*f*T)./(pi*f*T.*(1 - f.^2*T^2));GTf = GTf.^2;
figure(2)
plot(f,GTf,'-k ','LineWidth',5);
set(gcf,'Color','w');set(gca,'FontSize',20)
%axis off
xlabel('\bf\itf','FontSize',24,'FontWeight','bold');set(gca,'XTickLabel',Tarrstr);%set(gca,'YTickLabel',ystr);  
ylabel('\mid\bf\itG_T \rm\bf(\it f\rm\bf )\mid^2\rm / \itT \rm^2','FontSize',20,'FontWeight','bold');
axis ([min(f) max(f)*1 min(GTf) max(GTf)*1.05])
%axis ([min(f) max(f)*1 1e-10 max(GTf)*1.05])
%%%% Figs of Example 5.1
W = 4800;T = 1/W;f = -4800:5:4800;Cff = 1./sqrt(1 + (f/W).^2);
Cff = [ones(1,100)*min(Cff) Cff ones(1,100)*min(Cff)];fe = [-5300:5:-4805 f 4805:5:5300];figure(3)
figure(3);plot(fe,Cff,'-k ','LineWidth',5);;set(gcf,'Color','w');set(gca,'FontSize',20)
axis ([min(fe) max(fe)*1 min(Cff) max(Cff)*1.05]);axis off
XRC = T*(cos(pi*abs(f)/9600)).^2;XRC = [ones(1,100)*min(XRC) XRC ones(1,100)*min(XRC)];
figure(4);plot(fe,XRC,'-k ','LineWidth',5);set(gcf,'Color','w');set(gca,'FontSize',20)
axis ([min(fe) max(fe)*1 min(XRC) max(XRC)*1.05]);axis off
GTf = sqrt(T*(1 + (f/W).^2)).*cos(pi*abs(f)/9600);GTf = [ones(1,100)*min(GTf) GTf ones(1,100)*min(GTf)];
figure(5);plot(fe,GTf,'-k ','LineWidth',5);set(gcf,'Color','w');set(gca,'FontSize',20)
axis ([min(fe) max(fe)*1 min(GTf) max(GTf)*1.05]);axis off
GRf = sqrt(T).*cos(pi*abs(f)/9600);GRf = [ones(1,100)*min(GRf) GRf ones(1,100)*min(GRf)];
figure(6);plot(fe,GRf,'-k ','LineWidth',5);set(gcf,'Color','w');set(gca,'FontSize',20)
axis ([min(fe) max(fe)*1 min(GRf) max(GRf)*1.05]);axis off