我正在使用pusleMeter项目测量脉冲信号。
所以,我使用递归最小均方的自适应滤波来从脉冲信号中去除噪声(类似于ECG信号中存在的运动伪影的运动伪像),并且我修改了来自RLS <的RLMS代码/ p>
1)因为只有一个有噪声的脉冲信号所以第一次没有参考,所以试图使用第一个脉冲信号(500个样本)的低通滤波器版本作为RLS滤波器的参考
2)在第一个脉冲信号(接下来的500个样本)之后,它将RLSfitler输出作为参考信号。
我像这样实施
clear all;
clc;
P=load('Noise_Pulse_signal.mat');
a2=P.a1;
for i=1:500:length(a2)
if(i<499)
For the first pulse signal(500samples) the reference signal is approximated as the LPfilter version of the first pulse signal.
x1=a2(i:i+499,:);
d = fdesign.lowpass('Fp,Fst,Ap,Ast',2.4,8,1,40,500);
Hd1 = design(d);
LP = filtfilt(Hd1.Numerator,1,x1);
plot(LP,'-r');
pause(0.2);
e=LP';
else
x=e;
x1=a2(i:i+499,:);
x1=x1';
[e,w] = RLS_1(x,x1,500);
pause(0.2);
end;
end
RLS_1就是这个
function [e,w] = RLS_1(n,x,fs)
% Filter Parameters
p = 4; % filter order
lambda = 1.0; % forgetting factor
laminv = 1/lambda;
delta = 1.0; % initialization parameter
% Filter Initialization
w = zeros(p,1); % filter coefficients
P = delta*eye(p); % inverse correlation matrix
%e = x*0; error signal I'm not using this as the LPfilter output will be used as the e(reference signal).
for m = p:length(x)
y = n(m:-1:m-p+1);% Acquire chunk of data
e(m) = x(m)-w'*y;% Error signal equation
Pi = P*y;% Parameters for efficiency
k = (Pi)/(lambda+y'*Pi);% Filter gain vector update
P = (P - k*y'*P)*laminv; % Inverse correlation matrix update
w = w + k*e(m);% Filter coefficients adaption
end
toc
t = linspace(0,length(x)/fs,length(x));
figure;
plot(t,x,t,e);
title('Result of RLS Filter')
xlabel('Time (s)');
legend('Reference', 'Filtered', 'Location', 'NorthEast');
title('Comparison of Filtered Signal to Reference Input');
return
但它正在给出这样的错误
Error in RLS_1 (line 15)
e(m) = x(m)-w'*y;% Error signal equation
Error in Motion (line 18)
[e,w] = RLS_1(x,x1,500);
任何人都可以解释为什么会产生错误,如果这是上述要求的正确实现方式,因为我需要一个有效的方法,以便可以在微控制器上实现。 三江源。