%  Demonstration of spatial impulse response for a
%  rectangular aperture using Field II
%
%  Version 2, September 7, 2009, Joergen Arendt Jensen
%  Version 3, September 13, 2018, Joergen Arendt Jensen
%     New font sizes and linewidths added

%  Find field point position and do the calculation

%  Get the position

axes(position)
plot(z,x,'xw')
[z,x]=ginput(1);
plot(z,x,'xr')

%  Find the impulse response and plot it

[h,t]=calc_h(emit_aperture,[x 0 z]/1000);
axes(sir)
plot(((0:length(h)-1)/fs+t)*1e6, h, 'LineWidth',2)
xlabel('Time [\mus]')
ylabel('h [m/s]')
axis([(t-20/fs)*1e6 (t+(length(h)+10)/fs)*1e6 0 1600])
title('Spatial impulse response')
grid
zoom on

%  Make axis so that length is illustrated

if (length(h)/fs > 1e-6)
    axis([t*1e6-0.1 (t+length(h+5)/fs)*1e6 0  1600])
    title('Spatial impulse response, Note: Extended time axis')
else
    axis([t*1e6-0.1 t*1e6+1.0 0  1600])
end


%  Plot the projection

plot_explanation

