%Radar range equation for impulse radar
%G. L. Charvat
%12/23/12

close all;
clear all;
clc;

%constants
c = 3E8; %(m/s) speed of light

%parameters
Pt = 10E-3; %(W) average transmit power, for CW radar tArxhis is the transmit power
fc = 9E9; %(Hz) transmit frequency
lambda_c = c/fc; %(m) wavelength
Gtx = 17; %(dBi) measured gain of transmit antenna
Gtx = 10^(Gtx/10); %convert to linear
Grx = 17; %(dBi) measured gain of receive antenna
Grx = 10^(Grx/10); %convert to linear
%from Grx we can back-out effective aperture Arx
Arx = Grx*lambda_c^2/(4*pi); %let rho_rx=1 because rho is already factored into Grx
sigma = 10; %(dBsm) RCS of the target of interst
sigma = 10^(sigma/10); %convert to linear
Ls = 6; %(dB) misc system losses
Ls = 10^(Ls/10); %convert to linear
att = 0; %attenuation constant of propagation medium, for such a short-range
%radar this constant is usually 0 unless operating in the mmW bands, we can
%then let the term e^(2*att*Rmax) = 1
Fn = 4; %(dB) cascaded noise figure
Fn = 10^(Fn/10); %convert to linear
k = 1.38E-23; %(joul/deg) Boltzman's constant
To = 290; %(deg Kelvin) standard temperature
Bn = 2E9; %(Hz) system noise bandiwdth
SNR1 = 13.4; %(dB) required SNR for Probability of detection = 95% and 
%Probability of false alarm = 10^-6
SNR1 = 10^(13.4/10); %convert to linear
N = 190; %(#) range profiles to acquire a SAR image

%---------- calculate maximum range -------------%
Rmax = ((N*Pt*Gtx*Arx*sigma)/((4*pi)^2*k*To*Fn*Bn*SNR1*Ls))^(1/4)

%-------------------------------------------------%
%calculate minimum RCS at maximum range limited by video bandwidth in dBsm
sigma = 10*log10(Rmax^4*((4*pi)^2*k*To*Fn*Bn*SNR1*Ls)/(N*Pt*Gtx*Arx))

%--------- calculate down range resolution ------------%
Tp = 1/Bn;
range_resolution = c*Tp/(2) %(m) expected range resolution


%--------- calculate cross range resolution ------------%
%Aperture weighting
%Kr = 1.43; %Hanning
%Kr = 1.03; %Uniform Circular
Kr = 0.89; %Uniform Rectangular

Rt=2.33;
L = 95/12*.3048; %(m) aperture length from first range profile to last
phi_dc = pi/2; %(rad) aspect angle from aperture to target center
delta_theta = (pi/2-atan(Rt/(L/2+.47)))+(pi/2-atan(Rt/(L/2-.47)));
%(m) expected cross-range reoslution
cross_range_resolution = lambda_c*Kr*Rt/(2*L*sin(phi_dc)*cos(delta_theta/2))