迫零均衡器--代码(毕业设计)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
程序1
clear all
N=10000;
x=randn(1,N);%产生均值0,方差为1的随机序列for i=1:N
if x(i)>
b(i)=1;
else
b(i)=-1;
end
end%调制xx=pskmod(x,M);
y=[ 0 ]; %衰减信道
A1=zeros(5,5);
for m=1:5
for n=1:5
if n==m
A1(m,n)=;
else if n==m+1
A1(m,n)=;
else if n==m-1
A1(m,n)=;
else if n==m+2
A1(m,n)=;
else if n==m-2
A1(m,n)=0;
else
A1(m,n)=0;
end
end
end
end
end
end
end
B1=[0;0;1;0;0];
C1=pinv(A1)*B1;
A2=zeros(17,17);
for i=1:17
for j=1:17
if j==i
A2(i,j)=;
else if j==i-1
A2(i,j)=;
else if j==i-2
A2(i,j)=0;
else if j==i-3
A2(i,j)=;
else if j==i-4
A2(i,j)=;
else if j==i-5
A2(i,j)=;
else if j==i+1
A2(i,j)=;
else if j==i+2
A2(i,j)=;
else if j==i+3
A2(i,j)=;
else if j==i+4
A2(i,j)=;
else if j==i+5
A2(i,j)=;
else
A2(i,j)=0;
end
end
end
end
end
end
end
end
end
end
end
end
end
B2=[0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;0;0]; C2=pinv(A2)*B2;
A=zeros(31,31);
for i=1:31
for j=1:31
if j==i
A(i,j)=;
else if j==i-1
A(i,j)=;
else if j==i-2
A(i,j)=0;
else if j==i-3
A(i,j)=;
else if j==i-4
A(i,j)=;
else if j==i-5
A(i,j)=;
else if j==i+1
A(i,j)=;
else if j==i+2
A(i,j)=;
else if j==i+3
A(i,j)=;
else if j==i+4
A(i,j)=;
else if j==i+5
A(i,j)=;
else
A(i,j)=0;
end
end
end
end
end
end
end
end
end
end
end
end
end
B=[0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0]; C=pinv(A)*B;
SNR=1:2:21;
for m=1:length(SNR)
for i=1:N
noise=randn;
x1noise(i)=b(i)*sqrt(2*10^(SNR(m)/10))+noise;
if x1noise(i)<0;
t1(i)=-1;
else
t1(i)=1;
end
end%解调:X1=pskdemod(x1noise,M);
[numbers,pm1(m)]=symerr(b,t1);
xxy=conv(b,y);
for i=1:N+6
noise=randn;
x2noise(i)=xxy(i)*sqrt(2*10^(SNR(m)/10))+noise;
if x2noise(i)<0;
t2(i)=-1;
else t2(i)=1;
end
end%解调:X2=pskdemod(x2noise,M);
[numbers,pm2(m)]=symerr(b,t2(6:length(x)+5));
x2C1=conv(x2noise,C1);
for i=1:N+8
if x2C1(i)<0;
t3(i)=-1;
else t3(i)=1;
end
end%%解调 X2C1=pskdemod(x2C1,M)
[numbers,pm3(m)]=symerr(b,t3(8:length(x)+7));
x2C2=conv(x2noise,C2);
for i=1:N+14
if x2C2(i)<0;
t4(i)=-1;
else t4(i)=1;
end
end%解调X2C2=pskdemod(x2C2,M);
[numbers,pm4(m)]=symerr(b,t4(14:length(x)+13));
x2C=conv(x2noise,C);
for i=1:N+21
if x2C(i)<0;
t5(i)=-1;
else t5(i)=1;
end
end%X2C=pskdemod(x2C,M)
[numbers,pm5(m)]=symerr(b,t5(21:length(x)+20));
end
figure(1)
semilogy(SNR,pm1);grid on;
title('无串扰的误码率');
axis([1 16 10^-5 1]);
xlabel('SNR(dB)');ylabel('误码率');
figure(2)
semilogy(SNR,pm2);grid on;
title('经过衰减信道的误码率');
xlabel('SNR(dB)');ylabel('误码率');
figure(3)
semilogy(SNR,pm2,'r--',SNR,pm3,'ms:');grid on;
title('5抽头迫零均衡器');