⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autoadaption.m

📁 一个matlab实现自适应的程序
💻 M
字号:
function autoadaption(d,u)

%输入参数
L=100;
h1=-0.8;
h0=0;
%d=1;
%u=0.03;

%产生信号和噪声,得到y(n),s(n)
x=sqrt(d)*randn(1,L);
w=randn(1,L);
s=h1*x;
y=s+w;


%计算估计的h和s
Hg(1)=h0;
Sg(1)=Hg(1)*x(1);
for i=1:L-1
    Hg(i+1)=Hg(i)+2*u*(y(i)-Hg(i)*x(i))*x(i);
    Sg(i+1)=Hg(i+1)*x(i+1);
end
for i=1:L
    temp(i)=x(i)*x(i);
end
%计算理论的h
R=mean(temp);

for i=1:L;
    H(i)=h1+((1-2*u*R)^i)*(h0-h1);
end


%绘图
m=1:1:L;
subplot(2,2,1);
plot(m,s(m),'r',m,y(m),'b');
title('信号y(n)和s(n)');
legend('s(n)','y(n)');
grid on
subplot(2,2,2)
plot(m,Hg(m),'r',m,Sg(m),'b');
legend('Hg(n)','Sg(n)');
title('s(n)和h(n)的估计Sg(n),Hg(n)');
grid on;
subplot(2,2,3)
plot(m,Hg(m),'r',m,H(m),'b');
legend('h(n)','Hg(n)');
title('h(n)和h(n)的估计Hg(n)之间的波形比较');
grid on
subplot(2,2,4)
plot(m,s(m),'r',m,Sg(m),'b');
legend('s(n)','Sg(n)');
title('信号s(n)和s(n)的估计Sg(n)之间的波形比较');
grid on





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -