% plot_MSKMagPhase - plot magnitude and phase of MSK signal

%% Parameters:
fsT      = 20;
L        = 10;
Alphabet = [1,-1];                          % 2-PAM
Priors   = ones( size( Alphabet) ) / length(Alphabet);
Ns       = 20;                              % number of symbols
Pulse    = RectPulse( fsT);                 % Rectangular pulse
A        = 1;                               % amplitude
h        = 0.5;                             % modulation index

%% symbols and Signal using our functions
Symbols = RandomSymbols(Ns, Alphabet, Priors);
Signal  = CPM(Symbols, A, h, Pulse,fsT);
%% plot
tt = (0 : length(Signal)-1 )/fsT;
subplot( 2, 1, 1 )
plot(tt, abs( Signal ))
grid
xlabel('Time/T')
ylabel('Magnitude')
axis([5 15 0 1.5] );

subplot( 2, 1, 2 )
plot(tt, unwrap(angle( Signal ))/pi, ...
    tt(fsT/2:fsT:end),  Symbols(1:end), 'ro')
grid
xlabel('Time/T')
ylabel('Phase/\pi')
set(gca, 'XLim',[5 15]);


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