📄 lmsequalizer.m
字号:
clc;clear all;close all;
cn=[0.2194,1,0.2194];
Nv = 0.001;
T = 11; %Tap length
mu =0.1;
n=1000; %number fo input samples
s=randsrc(1,n); % input
sc=convn(s,cn,'same'); %convoluted with channel
index=1:15;
for noi=index
ns = awgn(sc,noi,'measured');
%eyediagram(ns,2);
%xxxxxxxx LMS xxxxxxxx
w(1,:)=ones(1,T); %initial weights
it=500;
for k=1:(n-T+1)
x=ns(k:k+T-1);
d=s(k:k+T-1); %desired o/p
for i=1:it
y(i,:) = w(i,:).*x;
er = d - y(i,:);
w(i+1,:)= w(i,:) + mu*(conj(er).*x);
end
out(k:k+T-1)=y(it,:);
end
%xxxxxxx Error xxxxxxx
ns(ns>=0.5) =1;
ns(ns<0.5) =-1;
err1(noi)=sum(ns~=s)/n;
out(out>=0.5)=1;
out(out<0.5)=-1;
err2(noi)=sum(out~=s)/n;
%xxxxxx END xxxxxxx
end
ns = awgn(sc,1,'measured');
figure,subplot(3,1,1),stem(s);title('i/p');
subplot(3,1,2),stem(ns);title('noised');
subplot(3,1,3),stem(out);title('out');
figure,plot(index,err1,'b-*', index,err2,'k-p');title('Error');
xlabel('time index');ylabel('error rate');
legend('error before LMS','error after LMS');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -