-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCoMat_estimation.m
78 lines (78 loc) · 2.36 KB
/
CoMat_estimation.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function R = CoMat_estimation(x, L, mode, lambda)
%--------------------------------------------------------------------------
%% estimate covariance matrix with observed signal
% Usage:
% R = CoMat_estimation(x, L, mode, lambda)
% Inputs:
% x: input signal of size 1*L
% L: dimension of estimated cvariance matrix
% mode:
% forward: forward estimation
% backward: backward estimation
% forward-backward: forward-backward(modified) method
% recursive: using forgetting factor to update estimation
% lambda: forgetting factor
% Output:
% R: estimated covariance matrix of size L*L
% Author:
% Xianrui Wang, Center of Intelligent Acoustics and Immersive
% Communications (CIAIC).
% Contact:
% Date:
% 6-16,2021
% Reference:
% Performance analysis of forward-backward
% matched-filterbank spectral estimators
% all conpyrights preserved
%--------------------------------------------------------------------------
if nargin<3
error('signal, matrix dimension and mode necessary, lambda optional');
end
N = length(x);
reshape(x, N, 1);
%-----------------------------use forward estimation-----------------------
if mode == "forward"
R = zeros(L);
x_f = x;
for i = 1:N-L+1
xf = x_f(i+L-1:-1:i);
%# forward estimation
R = R+xf*xf';
end
R = R/(N-L+1);
elseif mode == "backward"
R = zeros(L);
x_b = conj(flip(x));
for i = 1:N-L+1
xb = x_b(i+L-1:-1:i);
%# backward estimation
R = R+xb*xb';
end
R = R/(N-L+1);
elseif mode == "modified"
R = zeros(L);
x_f = x;
x_b = conj(flip(x));
for i = 1:N-L+1
xf = x_f(i+L-1:-1:i);
xb = x_b(i+L-1:-1:i);
%# forward-backward estimation
R = R + (xf*xf'+xb*xb')/2;
end
R = R/(N-L+1);
elseif mode == "recursive"
if nargin==3
lambda = 0.95;
end
R = 1e-2*eye(L);
xf = zeros(L,1);
xb = zeros(L,1);
for i = 1:N
xf = [x(i);xf(1:end-1)];
xb = [xb(2:end);x(i)'];
Rt = (xf*xf'+xb*xb')/2;
R = lambda*R + (1-lambda)*Rt;
end
end
%----------------------------------EOF-------------------------------------