% plot_BuildingsFreqResp - plot frequency response from ray data and
%                             compare to signal bandwidth

% load data
load PropData;       % loads PropData structure

BW  = 10e6;           % bandwidth to evaluate
N   = 1000;           % number of points to plot
fc  = 1e9;            % carrier frequency
BWs = 2/Ts;           % signal bandwidth from symbol duration

ff = (0:N-1)/N*BW - BW/2; % frequency axis from -BW/2 to (nearly) BW/2

tau = PropData.Delay/1e9; % delays were measured in nanoseconds.

HH = PropData.Field.*exp( -j*2*pi*fc*tau ) * exp(-j*2*pi*tau'*ff);
HH_max = max( abs( HH ) );
HH_min = min( abs( HH ) );

fill( [-BWs -BWs BWs BWs]/2e6, 20*log10( 1.1*[ eps HH_max HH_max eps] ), 'g' );
hold on

plot( ff/1e6, 20*log10(abs(HH)) )
xlabel( 'Frequency (MHz)')
ylabel( '|Frequency Response| (dB)')
axis( [ff(1)/1e6 ff(end)/1e6 20*log10([ 0.5*HH_min 2*HH_max ]) ] )
grid

hold off

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