% plot_SpecRaisedCosBeta - Spectrum of QPSK signals with Raised Cosine
% Pulses

%% clear graphics and hold on
figure(1)
clf reset
hold on

%% Parameters:
fsT      = 20;
L        = 10;
Alphabet = [1, -1, j, -j];                  % QPPSK
Priors   = ones( size( Alphabet) ) / length(Alphabet);
Ns       = 100;                             % number of symbols
M        = 500;                             % number of trials

colors = ['b','r','g','k'];

betas = [0 0.3 0.5 1.0];

for mm=1:length(betas)
    beta = betas(mm);

    Ps = zeros( 1, (Ns+L-1)*fsT );
    for kk = 1:M
        %% symbols and Signal using our functions
        Pulse    = RaisedCosPulse( L, fsT, beta);    % RC pulse
        Pulse    = Pulse/norm(Pulse);

        Symbols  = RandomSymbols(Ns, Alphabet, Priors);
        Signal   = LinearModulation(Symbols,Pulse,fsT);

        %% periodogram
        Ps  = Ps  + Periodogram( Signal );
    end

    Ps = Ps/M;

    %% plot
    ffT = (-length(Ps)/2 : length(Ps)/2-1)/length(Ps)*fsT;
    plot(ffT, 10*log10( Ps ),colors(mm) )
end

grid
xlabel('Normalized Frequency (fT)')
ylabel('PSD (dB)')
axis([-4 4 -100 5] );
legend('\beta=0','\beta=0.3','\beta=0.5','\beta=1');
hold off

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