-
Notifications
You must be signed in to change notification settings - Fork 5
/
esprit_cov_test_modulation.m
47 lines (46 loc) · 1.12 KB
/
esprit_cov_test_modulation.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
addpath './DOAToolbox'
%% Initializations
l = 0.04; %distance between sensors in m
m = 8; %num of sensors
fs = 44100; %sampling frequency
N = 1000; %num of samples
fc = [500 214 147]; %wave frequency
doa = [-60 17 40];
fp = 4000;
doa = doa .* pi/180;
sig = 0.1;
amps = 1;
%% Generate data
n = length(doa);
Y = zeros(N,m);
%yp = exp(-1j*2*pi*t(:).*fp);
%Yp = repmat(yp,1,m);
for i = 1:n
[Yx,~, ~] = simtone_planar(doa(i), m, l, fc(i), fs, N);
[Yp,d, t] = simtone_planar(doa(i), m, l, fp, fs, N);
Yx = Yx .* amps .* Yp; %modulation
Y = Y + Yx;
end
Y = addnoise(Y, sig);
%% Generate covariance matrices
P = diag(amps.^2);
R1 = cov_model(P, sig, m, 2*pi*d*sin(doa));
Y = Y.'; %transpose Y for the next line
R2 = (Y*Y')./N;
J = fliplr(eye(m));
R2 = 1/2*(R2 + J*R2.'*J);
%% Compute their norm
nm = norm(R1-R2);
nm
%% DOA
theta = esprit_cov(R2,d,n)
%% Plotting
plot(t, real(Y));
xlabel('Time');
ylabel('Value');
title('Data set');
legend('Sensor 1','Sensor 2','Sensor 3','Sensor 4','Sensor 5','Sensor 6','Sensor 7','Sensor 8');
grid on
%% Clean-up
rmpath './DOAToolbox'
clear J N P R1 R2 Y Yp Yx amps d doa fc fp fs i l m n nm sig t theta