📄 myrls.m
字号:
clear;
N=1024;
n=200;
FS=1000;
t=0:1/FS:(N-1)/FS;
s=exp(-30*t).*sin(80*pi*t);
D=50;
S=[zeros(1,N) s];
figure(1);
plot(s);
hold on;
plot(S,'r');
figure(2);
x1=awgn(s,10,'measured');
subplot(211);
plot(x1);
x2=awgn(S,10,'measured');
subplot(212);
plot(x2);
Cxx=1000*eye(n);
g=zeros(N,n);
h=zeros(N,n);
e=zeros(1,N);
y=zeros(1,N);
tr=zeros(1,N);
for (j=1:N-n+1)
wm=max(h);
if h(j,:)==wm
f(j,:)=wm;
end
end
figure(3)
plot(f)
for i=n+1:N,
g(i,:)=(Cxx*x1(i-n+1:i)'/(1+x1(i-n+1:i)*Cxx*x1(i-n+1:i)'))';
e(1,i)=x2(i)-h(i-1,:)*x1(i-n+1:i)';
h(i,:)=h(i-1,:)+e(1,i)* g(i,:);
Cxx= Cxx-g(i,:)'*x1(i-n+1:i)*Cxx;
y(1,i)= h(i,:)*x1(i-n+1:i)';
tr(1,i)=trace(Cxx);
end
figure(4)
plot(0:N-n,x1(1,n:N)),grid
title('x1(k) input signal in V')
xlabel('Sanples')
figure(5)
plot(0:N-n,x2(1,n:N),'r')
grid
axis([0 800 -1.2 1.2])
title('x2(k) reference signal in V')
xlabel('Samples')
figure(6)
plot(0:N-n,e(1,n:N)),hold on
plot(0:N-n,y(1,n:N),'r'),hold off
grid
title('e(k) error and y(k) output in V')
xlabel('Samples')
gtext('e(k)'),gtext('y(k)')
figure(7)
plot(0:N-n,h(n:N,1)),hold on
plot(0:N-n,h(n:N,2),'r'),hold off
grid
title('filter coefficients evolution')
xlabel('Samples')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -