?? prozt4.m
字號:
%receiver
clear;
close all;
%fp=fopen('block-2f.dat','r');
fp=fopen('zt4.dat','r');
%fp=fopen('test.dat','r');
fp2=fopen('sourcedata.dat','r');
dat=fread(fp,inf,'uint16');
s=fscanf(fp2,'%d\n');
n=1:2000;%2000=0.01/0.000005
%pt(n)=0.007*cos(2*3.1416*8000*(0.0.000005)*n+3.1416*400000*(0.000005*n)^2);
pt=cos(0.2513274*n+0.0000314159*n.^2);
x=dat(1:15000)-32767;
y=xcorr(x,pt);
[maxx,p]=max(y);
v=p-15000
plot(y);
n=1:2400000; %remove the pilot
r1(n)=dat(n+v+2000);
%%%symbol synchronization
%for n=1:26000
% pp=0;
% for m=1:1764
% pp=dat(n+m)*dat(n+m+10000)+p;
% end
% dd(n)=pp;
%end
%subplot(3,1,3),plot(dd);
a=ones(1,10); %賦初始狀態(tài)
for m=1:1023
if(a(8)==-1)&(a(1)==-1)
b=-1;
elseif(a(8)==1)&(a(1)==-1)
b=1;
elseif(a(8)==-1)&(a(1)==1)
b=1;
else
b=-1;
end
n=1:9;
a(n)=a(n+1);
a(10)=b;
tt(m)=b;
end
for l=1:50
c=l-1;
cc=rem(c,5);
m=1:40000; %remove the prefix of the symbol
w=8000+c*48000;
Rr2(m)=r1(m+w).*cos(0.37699*m);
Ir2(m)=r1(m+w).*sin(0.37699*m);
b=fir1(30,0.1);
z1=filter(b,1,Rr2);
z2=filter(b,1,Ir2);
n=1:40000;
r2(n)=z1(n)+z2(n)*j;
r3=fft(r2);
if (cc==0)
n=1:800;
h(n)=r3(n)./tt(n);
else
for n=1:800 %反映射
r4(n)=r3(n)/h(n);
odd2=2*n-1+1600*(4*fix(c/5)+cc-1);
even2=2*n+1600*(4*fix(c/5)+cc-1);
if( real(r4(n))>0)&(imag(r4(n))>=0)
rr(odd2)=0;
rr(even2)=0;
elseif( real(r4(n))<=0)&(imag(r4(n))>0)
rr(odd2)=0;
rr(even2)=1;
elseif( real(r4(n))<0)&(imag(r4(n))<=0)
rr(odd2)=1;
rr(even2)=1;
else
rr(odd2)=1;
rr(even2)=0;
end
end
end
end
g=0;
for n=1:64000
if((rr(n)-s(n))~=0)
g=g+1;
end
end
%xor(rr,s)
g/64000
fclose(fp);
fclose(fp2);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -