-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathUDUflt.m
55 lines (52 loc) · 1.16 KB
/
UDUflt.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
50
51
52
53
54
55
function w=uduflt(w,x,u,ek,gamma,N)
% udu algorithm - a numerically stable form of
% the recursive least squares algorithm
%
% inputs:
% x() input vector
% dn latest input data value
% w() coefficient vector
% u() vector containing elements of U and D
%
% outputs:
% en error signal
% yn digital filter output
% w() updated coefficient vector
% u() updated elements of U and D
%
sf = 1/gamma;
m=1; % update the UD elements
v=zeros(1,N);
v(1)=x(1);
for j=2:N
v(j)=x(j);
for k=1:j-1
m=m+1;
v(j)=v(j)+u(m)*x(k);
end
m=m+1;
b(j)=u(m)*v(j);
end
b(1)=u(1)*x(1);
alpha=gamma+b(1)*v(1);
delta=1/alpha;
u(1)=u(1)*delta;
m=1;
for j=2:N
beta1=alpha;
alpha=alpha+b(j)*v(j);
p=-v(j)*delta;
delta=1/alpha;
for k=1:j-1
m=m+1;
beta=u(m);
u(m)=beta+b(k)*p;
b(k)=b(k)+b(j)*beta;
end
m=m+1;
u(m)=u(m)*beta1*delta*sf;
end
perr=ek/alpha;
for j=1:N % update the weights
w(j)=w(j)+b(j)*perr;
end