?? lms_newchannel.m
字號:
%前端加訓(xùn)練序列均衡,后端加信息碼元并計算誤碼
%clc;clear all;close all;
N1=20;%一個碼元抽樣點數(shù)
fs=5000;%抽樣頻率
f=2000;%PSK載波頻率
N=600;
K=5;
%actual_isi=[0.05 -0.063 0.088 -0.126 -0.25 0.9047 0.25 0 0.126 0.038 0.088];%信道
sigma=0.01;
u=0.075;%mu值的選取0.02,大步長+少迭代次數(shù),小步長+多迭代次數(shù)
k=2;
eb_n0=30;
snr=eb_n0-10*log10(0.5*(N1*(1/fs)/(1/fs)/k));
w=[];%記錄第一權(quán)值
Num_of_realizations=100;
mse_av=zeros(1,N-2*K);
for j=1:Num_of_realizations
for i=1:N
if (rand<0.5)
info(i)=-1;
else
info(i)=1;
end
end
i=0;
for j=1:N
for t=0:1/fs:(N1-1)/fs
i=i+1;
psk_s(i)=sin(2*pi*f*t)*info(j);
ss(i)=sin(2*pi*f*i/fs);%本地恢復(fù)載波
end
end
%psk_s=psk_s+0.1*rand(1,N*N1);%加入噪聲
psk_s=awgn(psk_s,snr,'measured');
% yt=psk_s+0.5*[zeros(1,30) psk_s(1:N*N1-30)];%兩徑
yt=psk_s+0.5*[zeros(1,30) psk_s(1:N*N1-30)]+0.707*[zeros(1,10) psk_s(1:N*N1-10)];%三徑
%y1=filter(actual_isi,1,yt);
y1=yt;
y2=y1.*ss;%解調(diào)
b=fir1(34,0.20);%
y2=filter(b,1,y2);
for i=1:N
y(i)=y2(i*N1);%抽樣
end
estimated_c=[0 0 0 0 0 1 0 0 0 0 0];
for k=1:N-2*K
w(k)=estimated_c(1);
y_k=y(k:k+2*K);
z_k=estimated_c*y_k.';
e_k=info(k+9)-z_k;%期望序列延遲
estimated_c=estimated_c+u*e_k*y_k;
mse(k)=e_k^2;
end
mse_av=mse_av+mse;
end
mse_av=mse_av/Num_of_realizations;
hold on;
figure(1);
semilogy((1:length(mse_av)),mse_av);title('e_k^2');
figure(2);
subplot(211)
plot(1:N*N1,psk_s);title('psk+noise');
subplot(212)
plot(1:N*N1,yt);title('psk+noise+multipath');
figure(3);
subplot(211)
stem(1:N,y);title('demodulate+sample');
subplot(212)
stem(info);title('training squense');
%%均衡后信息碼元
test=randsrc(1,N);
i=0;
for j=1:N
for t=0:1/fs:(N1-1)/fs
i=i+1;
psk_test(i)=sin(2*pi*f*t)*test(j);
ss_test(i)=sin(2*pi*f*i/fs);%本地恢復(fù)載波
end
end
%psk_test=psk_test+0.1*rand(1,N*N1);
psk_test=awgn(psk_test,snr,'measured');
% ytest=psk_test+0.5*[zeros(1,30) psk_test(1:N*N1-30)];%兩徑
ytest=psk_test+0.5*[zeros(1,30) psk_test(1:N*N1-30)]+0.707*[zeros(1,10) psk_test(1:N*N1-10)];%三徑
% ytest1=filter(actual_isi,1,ytest);
ytest1=ytest;
ytest2=ytest1.*ss_test;%解調(diào)
btest=fir1(34,0.20);%低通濾波
ytest2=filter(btest,1,ytest2);
for i=1:N
ytout(i)=ytest2(i*N1);
end
for i=1:200
tt5(i)=ytout(i:i+10)*estimated_c'; %輸出序列
end
tt6=sign(tt5);
ber=sum(tt6~=test(1+9:200+9))/200%同樣延遲碼元
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -