登录 注册
当前位置:主页 > 资源下载 > 29 > Matlab程序RLSnew.m实现RLS与LMS算法

Matlab程序RLSnew.m实现RLS与LMS算法

  • 更新:2024-08-05 22:54:02
  • 大小:2KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Matlab - 大数据
  • 格式:M

资源介绍

rls与lms算法Matlab程序-RLSnew.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %RLS自适应滤波器性能分析 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear %clc %close all %%%%%%%%%%%%%%参数设置%%%%%%%%%%%%%%%%%%%%%%% w=2.9; forget_factor=0.995; variance_v=0.001; repeat_times=200; iteration_times=2000; filt_len=13; delay=fix-1; %%%%%%%%%%%%%%%%%%%%变量及数组初始化%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chan_factor=/w))/2; Square_err=zeros; %%%%%%%%%%%%%外循环,重复做repeat_times次实验,平均值%%%%%%%%%%%%%%%% for loop1=1:repeat_times %%%%%%%%%%%%%%内循环变量及数组初始化%%%%%%%%%%%%%%%%%%%%%%%% Source=zeros; W=zeros; P=eye; Pi=zeros; K=zeros; %%%%%%%%%%%%%内循环,做iteration_times次迭代%%%%%%%%%%%%%%%%%%%%%%%%%%%%    for i=1:iteration_times %%%%%%%%%%%%%%信源,产生等概率分布的正负1%%%%%%%%%%%%%%%%%%%%%%%%%%%%       if rand<0.5           Source=-1;       else           Source=1;       end    end %%%%%%%%%%%%%%信道,滤波和加噪声%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    Revdata=filter randn*sqrt; %%%%%%%%%%%%%%均衡器,基于LMS算法%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        for loop2=1:iteration_times-filt_len 1         U=Revdata;         d=Source;                  Pi=P*U;         K=Pi/;         e=d-W'*U;         W=W K*e;         P=P/forget_factor-K*U'*P/forget_factor;                  Square_err=e.^2;     end end %%%%%%%%%%%%%%作图,显示结果%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Square_err_mean=sum)/repeat_times; %semilogy; plot; hold off; %figure; %stem; 运行结果: LMS: Figure18.jpg RLS: Figure19.jpg