-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathestChanResp.m
70 lines (56 loc) · 1.7 KB
/
estChanResp.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
function [hfd,h,snr] = estChanResp(r,xfd,opt)
% estChanResp: Estimates the channel response using frequency-domain
% correlation
%
% The model is that the TX repeatedly sends x=ifft(xfd) and the RX
% receives samples
% r = h*x + w
% where h is the channel impulse response and w is noise.
%
% Parameters
% ----------
% r: RX complex baseband samples of length nfft
% xfd: TX samples in frequency-domain
% nleft, nright: Number of samples to the left and right of peak
% used for signal energy computation
% normToNoise: Boolean flag indicating that the energy / tap
% should be normalized to the noise energy estimate.
% In this case abs(h(k))^2 represents the SNR per tap.
%
% Returns
% -------
% hfd: Frequency domain channel estimate. hfd(k) is the estimate
% of the channel frequency response at f(k) = k/nfft*fsamp
% h: Time-domain channel impulse response estimate.
% snr: Total snr in dB.
arguments
r (:,1) double;
xfd (:,1) double;
opt.nleft (1,1) {mustBeInteger} = 8;
opt.nright (1,1) {mustBeInteger} = 8;
opt.normToNoise (1,1) = false;
end
% Create empty outputs until they are set.
% You can delete this code when you have set the variables
hfd = [];
h = [];
snr = [];
% TODO: Take the FFT of r
% rfd = ...
% TODO: Estimate the channel frequency response by dividing by the
% FFT of x, xfd
% hfd = ...
% TODO: Compute the time-domain response
% h = ...
% TODO: Find the peak location in h
% Then, circularly shift h so that the peak is at position opt.nleft
% h = circshift(...)
% TODO: Compute the SNR
% Enoise = ...
% Esig = ...
% snr = ... (in dB)
% TODO: Normalize to the noise level
% h = ...
if opt.normToNoise
end
end