clc;clear all;close all;
%% 'Barker, 13 elements'
% r=10;% signal is sampled r times in each tb (r/tb sampling rate)
% u_amp=ones(1,13);% signal amplitude vector
% u_phase=[0 0 0 0 0 1 1 0 0 1 0 1 0];% signal phase vector
% u = [ones(1,r*5),-(ones(1,r*2)),ones(1,r*2),-ones(1,r),ones(1,r),-ones(1,r),ones(1,r)];%13 bit
% df=.0308;
% K=50;% number of points in the Doppler axis for ambiguity plot is K
%% 'Frank,P1,P2, M elements'
% r=10;% signal is sampled r times in each tb (r/tb sampling rate)
% M=8;
% u_amp=ones(1,M*M);% signal amplitude vector
% for i=1:M
% for j=1:M
% % phi(j,i)=2*pi/M*(i-1)*(j-1);% 'Frank, M elements'
% phi(j,i)= (-pi/M/2)*(2*i-1-M)*(2*j-1-M);% 'P2, M elements'
% % phi(j,i)= (-pi/M)*(M-(2*j-1))*((j-1)*M+(i-1));% 'P1, M elements'
% end
% end
% nn=0;
% for ii=1:M
% for jj=1:M
% nn=nn+1;
% phi2(nn)=phi(ii,jj);
% end
% end
% j=sqrt(-1);
% u_phase=phi2;
% u_basic=u_amp.*exp(j*u_phase);
% m_basic=length(u_basic);
% ud=diag(u_basic);
% ao=ones(r,m_basic);
% m=m_basic*r;
% u=reshape(ao*ud,1,m); % u_basic with each eleement repeated r times
% df=.0312;% maximal displayed Doppler is F/Mtb
K=50;% number of points in the Doppler axis for ambiguity plot is K
%% 'P3,P4, M elements'
% r=10;% signal is sampled r times in each tb (r/tb sampling rate)
% M=64;
% u_amp=ones(1,M);% signal amplitude vector
% for i=1:M
% % phi(i)= (pi/M)*(i-1)*(i-1);% 'P3, M elements'
% phi(i)= (pi/M)*(i-1)*(i-1)-pi*(i-1);%'P4, M elements'
% end
% j=sqrt(-1);
% u_phase=phi;
% u_basic=u_amp.*exp(j*u_phase);
% m_basic=length(u_basic);
% ud=diag(u_basic);
% ao=ones(r,m_basic);
% m=m_basic*r;
% u=reshape(ao*ud,1,m); % u_basic with each eleement repeated r times
% df=.0312;% maximal displayed Doppler is F/Mtb
% K=50;% number of points in the Doppler axis for ambiguity plot is K
%% 'T1,T2,T3,T4'
r=1;
m=2;
k=4;
T=16e-3;
ttt=1;
deltaf=1e3;
for tt = linspace(0,T,120);
jj = floor(k*tt/T);
% phase(ttt)= mod(((2*pi/m)*floor(((k*tt - jj*T)*(jj*m/T)))), 2*pi); % T1
% phase(ttt)= mod(((2*pi/m)*floor((((k*tt - jj*T)*((2*jj-k+1)/T)*(m/2))))), 2*pi); % T2
% phase(ttt)=mod(((2*pi/m)*floor((m*deltaf*tt.^2)/(2*T))),2*pi); % T3
phase(ttt)=mod(((2*pi/m)*floor((m*deltaf*tt.^2)/(2*T)-(m*deltaf*tt)/2)),2*pi); % T4
if ttt==1
phaseunwrapped(ttt)=phase(ttt);
else
if phase(ttt)==phase(ttt-1)
phaseunwrapped(ttt)=phaseunwrapped(ttt-1);
else
phaseunwrapped(ttt)=phaseunwrapped(ttt-1)+2*pi/m;
end
end
ttt= ttt+1;
end
u=exp(j*phase);
u_amp=ones(1,length(u));
df=.0312;% maximal displayed Doppler is F/Mtb
K=50;% number of points in the Doppler axis for ambiguity plot is K
%% 'LFM '
% r=1;
% dt=1;
% u_amp=ones(1,51);
% u_freq=.0031*[-25:25];
% df=.0032;
% K=60;
% phas=2*pi*dt*cumsum(u_freq);
% % phas=2*pi*(-.0031*25*[0:50]*dt+0.5*.0031*[0:50].^2*dt.^2);
% u=exp(j*phas);
%%
F=df*length(u_amp)*K;
scalet=[0:length(u)-1]/r;
% calcualte normalized ACF
acfun=20*log10(abs(xcorr(u))+eps);
acfun=acfun-max(acfun);
acfun1=acfun;
acfun=max(acfun,-70);
acfun=acfun(length(u):2*length(u)-1);
% acfun=acfun(1:(length(acfun)+1)/2);
% acfun=fliplr(acfun);
% calcualte normalized PACF
zeru=zeros(size(u));
pacfun=20*log10(abs(xcorr([u u u],[zeru u zeru]))+eps);
% clear zeru;
pacfun=pacfun-max(pacfun);
pacfun=max(pacfun,-70);
pacfun=pacfun(3*length(u):4*length(u)-1);
% calcualte spectrum
% fftlength=max(1024*8,length(u)*32);
% spec=20*log10(max(abs(fft(u,fftlength)),eps));
% spec=spec-max(spec);
% spec=max(spec,-60);
% spec=spec(1:fftlength/2);
% scales=[0:fftlength/2-1]/(fftlength/2-1)*r/2;
figure(1)
plot(scalet,acfun,'k');
xlabel('{\it\tau}/\itt_b');ylabel('[dB]');
title('Autocorrelation');
axis([0 max(scalet) -70 0]);
grid on;
figure(2)
plot(scalet,pacfun,'r','linewidth',2);
xlabel('{\it\tau}/\itt_b');
ylabel('[dB]');
title('Periodic Autocorrelation ');
axis([0 max(scalet) -70 0]);
grid on;
% subplot(313);
% plot(scales*length(u)/r,spec,'k');
% xlabel('{\itf*Mt_b}');
% ylabel('|{\itS}({\itf})|');
% axis([0 F -60 0]);
% grid on;
评论15