-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathALE_imp.m
49 lines (45 loc) · 936 Bytes
/
ALE_imp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [output,e] = ALE_imp(imp,fs,delay,mu,niter)
%%% Adaptive Noise Canceler with NLMS algorithm
%% Inputs:
% imp : impedance sig
% delay : delay in samples , also corresponds to the filter order
% (default 4 sec)
% mu : convergance factor, default 0.01
% niter : number of iteration, default 2
%% Outputs :
% output : output signal
% e : error signal
%% Author :
% Hooman Sedghamiz
% July 2015
%% Update :
% Hooman Sedghamiz
% September 2015
if nargin < 5
niter = 2;
if nargin < 4
mu = 0.01;
if nargin < 3
delay = round(4*fs);
end
end
end
disp('Computing Please Wait...');
imp = imp(:);
M = delay;
N = length(imp);
output = zeros(1,N);
w = zeros(delay,1);
e = zeros(1,N);
gamma = 0.0001;
for l = 1 : niter
for i = M: N-1
d = imp(i:-1:i-M+1);
output(i) = w'*d;
e(i) = imp(i+1) - output(i);
den = (gamma +d'*d);
w = w + (mu/den)*e(i)*d;
end
end
e = e.^2;
disp('Done!');