% GPR received power vs. distance for fixed 
% depth and attn. constant
clear
rad=pi/180;
attndb=10;              % in dB/m
attn=-log(10^(-attndb/10));  % POWER attn coefficient
x=[-10:.5:10];
y=x;
N=length(x);
h=2;                   % depth of target
x0=0;                  % target displacement from origin
% move the radar in x or y
Rx=sqrt((x-x0).^2+h^2);      % vector of ranges
F=exp(-2*attn*Rx);      % round trip power attn factor
Rx4=Rx.^4;
Px=F./Rx4;               % normalized power
Pdbx=10*log10(Px+1e-20);
Pdbxm=max(Pdbx);
figure(1),hold on
plot(x,Pdbx-Pdbxm,'r--')
grid
xlabel('Distance along surface, x')
ylabel('Normalized power, dB')
axis([min(x),max(x),-50,0])
% move the radar in a 2-d sweep
[X,Y]=meshgrid(x,y);
R=sqrt(X.^2+Y.^2+h^2);      % vector of ranges
F=exp(-2*attn*R);      % attn factor for RRE
R4=R.^4;
P=F./R4;               % normalized power
Pdb=10*log10(P+1e-10);
figure(2), clf
plot(x,Pdb-max(max(Pdb)))
grid
xlabel('Distance along surface, x')
ylabel('Normalized power, dB')
% move the radar in a 2-d sweep

Pxy=reshape(Pdb,N,N);
figure(3)
waterfall(X',Y',Pxy-max(max(Pxy)))


