📄 pr8_16.m
字号:
%Problem 8.16;
%DLL exploring;
clear all; close all;
n=6; %m-sequence memory;
d=bmsq(n); %constructing m-sequence;
a=-2*d+1; %transform into BPSK alphabet;
DEL=100; a=kron(a,ones(1,DEL)); L=length(a); %oversampling;
dl=DEL; %early-late space;
ad=0; %advancement of references;
rfe=circshift(a,[0,-dl/2-ad]); rfl=circshift(rfe,[0,dl]); %forming early-late references;
G=35; %loop gain;
subplot(411);stairs([0:10*DEL],a(1:10*DEL+1)); ylim([-1.2,1.2]); ylabel('s(t)'); grid; %plot static signal;
sgm=15; y=a+normrnd(0,15,1,L); %signal plus noise;
subplot(412); plot([0:10*DEL],y(1:10*DEL+1)); ylim((1+3*sgm)*[-1.2 1.2]); ylabel('y(t)'); grid; %plot obseravtion;
subplot(413); stairs([0:10*DEL],rfe(1:10*DEL+1)); ylim([-1.2,1.2]); ylabel('ErlRf(t)'); grid; %early reference static;
subplot(414); stairs([0:10*DEL],rfl(1:10*DEL+1)); ylim([-1.2 1.2]); ylabel('LtRf(t)'); grid; %late reference static;
err1=0;
for k=1:1000 %in the loop every run calculates current error signal and controls the position of references;
y=a+normrnd(0,sgm,1,L); %signal plus noise;
err2=err1+G*((rfl-rfe)*y')/L; err=round(err2); err1=err2-err; %loop error signal;
sh=mod(L-err,L); rfe=circshift(rfe,[0,-sh]); rfl=circshift(rfe,[0,dl]); %shifting references;
tmp=char(a(30*DEL+1:36*DEL)+2); %we use some characteristic points of a tracked sequence and convert it to substring;
tmp1=char(rfe+2); %convert reference to string in order to then find time position of a characteristic point in reference;
tauer=findstr(tmp,tmp1)+dl/2-30*DEL-1; %time mismatch between received signal and reference;
ertau(k)=tauer; %array of errors of mearuring tau;
subplot(411); stairs([0:10*DEL],a(1:10*DEL+1)); ylim([-1.2,1.2]); ylabel('a(t)'); grid;
subplot(412); plot([0:10*DEL],y(1:10*DEL+1)); ylim((1+3*sgm)*[-1.2,1.2]); ylabel('y(t)'); grid; %plots current observation;
subplot(413); stairs([0:10*DEL],rfe(1:10*DEL+1)); ylim([-1.2,1.2]); ylabel('ErlRf(t)'); grid; %plots early reference in a current position;
subplot(414); stairs([0:10*DEL],rfl(1:10*DEL+1)); ylim([-1.2,1.2]); ylabel('LtRf(t)'); grid; %plots late reference in a current position;
pause(0.01)
end;
meantau=mean(ertau); vartau=var(ertau); vartauth=(sgm^2)*G*DEL/(2*L); %bias, experimental and theoretical variances of delay estimate; in theoretical one
%error values are treated as samples of a process with bandwidth 1/2L, noise
%bandwidth is calculated as in Problem 8.10;
disp(' bias var var th.');
disp([meantau,vartau,vartauth]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -