资源简介
用MATLAB脚本实现,使用LMS和RLS两种算法分别实现系统辨识和逆辨识,通过脚本实现过程可比对LMS和RLS两种算法收敛速度、稳态误差变化趋势等特征,模仿本段代码可作为理解自适应滤波算法的入门练习。

代码片段和文件信息
%%
%Adaptive Filter Test
%Copyright By popwaic
%2019.11
%In ZhengZhou
%%
%
clc;
clear;
d=randn(110000)‘;
h=[0.2 0.66 0.31 0.77 0.91 0.65 0 0 0 0 0 0 0];
N=11;
h1=[0 0 0 0.3 0.6 0.3 0.7 0.9 0 0 0];
w=zeros(113); %init
w1=zeros(12*N+3); %init
w1(N+2)=1;
r=zeros(1length(d));
u=0.2;
u1=0.015;
Lmin=7000;
%%
%System Identification
for i=1:length(d)-13
xx=d(i+12:-1:i);
dr=h*xx;
r(i)=dr;
end
%LMS
[w_est_Lee_L]=LMS_t(rdwu1);
%use RLS
R=eye(length(w));
t=0.0001;
R=t*R;
R=inv(R);
j=0.995;
[w_est_Ree_R]=RLS_t(d(1:Lmin)rwRj);
%drow picture
subplot(221);
stem(h);
title(‘h(n)‘);
subplot(222);
stem(w_est_L);
hold on;
stem(w_est_R);
hold off;
title(‘w(n)‘);
subplot(223);
stem(h-w_est_L);
hold on;
stem(h-w_est_R‘);
hold off;
title(‘h(n)-w(n)‘);
subplot(224);
plot(ee_L(1:Lmin-100));
hold on
plot(ee_R(1:Lmin-100));
title(‘MSE of e*e‘);
%%
%System inverse identification
for i=1:length(d)-N
xx=d(i+N-1:-1:i);
dr=h1*xx;
r(i)=dr;
end
r=r*0.7359; %Normalization
eee=zeros(1length(r));
%use LMS
[w_est_Lee_L]=LMS_t(d(17:Lmin)rw1u10);
%use RLS
R=eye(length(w1));
t=0.0001;
R=t*R;
R=inv(R);
j=0.995;
[w_est_Ree_R]=RLS_t(rd(17:Lmin)w1Rj);
figure;
subplot(221);
stem(h1);
title(‘h1(n)‘);
subplot(222);
%stem(w1)
stem(w_est_L);
hold on;
stem(w_est_R);
hold off;
title(‘w1(n)‘);
subplot(223);
stem(conv(h1w_est_L(:)));
hold on;
stem(conv(h1w_est_R(:)));
hold off;
%stem(conv(h1w1(:)));
title(‘h1(n)*w1(n)‘);
subplot(224);
plot(ee_L(1:Lmin-100));
hold on;
plot(ee_R(1:Lmin-100));
hold off;
title(‘MSE of e*e‘);
%%noise
%%
%functrion of LMS
% r:y
% d:d
% w:estimate of h
% u: step length
% mod : 0:basic LMS 1:normalzial LMS
function [w_estee]=LMS_t(rdwumod)
N=length(w);
n=30;
for i=1:length(r)-2*N
xx=d(i+N-1:-1:i); %
%
[m h]=size(xx);
if m==1
xx=xx‘;
end
y=w*xx;
e=r(i)-y;
if mod==1
w=w+(u/(sum(xx.^2)+0.01)*xx*e)‘;
elseif mod==0
w=w+(u*xx*e)‘;
end
%calculate MSE
Le=i;
eee(i)=e.^2;
if i ee(i)=10*log10(sum(eee(1:Le).^2)/Le);
else
ee(i)=10*log10(sum(eee(Le-n+1:Le).^2)/Le);
end
end
w_est=w;
end
%%function
%RLS
% x: x N*1 D
% d: d N*1 D
% w: w(n-1) N*1 D
% R: the inverse of square matrix Rxx(n-1) N*N D
% t: a very small param
% I: N*N D R(0)=t*I
% j: forget param
%init: w(0)=0 R0 jt
f
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3855 2019-12-08 15:05 Adaptive_Filter_LSM_RLS_SysIdent_SysEqu.m
相关资源
- kalman工具箱 用matlab编写 包附全部函数
- 增广拉格朗日法.zip
- LMS语音信号去噪matlab代码
- 基于MATLAB利用相关分析法辨识脉冲响
- Elm_KElm.rar
- 各种ELM变形MATLAB代码
- 系统辨识大牛Ljung编写的MATLAB系统辨识
- Matlab+YALMIP+CPLEX的安装与入门
- MATLAB在卡尔曼滤波器中应用的理论与
- LM算法+PPT讲解
- LMS MATLAB DSP算法实现和程序收集
- Kalman Filtering - Theory and Practice Using M
- 自适应滤波器设计及Matlab实现
- 系统辨识与自适应控制MATLAB仿真1904
- 多层ELM进行MNIST手写字符分类MATLAB代码
- LMI先行矩阵不等式的程序
- 主动噪声控制,fxLMS Active-Noise-Contro
- 系统辨识及其MATLAB仿真].侯媛彬.扫描
- 系统辨识及其MATLAB仿真pdf
- matlab实现的人体跟踪kalman滤波
- 集合卡尔曼滤波算法-数据同化的经典
- LabelMeToolbox-master
- 系统辨识理论及Matlab仿真-刘金琨 [程
- Kalman_Filter粗对准和经对准和实际试验
- 系统辨识及其MATLAB仿真
- 鲁棒控制——线性矩阵不等式处理方
- Kalman滤波器理论与应用——基于MATL
- Kalman Filtering - Theory and Practice Using M
- camshift+kalman视频跟踪matlab代码
- 扩展Kalman滤波在INS/GPS组合导航系统
评论
共有 条评论