%rectax.m
% This program by T. L. Szabo calculates absolute axial pressure vs. S
% for a line aperture using Fresnel integrals from required
% subroutine fresnel.m by J. N. McElwaine.....Version 1  July 2003
% creates figure 6.5b in Diagnostic Ultrasound Imaging: Inside Out
clear all;
close all;
% S=lambda*z/L squared(L=line aperture length, z=distance from aperture)
S=.01:.001:2.;
[m,n]=size(S);
arg=ones(m,n)./sqrt(2.*S);
[fs,fc,ff,fg]=fresnel(arg,1.8);   %call function fresnel
p=abs(fc-i*fs)*sqrt(2.); % pressure normalized to pressure on aperture
figure;
%plot(arg,fc,'k',arg,fs,'r',arg,p,'g');
plot(S,fc,'g',S,fs,'r',S,p,'k');
legend('real','imaginary','absolute');
xlabel('S'); ylabel('normalized pressure');
figure;
plot(S,p,'k');
xlabel('S'); ylabel('absolute normalized pressure');
axis([0. 2. 0.6 1.4]);
% the end