[Optimization algorithm] Improved LMS algorithm-SVSLMS algorithm [Contains Matlab source code 632 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

%%------------------- 定义变量:----------------------%%
% N - # of elements in array                                  %
% d - 阵元间距                          %
% ang - theta in deg                                          %
% thetaS - 期望用户波达角                             %
% thetaI - 干扰波达角                              %
% T - 期望信号的周期                               %
% t - 期望信号的时间轴                            %
% S - 期望信号                                        %
% I - 干扰信号                                    %
% vS,vI - 期望用户和干扰用户的转移矢量   %
% X - 总阵列因子                                     %
% Rxx - 总接收信号相关矩阵             %
% mu - 收敛参数                                  %
% w - 用LMS算法确定的均匀线阵权值          %
% x - 总接收信号                                   %
% y - 阵列输出                                            %
% e - 阵列输出和期望信号的误差           %
% theta - range of AOA's (rad)                                %
% AF - 加权阵列输出                                  %
%%-----------------------------------------------------------%%

%%----- 赋值-----%%

N = 8; d =0.5; 

thetaS = 30*pi/180; thetaI = -60*pi/180;%期望信号方向30. 干扰-60.%

%%----- 期望和干扰信号-----%%

T = 1E-3; t = (1:100)*T/100; it = 1:100;%1E-3表示1ms%

S = cos(2*pi*t/T); %,此时,S已经是一个矩阵!1100列


I = randn(1,100);%生成1100列的正态分布随机矩阵%
  
%%----- 为每个用户的线性阵列信号创建的阵列因子 -----%%

vS = []; vI = [];
i = 1:N;
vS = exp(1j*(i-1)*2*pi*d*sin(thetaS)).';%’表示厄米特转置,产生N行1列的阵列向量,然后后面在此基础上乘以信号就得到天线每个阵元接收到的信号
vI = exp(1j*(i-1)*2*pi*d*sin(thetaI)).';

%%----- 用LMS解决权值 -----%%

w = zeros(N,1);%初始天线阵权值全为0%
X = vS + vI;
Rxx = X*X';%X'为X的厄米特转置%
mu = 1/(4*abs(trace(Rxx)));%trace,迹%

wi = zeros(N,max(it));%初始权值都为0%
for n = 1:length(S)%n是迭代次数?%
    x = S(n)*vS + I(n)*vI;
    y(n) = w'*x;
    e = conj(S(n)) - y(n);     esave(n) = abs(e)^2;%conj,求复数的共轭%
    nu=mu*(1-exp(-(abs(e))^2));
    w = w + nu*conj(e)*x;
    wi(:,n) = w;
end               %没有判断收敛,要判断是从误差收敛曲线来看
w = w/w(1);    % 第一权值的规范解%

%%----- 显示权值 -----%%

disp(' ')
disp('%------------------------------------------------------------------------%')
disp(' ')
disp(['    N = ',num2str(N),' 的权值是:'])
disp(' ')
for m = 1:length(w)
    disp(['   w',num2str(m),' = ',num2str(w(m),3)])
end
disp(' ')

%%----- 输出结果 -----%%

% 1.) Plot 权重与迭代次数

wi = wi.';
figure(1), plot(it,abs(wi(:,1)),'kx',it,abs(wi(:,2))...
    ,'ko',it,abs(wi(:,3)),'ks',it,abs(wi(:,4)),'k+',...
    it,abs(wi(:,5)),'kd','markersize',2)
xlabel('Iteration no.'), ylabel('|weights|')
title('\bf  阵列权值')

% 2.) Plot 信号采集和跟踪

figure(2)
plot(it,S,'k',it,real(y),'k--')
xlabel('迭代次数'), ylabel('Signals')
title('\bf  期望信号采集与跟踪')
legend('期望信号','阵列输出')

% 3.) Plot 最小均方误差

figure(3), plot(it,esave,'k')
xlabel('Iteration no.'), ylabel('|e|^2')
title('\bf 均方误差与迭代次数.')

% 4.) Plot 阵列因子

theta = -pi/2:.01:pi/2;
AF = 0;
for i = 1:N
    AF = AF + w(i)'.*exp(j*(i-1)*2*pi*d*sin(theta));
end

Three, running results

Insert picture description here
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]
[Workshop scheduling] Based on matlab genetic algorithm to solve workshop scheduling [Include Matlab source code 070]
[Workshop scheduling] Based on matlab nsgaII to solve workshop scheduling [Contain Matlab source code 071 period]
[Workshop scheduling] Improved 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 】
[Workshop scheduling] production scheduling based on matlab particle swarm [including Matlab source code 412]
[Workshop scheduling] based on matlab genetic algorithm multi-objective flow shop scheduling [including Matlab source code 443]
[Optimization solution] based on matlab particle swarm microgrid Multi-objective optimization [Include Matlab source code 444]
[Optimization] Based on matlab dragonfly algorithm to solve multi-objective optimization problems [Include Matlab source code 477]
[Optimization algorithm] Marine predator algorithm (MPA) [Include Matlab source code 478]
[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 599 period]
[optimization solution] based on Genetic algorithm to solve the multi-objective distribution network reconstruction model [including Matlab source code 622]
[Optimization algorithm] Improved fixed and variable step size LMS algorithm [including Matlab source code 629]
[Optimization algorithm] Improved LMS algorithm [including Matlab source code 630 period]
[Optimization algorithm] improved LMS algorithm-NLMS algorithm [including Matlab source code 631 period]

Guess you like

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