% plot_SpecMSKvsGMSK - MSK vs GMSK

%% parameters
fsT = 20;
Ns  = 100;
A = 1;
h = 0.5;

PulseMSK = RectPulse( fsT );

BT = 0.3;
L  = 10;
PulseGMSK = GaussPulse( L, BT, fsT);

M     = 500; % number of averages
Alphabet = [ 1, -1];   % BPSSK
Priors   = ones( size( Alphabet) ) / length(Alphabet);

%% Loop for accumulating periodiograms
PsMSK  = zeros( 1, Ns*fsT );
PsGMSK = zeros( 1, (Ns+L-1)*fsT );

 
for kk=1:M
    % generate signals
    Symbols     = RandomSymbols(Ns, Alphabet, Priors);
    
    SignalMSK   = CPM(Symbols, A, h, PulseMSK, fsT);

    SignalGMSK  = CPM(Symbols, A, h, PulseGMSK, fsT);
    
    % accumulate periodogram
    PsMSK  = PsMSK  + Periodogram( SignalMSK );
    PsGMSK = PsGMSK + Periodogram( SignalGMSK );

end

%average
PsMSK  = PsMSK/M/fsT;
PsGMSK = PsGMSK/M/fsT;

%% plot
% frequency axis
ffT  = (-Ns*fsT/2 : Ns*fsT/2-1)/Ns;
ffT1 =(-(Ns+L-1)*fsT/2 : (Ns+L-1)*fsT/2-1)/(Ns+L-1);
plot( ffT, 10*log10(PsMSK), ffT1, 10*log10(PsGMSK) ) 

grid
xlabel('Normalized Frequency (fT)')
ylabel('PSD (dB)')
axis( [-10 10 -120 5])
legend( 'MSK', 'GMSK (BT=0.3)')


%% Store name of script for automated figure generation
ScriptName = mfilename;