-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDDLMS_v0.m
More file actions
66 lines (64 loc) · 2.17 KB
/
DDLMS_v0.m
File metadata and controls
66 lines (64 loc) · 2.17 KB
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
56
57
58
59
60
61
62
63
64
65
66
function [u1x,u1y] = DDLMS_v0(u0x,u0y,mu,ntaps,sps,P)
% 已经写了一个ddlms,这个应该是对的,但没函数进行验证
L = floor((length(u0x)-ntaps)/sps);
Lp = floor(L/2);
err = nan(L,2);
h = zeros(ntaps,2,2);
mid = ceil((ntaps+1)/2);
h_init = 1;
h(mid,:,:) = diag([h_init h_init]);
hxx = squeeze(h(:,1,1));
hxy = squeeze(h(:,1,2));
hyx = squeeze(h(:,2,1));
hyy = squeeze(h(:,2,2));
u_hat = nan(L,2);
u_temp = nan(ntaps,2);
temp = 1:ntaps;
field_tp = [u0x, u0y];
% 训练
for i = 1:Lp
idx = temp + (i-1)*sps;
field = field_tp(idx,:);
u_temp(:,1) = sum([hxx, hxy].*field, 2); % [ntaps,1]
u_temp(:,2) = sum([hyx, hyy].*field, 2); % [ntaps,1]
dn = sum(u_temp,1); % [1,2]
mu_mat = repmat(mu,[2,2]);
[dec_x, ~] = Decision(dn(1),P);
[dec_y, ~] = Decision(dn(2),P);
% 误差计算
err(i,1) = dec_x - dn(1);
err(i,2) = dec_y - dn(2);
% 抽头更新
hxx = hxx + mu_mat(1) * err(i,1) * conj(field_tp(idx,1));
hyx = hyx + mu_mat(2) * err(i,2) * conj(field_tp(idx,1));
hxy = hxy + mu_mat(3) * err(i,1) * conj(field_tp(idx,2));
hyy = hyy + mu_mat(4) * err(i,2) * conj(field_tp(idx,2));
end
% 均衡
for k = 1:L
idx = temp + (k-1)*sps;
field = field_tp(idx,:);
u_temp(:,1) = sum([hxx, hxy].*field, 2);
u_temp(:,2) = sum([hyx, hyy].*field, 2);
u_hat(k,:) = sum(u_temp,1);
dn = u_hat(k,:);
mu_mat = repmat(mu,[2,2]);
[dec_x, ~] = Decision(dn(1),P);
[dec_y, ~] = Decision(dn(2),P);
% 误差计算
err(k,1) = dec_x- dn(1);
err(k,2) = dec_y- dn(2);
% 抽头更新
hxx = hxx + mu_mat(1) * err(k,1) * conj(field_tp(idx,1));
hyx = hyx + mu_mat(2) * err(k,2) * conj(field_tp(idx,1));
hxy = hxy + mu_mat(3) * err(k,1) * conj(field_tp(idx,2));
hyy = hyy + mu_mat(4) * err(k,2) * conj(field_tp(idx,2));
end
u1x = u_hat(:,1);
u1y = u_hat(:,2);
end
function [dec,index] = Decision(u, P)
u = repmat(u,[length(P),1]);
[~,index] = min(abs(u-P));
dec = P(index);
end