[Optimization algorithm] Improved LMS algorithm-NLMS algorithm [Contains Matlab source code 631 period]

1. Introduction

Least Mean Squares (LMS, Least Mean Squares) is the most basic adaptive filtering algorithm.
The LMS algorithm is a commonly used algorithm in adaptive filters. The difference from the Wiener algorithm is that the coefficients of the system change with the input sequence. In the Wiener algorithm, a section of the autocorrelation function of the input sequence is intercepted to construct the optimal coefficient of the system. The LMS algorithm is implemented by continuously correcting the initialized filter coefficients according to the minimum mean square error criterion. Therefore, theoretically speaking, the performance of the LMS algorithm is better than Wiener under the same conditions. However, the LMS is adjusted gradually under the initial value, so before the system is stable, there will be a period of adjustment time. The adjustment time is controlled by the step size factor. Within a certain range, the larger the step size factor, the smaller the adjustment time, and the step size factor The maximum value of is the trace of R. LMS adopts the principle of minimum square error instead of the principle of minimum mean square error, and the basic signal relationship is as follows:
Insert picture description here
Insert picture description here

Second, the source code

clear all
close all
hold off%系统信道权数
sysorder = 5 ;%抽头数
N=1000;%总采样次数
inp = randn(N,1);%产生高斯随机系列
n = randn(N,1);
[b,a] = butter(2,0.25);
Gz = tf(b,a,-1);%逆变换函数
h= [0.0976;0.2873;0.3360;0.2210;0.0964;];%信道特性向量
y = lsim(Gz,inp);%加入噪声
n = n * std(y)/(10*std(n));%噪声信号
d = y + n;%期望输出信号
totallength=size(d,1);%步长
N=60 ; %60节点作为训练序列
%算法的开始
w = zeros ( sysorder , 1 ) ;%初始化
for n = sysorder : N 
u = inp(n:-1:n-sysorder+1) ;% u的矩阵
y(n)= w' * u;%系统输出
r(n)=u'*u;%自相关矩阵
e(n) = d(n) - y(n) ;%误差
fai=.0001;%修正参数,为防止u'*u过小导致步长值太大而设置的
if n < 20
mu=0.32;
else
mu=0.15;
end
w = w + mu * u * e(n)/(r(n)+fai) ;%迭代方程
end 
%检验结果
for n = N+1 : totallength
u = inp(n:-1:n-sysorder+1) ;
y(n) = w' * u ;
e(n) = d(n) - y(n) ;%误差
end 
hold on
plot(d)
plot(y,'r');
title('系统输出') ;
xlabel('样本')
ylabel('实际输出')
figure
semilogy((abs(e))) ;% e的绝对值坐标
title('误差曲线') ;
xlabel('样本')
ylabel('误差矢量')
figure%作图
plot(h, 'k+')

Three, running results

Insert picture description here
Insert picture description here
Insert picture description here

Four, remarks

Complete code or writing add QQ 1564658423 review of previous periods
>>>>>>
[Workshop scheduling] Matlab particle swarm-based workshop scheduling [including Matlab source code 013]
[Workshop scheduling] Based on matlab genetic algorithm to solve the workshop scheduling model with GUI [ Include Matlab source code 049 period]
[Workshop scheduling] Based on matlab genetic algorithm to solve shop scheduling [Include Matlab source code 070]
[Workshop scheduling] Based on matlab nsgaII Solve shop scheduling [Contain Matlab source code 071 period]
[Workshop scheduling] Improve leapfrog based on matlab Algorithm to solve shop scheduling problem [including Matlab source code 073]
[Workshop scheduling] Matlab to solve the replacement flow shop scheduling problem [including Matlab source code 176]
[Workshop scheduling] Based on matlab PSO to solve 6X6 shop scheduling problems [including Matlab source code 411 ]
[shop scheduling] based production scheduling matlab particle swarm [with Matlab source code 412]
[shop scheduling] based on matlab genetic algorithm for multi-objective flow shop scheduling [with Matlab source code 443]
[optimization solution] based microgrid matlab PSO's Multi-objective optimization [including Matlab source code 444 period]
[Optimization solution] based on matlab dragonfly algorithm to solve multi-objective optimization problems [including Matlab source code 477 period]
[Optimization algorithm] Marine predator algorithm (MPA) [including Matlab source code 478 period]
[Optimization Algorithm] Black Hole Simulation Algorithm (MVO) [Including Matlab source code 479]
[Optimization algorithm] Improved flower pollination algorithm based on mutation strategy [Including Matlab source code 480]
[Optimization solution] based on matlab particle swarm algorithm to solve hydro-thermal power economic dispatch [including Matlab source code 500 period]
[Optimization solution] based on sparrow search algorithm 3D wireless sensor network (WSN) coverage optimization [including Matlab source code period 599]
[Optimization solution] based on Genetic algorithm to solve the multi-objective distribution network reconstruction model [including Matlab source code 622]
[Optimization algorithm] Improved fixed step and variable step size LMS algorithm [including Matlab source code 629]
[Optimization algorithm] Improved LMS algorithm [including Matlab source code 630]

Guess you like

Origin blog.csdn.net/TIQCmatlab/article/details/115221255