% plot_BuildingsSineResponse - plot time-varying response to sinusoidal
%                              input

% load data
load PropData;       % loads PropData structure

ff = 0;              % base-band equivalent frequency

v  = 10;             % velocity in m/s
dT = 1e-3;           % time increment between snapshots
NT = 1000;           % number of snap-shots
fc = 1e9;            % carrier frequency

c = 299792458;       % speed of light in m/s

tt = (0:NT-1)*dT;                    % time axis
tau   = PropData.Delay/1e9;          % delays were measured in nanoseconds.
theta = PropData.Arrival_Phi*pi/180; % arrival angles in radians
Dopplers = v/c*fc*cos(theta);

HH = zeros(1,NT);

for kk = 1:NT
    HH(kk) = PropData.Field.*exp(-j*2*pi*fc*tau) * exp(-j*2*pi*tau'*ff);
    tau = tau + Dopplers/fc*dT;
end

subplot(2,1,1)
plot( tt, 20*log10(abs(HH)) )
xlabel( 'Time (s)')
ylabel( 'Magnitude (dB)')
grid

subplot(2,1,2)
plot( tt, unwrap(angle(HH))/pi )
xlabel( 'Time (s)')
ylabel( 'Phase/\pi')
grid

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