% plot_DMFSignals - plot a few symbol periods of DMF input and output

%% set parameters
SimpleSetParameters;

%% system simulation
[NumErrors, ResultsStruct] = MCSimple( Parameters );

%% plot a few symbol periods of DMF input and output
N  = 10;                        % number of symbol periods to plot
nn = 1 : N*Parameters.fsT;      % indices of samples to plot
tt = ( nn-1 ) / Parameters.fsT; % time axis
ss = nn( length(Parameters.hh) : Parameters.fsT : end ); % MF samples

% for BPSK signals, I-component is only noise
InSig  = real( ResultsStruct.Received );
% redo MF calculation
OutSig = real( conv( ResultsStruct.Received, ...
                     conj( fliplr( Parameters.hh) ) ) ) ;

% input signal
subplot( 2, 1, 1 )
plot( tt, InSig(nn) )
xlabel( 'Time (1/T)' )
title( 'DMF Input' )
grid

subplot( 2, 1, 2 )
plot( tt, OutSig(nn),  tt(ss), OutSig(ss), 'ro' )
xlabel( 'Time (1/T)' )
title( 'DMF Output' )
grid

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