www.pudn.com > modulation-of-barker.rar > modulation of barker.m, change:2015-04-17,size:4585b


close all;clear all; clc; 
code=[1,1,1,0,0,1,0]; 
tao=0.5e-6; 
fc=10e6; 
fs=400e6; 
B=1/tao; 
t_tao=0:1/fs:tao-1/fs; 
N=length(code); 
pha=0; 
t=0:1/fs:7*tao-1/fs; 
N2=length(t); 
s=zeros(1,length(t)); 
    for i=1:N 
        if code(i)==1 
           pha=1; 
        else    pha=0; 
        end        
s(1,(i-1)*length(t_tao)+1:i*length(t_tao))=sin(2*pi*fc*t_tao+pha*pi); 
    end 
f=(-N2/2:N2/2-1)/N2*fs; 
y_fft=fft(s); 
figure 
subplot(2,1,1); 
plot(t,s),xlabel('t(units : seconds)');title('two phase code barker'); 
subplot(2,1,2); 
plot(f,abs(y_fft)); 
xlabel('frequency in hz?');title('spectrum barker code'); 
 
ts=1/fs; 
c=3e8; % sped of light 
dist=9e3; % 9km distance radar test target 
total_dist=15e3; % Radar range to 15km 
tao_delay=2*dist/c; % Target delay time 
total_delay=2*total_dist/c; 
tao_T=floor(tao_delay/ts);%The number of sampling period delay 
total_delay_T=floor(total_delay/ts); 
 
Am=1;%Echo amplitude 
so=zeros(1,total_delay_T); 
%After the time delay and the calculated echo amplitude echo signal simulation 
for i=1:N2 
    so(tao_T+i)=Am*s(i); 
end 
figure; 
t=(0:1:length(so)-1)*3.6; 
plot(t,so),xlabel('s(Unit: m)'),title('Echo waveform'); 
 
%%%%%%%%%%%%%%%Quadrature demodulator 
ft=0:1:length(so)-1; 
N=length(ft); 
n=0:N-1; 
ft=(0:1:length(so)-1)/fs;%Abscissa normalized by fs 
local_oscillator_i=sin(n*fc/fs*2*pi);%I LO signal path 
local_oscillator_q=cos(n*fc/fs*2*pi); %Q LO signal path 
fbb_i=local_oscillator_i.*so;%I demultiplexer 
fbb_q=local_oscillator_q.*so;%Q demodulation road 
window=chebwin(51,40);%Using 50 bandschebyWindowFIRLow pass filter 
[b,a]=fir1(50,2*B/fs,window); 
fbb_i=filter(b,a,fbb_i); 
fbb_q=filter(b,a,fbb_q); 
figure; 
subplot(2,1,1);plot(ft,fbb_i);xlabel('t(Units: seconds)');title('I demodulated signals'); 
subplot(2,1,2);plot(ft,fbb_q); 
xlabel(' t(Units: seconds)');title('Q demodulated signals'); 
fbb=fbb_i+j*fbb_q; 
fbb_fft_result=fft(fbb); 
figure; 
plot((0:fs/N:fs-fs/N),abs(fbb_fft_result(1:N))) 
xlabel('f(frequency?Hz)'),title('Demodulated signal spectrum'); 
 
%%%%%%%Matched filter%%%%%%%%%%%%%%%%%%%%%%% 
fbb_i=fbb_i(2369:2624);%Interception return carrying pieces of information 
fbb=fbb_i; 
  
M=4096;%Do M pointsFFT 
match_filter=fliplr(conj(fbb));%Generate a matched filter 
  
match_filter_fft=fft(match_filter,M); 
figure; 
subplot(2,1,1),plot(real(match_filter_fft));title('Pulse compression coefficient real'); 
subplot(2,1,2),plot(imag(match_filter_fft));title('Pulse compression coefficient imaginary part'); 
 
%%%%%%%Pulse compression%%%%%%%%%%%%%%%% 
signal_fft=fft(fbb,M); 
pc_result_fft=signal_fft.*match_fIlter_fft; 
pc_result=ifft(pc_result_fft,M); 
fIgure, 
plot((0:ts:2*length(fbb)*ts-ts),abs(pc_result(1:2*length(fbb)))),  
xlabel( 'Time, unit : s'), 
title('Echo pulse compression processing results'); 
 
 
%%%%%%%%%%%%%%%%%%%%%%% 
ts=1/fs; 
c=3e8;% spped of the light 
dist1=9e3;%Target distance 1 
dist2=9.5e3; %Target distance 2 
total_dist=15e3;% Radar range 
tao_delay1=2*dist1/c; 
tao_delay2=2*dist2/c; 
total_delay=2*total_dist/c;% Delay time 
tao_T1=floor(tao_delay1/ts); 
total_delay_T=floor(total_delay/ts); 
tao_T2=floor(tao_delay2/ts);% The number of sampling period delay 
Am=1; 
 
so=zeros(1,total_delay_T);% After the time delay and the calculated echo signal amplitude simulation echo signal 
for i=1:N2 
    so(tao_T1+i)=Am*s(i); 
end 
t=(0:1:length(so)-1)*3.6; 
figure; 
subplot(2,1,1) 
plot(t,so);xlabel('s(Unit: m)');title('?9km??????'); 
for i=1:N2 
    so(tao_T2+i)=Am*s(i); 
end 
subplot(2,1,2) 
t=(0:1:length(so)-1)*3.6; 
plot(t,so);xlabel('s(Unit: m)');title('9km?9.225kmTwo -point target echo waveform '); 
%%%%%%%%%%%%%%%%%%%%%Quadrature demodulation part of the program slightly , following pulse compression%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%Matched filter%%% 
fbb_i=fbb_i(2369:2624); 
fbb=fbb_i; 
M=4096; 
match_fIlter=fliplr(conj(fbb)); 
match_fIlter_fft=fft(match_fIlter,M); 
fIgure, 
subplot(2,1,1),plot(real(match_fIlter_fft)),title('Pulse compression coefficient real'); 
subplot(2,1,2),plot(imag(match_fIlter_fft)),title('Pulse compression coefficient imaginary part'); 
%%%%%%%Pulse compression%%% 
signal_fft=fft(fbb,M); 
pc_result_fft=signal_fft.*match_fIlter_fft; 
ft2=0:1:length(fbb)-1; 
N=length(ft2); 
fIgure, 
plot((0:fs/N:fs-fs/N),abs(fbb_fft_result(1:N))) 
xlabel('Frequency f ( units?Hz?'),title('Spectrum after pulse compression'); 
pc_result=ifft(pc_result_fft,M); 
fIgure, 
plot((0:ts:2*length(fbb)*ts-ts),abs(pc_result(1:2*length(fbb)))),  
xlabel('Time , unit:s'), 
title('Echo pulse compression processing results');