?? watch_rake_experiment.asv
字號:
close all;
clear all;
A=[1 1 1 1 0 0 0 1 0 0 1 1 0 1 0];%用戶A擴(kuò)頻碼
B=[1 1 0 0 1 0 0 0 1 1 1 1 0 1 0];
h=[0.6,0.8];%多徑信道
A1=2*A-1;%BPSK調(diào)制
B1=2*B-1;
errcount=0;
tercount=0;
mod_angle=exp(j*[1/2*pi 0 pi -1/2*pi]);
for m=1:100000
src=[i,-1,1];%用戶A信源比特
%src_B=[-1,1 1];%信源比特
src_B=[i,-1,1];
L_src=length(src);
Lm=length(A);%擴(kuò)頻碼長度
Lh=length(h);%信道長度
snd=[];
snd_B=[];
for k=1:1:L_src
tt=A1*src(k);
snd=[snd,tt];%發(fā)送chip數(shù)組,前16chip是第一比特。。。
tt_B=B1*src_B(k);
snd_B=[snd_B,tt_B];
end
%The signals after the multi-path channel
L=Lm*L_src;%發(fā)送的chip序列
L1=L+Lh+3;%加上信道傳輸延遲
y=zeros(1,L1);%置接收信號長度和令初始值為0
y_B=zeros(1,L1);
%for k=1:1:Lh
% y(1,k:L+k-1)=y(1,k:L+k-1)+snd*h(k);% 經(jīng)多徑信道傳播以后的chip數(shù)組
% y_B(1,k:L+k-1)=y_B(1,k:L+k-1)+snd_B*h(k);
%end
for k = 1:Lh
y(1,(k-1)*4+1:L+(k-1)*4) = y(1,(k-1)*4+1:L+(k-1)*4)+snd*h(k);
y_B(1,(k-1)*4+1:L+(k-1)*4)=y_B(1,(k-1)*4+1:L+(k-1)*4)+snd_B*h(k);
end
y=y+y_B;
%figure(1)%是chip的圖
%plot(y);
%Rake receiver
%Detect the first bit of userA
a1=sum(y(1:Lm).*A1);%相干RAKE(*擴(kuò)頻碼)
b1=sum(y(5:(Lm+4)).*A1);%第二徑比第一徑有一個(gè)chip 延遲
r1=(a1+b1)/Lm
dist=abs(mod_angle-r1); %確定與星座圖點(diǎn)的距離
[temp,index]=min(dist);
sr1=mod_angle(index);
%Detect the second bit
a2= sum( y((Lm+1):(Lm+Lm)).*A1 );
b2= sum( y((Lm+5):(Lm+Lm+4)).*A1 );
r2=(a2+b2)/Lm
dist=abs(mod_angle-r2); %確定與星座圖點(diǎn)的距離
[temp,index]=min(dist);
sr2=mod_angle(index);
%Detect the third bit
a3= sum( y((2*Lm+1):(2*Lm+Lm)).*A1 );
b3= sum( y((2*Lm+5):(2*Lm+Lm+4)).*A1 );
r3=(a3+b3)/Lm
dist=abs(mod_angle-r3); %確定與星座圖點(diǎn)的距離
[temp,index]=min(dist);
sr3=mod_angle(index);
rec=[r1 r2 r3];
num=sum(src-rec);
errcount=errcount+sum(num);
tercount=tercount+3;
end
ber=errcount/tercount
%15擴(kuò)頻,bpsk,2徑RAKE
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -