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

📄 lms算法仿真.m

📁 LMS算法的仿真程序
💻 M
字号:
clear all
close all
N=10;                     %滤波器阶数
sample_N=500;             %采样点数
snr=10;                    %信噪比
t=1:sample_N; 
length_t=100;       %期望信号序列长度
d=1*sin(2*pi*t/length_t); %期望信号
M=length(d);               %M为接收数据长度
x=awgn(d,snr);             %经过信道(加噪声)
u=0.1;    %LMS算法收敛的步长参数
y=zeros(1,M);
w=zeros(1,N);             %LMS滤波器系数
y1=zeros(1,N);
for n=N:M                 %系数调整LMS算法
    x1=x(n:-1:n-N+1);
    %LMS算法
    y(n)=w*x1';         %滤波器的输出
    e(n)=d(n)-y(n);     %信号误差
    w=w+u*e(n)*x1;  %抽头权向量的自适应 
end
error=e.^2;                      %LMS算法每一步迭代的均方误差
figure
subplot(3,1,2)
plot(t,d);  %期望信号
title('Desired signal','fontsize',10)
axis([1,sample_N,-2,2]);
subplot(3,1,1)
plot(t,x);
title(' signal','fontsize',10)
subplot(3,1,3)
plot(t,y);
title('output signal','fontsize',10)
figure
plot(t,error,'r'); 

⌨️ 快捷键说明

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