tic
clc;
clf;
BW=5*10^6;%bandwidth
T=51.2*10^-6;%pulse width
fc=0; %zero centered frequency
n=fix(2*BW*T+1);% sampling points
sampling_interval = T / n;%sampling interval
freqlimit = 0.5/ sampling_interval;
alpha=BW/(T);%chirp rate
t=linspace(-T/2,T/2,n);%time interval
ichannel1=cos(2*pi*((fc)*t+alpha*t.^2));%real part
qchannel2=sin(2*pi*((fc)*t+alpha*t.^2));%imaginary part
LFMD=(ichannel1+(1i.*qchannel2));%Complex Base band time domain signal
LFMD(2:1:10)=0;
LFMD(504:1:511)=0;
freq = linspace(-freqlimit/2,freqlimit/2,n);
FLFMD=fftshift(fft(LFMD,n));%Frequency domain of Base band signal
[lfm,frei,flfm]=lffm1(BW,n,T);%Function calling for input Lfm signal
figure(1)
subplot(3,1,1)
plot(freq,abs(FLFMD),frei,abs(flfm));
xlabel('Time domain')
ylabel('Amplitude')
title(' base band and input signals of pulse compression filter');
grid;
%plot(t,((LFMD)),'k')
% plot(t,(lfm),'k');
rep=fliplr(LFMD);
% disp(length(rep));
j=0;
y1=zeros(1,10001);%10Khzs Sampling domain
for i=2246:1:2758
j=j+1;
y1(i)=LFMD(j);
end
% j=0;
% for i=3276:1:3788
% j=j+1;
% y1(i)=LFMD(j);
% end
% for i=9246:1:9758
% j=j+1;
% y1(i)=LFMD(j);
% end
Q=length(lfm);%length of lfm signal h(k)
P=length(y1);%length of base band signal domain X(k)
N=P+Q-1;
N=2.^nextpow2(N);% FFTbuffer
x1=zeros(1,N);%creating a empty 16k Buffer
% creating stored replica buffer of 16k
for k1=1:1:N
if k1<=Q
h1(k1)=rep(k1);
else
h1(k1)=0;
end
end
hn=fftshift(fft(h1,N)); %taking FFt of 16k H(k)buffer
hnc=(conj(hn));%
%creating the 16k buffer for X(k)signal
n3=0;
for k2=1:1:N
if k2<=N-P+1
x1(k2)=0;
else
n3=n3+1;
x1(k2)=y1(n3);
end
end
% x1=awgn(x1,5);
subplot(3,1,2);
tt=linspace(0,N,N);
plot(tt,x1);
xlabel('Time domain')
ylabel('Amplitude')
title('Intermediate stageof pulse compression filter');
grid;
xf=(fftshift(fft(x1,N))); %fft of the 16k X(k) buffer
%computing the product of X(k)*h(k)
zn=xf.*hnc;
%IFFT of the Multiplier output buffer
zk=(ifft(zn,N));
zk=abs((zk));
t4=linspace(0,1*10^-6,N);
subplot(3,1,3)
plot(t4,(zk));
xlabel('Time domain')
ylabel('Amplitude')
title('output of the pulse compression filter');
grid;
toc;