-
Notifications
You must be signed in to change notification settings - Fork 102
/
sp_eldar_impl.m
73 lines (59 loc) · 2.01 KB
/
sp_eldar_impl.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
function [output, fs] = sp_eldar_impl(inp_fs, input, time_skew)
% Reconstruction of a signal from non-uniform samples
% Based on Sindhi and Prabhu's implementation of Eldar and Oppenheim's
% method
N = length(time_skew); % number of samplers
fs = inp_fs * N; % full sampling frequency
T_inp = 1/inp_fs;
% index_mapping is used to reorded filters in case the first input
% signal is actually delayed comparing to the second and not vice versa
[time_skew, index_mapping] = sort(time_skew);
TQ = 1; % Nyquist sampling period
% Decimation Periods - in our case all ADCs sample with the same rate
T = [2*TQ 2*TQ];
K = 0.5*lcm(2*T(1), 2*T(2))/TQ; % number of samples in recurrent period
capT = K*TQ; % the full sampling period - of all samplers
M = capT./T;
ML = length(input{1}); % number of slices
taus = time_skew / (T_inp * capT); % ADC delays in seconds
tausI = sort([taus(1) taus(2)]);
tauI = zeros(K,ML);
for p = 1:K
tauI(p,:) = tausI(p)+(0:ML-1)*capT;
end;
y = zeros(N,ML*K);
for p = 1:N
x1 = input{index_mapping(p)};
y1 = upsample(x1,K);
% length of LF should be Multiple of LCM{M(p)}*2*K
LFE = M(p)*lcm(M(1),M(2))*2*K+1;
nE = -(LFE-1)/2:1:(LFE-1)/2;
h = sinc((nE/K)-(taus(p)/T(p))).*kaiser_mine1(LFE,3,-K*(taus(p)/T(p)));
aaa = ones(1,M(p));
bb = ones(M(p),LFE);
for l = 1:M(p)
for q = 1:N
if q ~= p
aaa(l) = aaa(l)*sin(pi*(taus(p)-taus(q)+(l-1)*T(p))/T(q));
bb(l,:) = bb(l,:).*sin(pi*((nE*TQ/M(p))-taus(q)+(l-1)*T(p))/T(q));
end;
end;
bb(l,:) = bb(l,:)/aaa(l);
end;
bbb = zeros(M(p),LFE);
bbn = zeros(M(p),LFE);
for m = 1:M(p)
for l = 1:M(p)
bbb(l,:) = bb(l,:)*exp(1i*(2*pi/M(p))*(m-1)*(l-1));
end
bbb = sum(bbb,1);
bbn(m,:) = bbb.*exp(1i*(2*pi/M(p))*(m-1)*nE);
end;
bbn = sum(bbn,1);
bbn = bbn.*h/M(p);
y1 = conv(y1,bbn);
delay = (length(h)-1)/2;
y(p,:) = y1(1+delay:M(p):end-delay);
end
output = sum(real(y),1)';
end