• 大小: 3KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-07
  • 语言: Matlab
  • 标签: LMS  matlab  RLS  

资源简介

对二阶自回归模型产生的信号的LMS算法与RLS算法收敛速度对比(Matlab版)

资源截图

代码片段和文件信息

close all; 
clear; 
clc;
repeat_times=50;                              %重复次数,平滑误差
iters=600;                                    %迭代次数
p=2;                                          %滤波器抽头数
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%序列x(iters)由零均值,单位方差的白噪声通过一个二阶回归方程
%x(iters)+a1x(iters-1)+a2x(iters-2)=v(iters)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a1=-1.6; a2=0.8; sigma_v=1;
u=0.002;                                     %LMS自适应步长
forget_factor=0.98;                          %遗忘因子lamda
LMS_w1=zeros(repeat_timesiters);
RLS_w1=zeros(repeat_timesiters);
for k=1:repeat_times     
    xtemp=zeros(iters+p1);                   %初始化序列,x(iters)为列向量   
    vn=normrnd(0sigma_viters+p1);          %零均值,单位方差的高斯白噪声
    for i=1:iters     
        xtemp(i+2)=vn(i)-a1*xtemp(i+1)-a2*xtemp(i);
    end
    x=xtemp(p+1:length(xtemp));               %产生2阶自回归信号,剔除初始的前两个零值
    x=[zeros(p1);x];
    w_e=zeros(piters);                       %初始化LMS权矢量
    W_e=zeros(piters);                       %初始化RLS权矢量         
    T=10*eye(p);                              %初始化T(n)=1/R(n)R(n)为随机信号的自相关函数
    Pi=zeros(p1);                            %Pi(n)=T(n-1)*x(n)
    K=zeros(p1);                

评论

共有 条评论