现代通信原理A.5:数字基带传输系统误码性能仿真

%------------------
%系统参数设置
%-----------------
T_start=0;%开始时间
T_stop=10;%截止时间
T=T_stop-T_start;%仿真持续时间
T_sample=1/1000;%采样间隔
f_sample=1/T_sample; % 采样速率
N_sample=T/T_sample;% 采样点数
n=0:N_sample-1;
r_s=100;%transmission rate
alpha=0.25;%df=alpha*rs=25Hz
NumBits=T*r_s;%number of bits
NumCoff=40;%number of coefficients of RRC
SamplingIns=NumCoff/2;
SamplingStart=NumCoff;
%-------------------------------
%Transmitter
%-------------------------------
g_T=firrcos(NumCoff,r_s/2,alpha*r_s,f_sample);%transmission filter
b1=sign(rand(1,NumBits)-0.5);%original bits
b2=zeros(f_sample/r_s,NumBits);
b2(1,:)=b1;
b3=reshape(b2,1,f_sample/r_s*NumBits);
s=conv(b3,g_T);%transmitted signal
%--------------------------------
%AWGN channel
%--------------------------------
N_0=10^(-9);
noise_w=wgn(1,length(s),N_0*f_sample,'linear');%产生白噪声
r=s+noise_w;
%figure(1)
%plot(s)
%hold on
%plot(r)
%--------------------------------
%receiver
%--------------------------------
g_R=firrcos(NumCoff,r_s/2,alpha*r_s,f_sample);%transmission filter
y1=conv(r,g_R);
myeyediagram=eyediagram(y1(1:length(y1)),f_sample/r_s);
%figure(2)
%plot(y1)
%hold on
sample1=zeros(f_sample/r_s,NumBits);
sample1(1,:)=ones(1,NumBits);
sample2=reshape(sample1,1,f_sample/r_s*NumBits);
sample3=zeros(1,length(y1));
sample3(NumCoff+1:NumCoff+f_sample/r_s*NumBits)=sample2;
%plot(sample3)
y2=y1.*sample3;
%plot(y2)
y2(:,all(y2==0,1))=[];
b_t=(sign(b1)+1)*0.5;
b_r=(sign(y2)+1)*0.5;
BER=length(find(b_t~= b_r))/NumBits

猜你喜欢

转载自blog.csdn.net/tanghonghanhaoli/article/details/103415857