%Programme to plot the frequency response for Sunde's FSK, 
%Minimum Shift Keying and unfiltered QPSK

%Written by Andrew Bateman.

%set up figure numbers and location on the screen

figure(1)
close
figure(2)
close
h=figure('position',[90 341 394 369],'color',[1,1,0]);
h=figure('position',[491 341 400 370],'color',[1,1,0]);

%initialise vectors
Xaxis1=[];
Xaxis2=[];
H1=[];
H2=[];
H3=[];


%calculate magnitude of frequency response for Sunde's FSK

for i=1:121
   %var=frequency*bit duration
   fTb=(i-60-0.1)/21;
   Xaxis1(i)=fTb;
   H1(i)=(cos(pi*fTb)/(4*fTb^2-1))^2;
   H1(i)=10*log10(H1(i));
   if (H1(i)<-40);
      H1(i)=-40;
   end
   %add delta function elements
   if(fTb>0.48) & (fTb<0.52)
      H1(i)=5;
   end
      if(fTb>-0.52) & (fTb<-0.48)
      H1(i)=5;
      end

   
end

%calculate magnitude of frequency response for MSK

for i=1:121
   %var=frequency*bit duration
   fTb=(i-60-0.1)/21;
   Xaxis1(i)=fTb;
   H2(i)=(cos(2*pi*fTb)/(16*fTb^2-1))^2;
   H2(i)=10*log10(H2(i));
   if (H2(i)<-40);
      H2(i)=-40;
      end
end
   
   
%calculate magnitude of frequency response for unfiltered QPSK

for i=1:121
   %var=frequency*bit duration
   fTb=(i-60-0.1)/21;
   Xaxis1(i)=fTb;
   H3(i)=((sin(2*pi*fTb))/(2*pi*fTb))^2;
   H3(i)=10*log10(H3(i));
   if (H3(i)<-40);
      H3(i)=-40;
      end
end


%plotting routine

figure(1)
plot(Xaxis1,H1,'-b','linewidth',2)
hold on
xaxis1=[-40,5];
xaxis2=[0,0];
plot(xaxis2,xaxis1,'-k','linewidth',1)
title('frequency response for Sundes FSK')

figure(2)
plot(Xaxis1,H2,'-b','linewidth',2)
hold on
plot(Xaxis1,H3,'-g','linewidth',2)
xaxis1=[-40,5];
xaxis2=[0,0];
plot(xaxis2,xaxis1,'-k','linewidth',1)
title('frequency response for MSK (blue) & QPSK (green)')


