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

📄 runlms.m

📁 System identification with adaptive filter using full and partial-update Least-Mean-Squares
💻 M
字号:

%System identification with adaptive filter using  full and partial-update Least-Mean-Squares 

clear all
close all

mm = menu('Choose an input',...
    'iid Gaussian',...
    'AR(1) Gaussian a=-0.5',...
    'AR(1) Gaussian a=-0.9');

L = 100000;     %input data size
N = 5;          %filter length
nvar = .001;    %output noise variance   
w0 = zeros(N,1);    %initialization for adaptive filters
mu = 5e-4;      %step-size parameter

u = randn(L,1);     %white Gaussian input

if mm == 1,         %input is iid
    x = u;
elseif mm == 2,     %input is AR(1)
    x = filter(1,[1,-.5],u);
elseif mm == 3,     %input is AR(1)
    x = filter(1,[1,-.9],u);
end
    
h = [1, -0.7, 0.4, -0.3, 0.2];      %system to be identified
n = sqrt(nvar)*randn(L,1);          %output noise
d = filter(h,1,x) + n;              %desired response

%
%Full-update LMS
%
eLMS = full_lms(x,d,N,w0,mu);

%
%Periodic-partial-update LMS
%
S = N;  %period of updates
ePLMS = per_lms(x,d,N,S,w0,mu); 

%
%Sequential-partial-update LMS
%
M=1;    %no of coefficients to be updated at each iteration
eSLMS = seq_lms(x,d,N,M,w0,mu);

%
%Stochastic-partial-update LMS
%
M=1;    %no of coefficients to be updated at each iteration
eStochLMS = stoch_lms(x,d,N,M,w0,mu);

%
%M-max LMS
%
M=1;    %no of coefficients to be updated at each iteration
eMmaxLMS1 = Mmax_lms(x,d,N,M,w0,mu);
M=2;    %no of coefficients to be updated at each iteration
eMmaxLMS2 = Mmax_lms(x,d,N,M,w0,mu);
M=3;    %no of coefficients to be updated at each iteration
eMmaxLMS3 = Mmax_lms(x,d,N,M,w0,mu);
M=4;    %no of coefficients to be updated at each iteration
eMmaxLMS4 = Mmax_lms(x,d,N,M,w0,mu);

%
%Time averaged MSE (learning) curves
%
L_ave = 100;    %averaging window length
b_ave = [1,zeros(1,L_ave-1),-1];    %comb filter
a_ave = [1,-1]*L_ave;

mse_lms = filter(b_ave,a_ave,eLMS.^2);      %LMS
mse_perlms = filter(b_ave,a_ave,ePLMS.^2);  %perLMS
mse_seqlms = filter(b_ave,a_ave,eSLMS.^2);  %seqLMS
mse_stochlms = filter(b_ave,a_ave,eStochLMS.^2);  %stochLMS
mse_Mmaxlms1 = filter(b_ave,a_ave,eMmaxLMS1.^2);  %Max LMS LMS, M=1
mse_Mmaxlms2 = filter(b_ave,a_ave,eMmaxLMS2.^2);  %Max LMS LMS, M=2
mse_Mmaxlms3 = filter(b_ave,a_ave,eMmaxLMS3.^2);  %Max LMS LMS, M=3
mse_Mmaxlms4 = filter(b_ave,a_ave,eMmaxLMS4.^2);  %Max LMS LMS, M=4

%Time averaged MSE plot
figure
semilogy(1:L,mse_lms,'k-',...
    1:L,mse_perlms,'b:',...
    1:L,mse_seqlms,'r-.',...
    1:L,mse_stochlms,'g--',...
    1:L,mse_Mmaxlms1,'c-',...
    1:L,mse_Mmaxlms2,'m:',...
    1:L,mse_Mmaxlms3,'y-.',...
    1:L,mse_Mmaxlms4,'b--');
ylim([1e-4,10]);
xlabel('k'), ylabel('Time-averaged MSE')
legend('LMS','Periodic-partial-update LMS','Sequential-partial-update LMS',...
    'Stochastic-partial-update LMS','M-max LMS (M=1)','M-max LMS (M=2)',...
    'M-max LMS (M=3)','M-max LMS (M=4)','Location','NorthEast');
    

    

⌨️ 快捷键说明

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