I got a problem when I was trying to denoise a signal. Actually, it is a simple simulation. The signal is the addition of a step signal (The info I wish to get) and a sinusoidal one (the noise I wish to remove). See below However, I tried different parameters of using the adaptive filter, it simply cannot filter out the sinusoidal noise from the step signal. See figure like this.
Any suggestions will be greatly appreciated!
Below is the matlab code
clear all
close all
%% walking induced noise
t = [1:5000]*1e-2;
f = 0.1;
WalkNoise = 1*sin(2*pi*f.*t);%+1.5*cos(3*pi*f.*t);
WN = WalkNoise + 0.05*randn(size(WalkNoise));
figure
subplot(3,1,1)
plot(t,WN);
title('Noise');
%% signal
h1 = 14; % height of the signal 1
h2 = 18; % height of the signal 2
L = 5000; % total length of the signal
bp =2500; % location of break point
x1 = h1*ones(1,bp);
x2 = h2*ones(1,L-bp);
Sig = [x1,x2];
Sig = Sig + 0.1*randn(size(Sig));
subplot(3,1,2)
plot(t,Sig);
title('Signal');
%% walking-induced-noise + signal
NoisySig = Sig + WN;
subplot(3,1,3)
plot(t,NoisySig); hold on
title('Signal + noise');
%% adaptive filtering
figure
plot(t,NoisySig); hold on
title('Signal + noise');
mu = 0.001; % LMS step size.
ha = adaptfilt.lms(20,mu);
[y,e] = filter(ha,WN,NoisySig);
plot(t,e,'r');
legend('Signal+noise','Filtered using Adaptive filter');