-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathChanSounder.m
109 lines (71 loc) · 2.97 KB
/
ChanSounder.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
classdef ChanSounder < matlab.System
% TX and RX channel sounder class
properties
nfft; % number samples per frames
seed; % random generator seed
nframesTx; % number of TX frames
x0fd; % one frame of the frequency-domain TX signal
x0; % one frame of the time-domain TX signal
end
methods
function obj = ChanSounder(opt)
% Constructor
arguments
opt.nfft (1,1) {mustBeInteger} = 1024;
opt.nframesTx (1,1) {mustBeInteger} = 32;
opt.seed = 'default';
end
% Set the parameters
obj.nfft = opt.nfft;
obj.nframesTx = opt.nframesTx;
obj.seed = opt.seed;
end
function xtx = getTx(obj)
% Creates a random transmit sounding signal
%
% Outputs
% ------
% xtx: A complex sequence of length nframesTx * nfft
% Set the random seed so that the TX and RX will have the
% same seqeuence
rng(obj.seed);
% TODO: Use the qammod function to create nfft random QPSK symbols.
% Store the symbol values in a column vector obj.x0fd
% obj.x0fd = ...
% TOOD: Create the time-domain signal in one frame
% by taking the IFFT of obj.x0fd.
% obj.x0 = ...
% TODO: Use the repmat command to repeat the TX signal
% obj.x0 obj.nframesTx times and output the signal in xtx.
% Since obj.x0 is obj.nfft samples long, the resulting signal
% xtx should be obj.nfft * obj.nframesTx long.
% xtx = ...
end
function [hest, hestFd] = getChanEst(obj, y)
% Estimates the time-varying channel
%
% Inputs
% ------
% r: nfft*nframe length RX signal
%
% Outputs
% -------
% hestFd: nfft x nframe matrix of the frequency-domain channel
% in each frame
% hestTd: Time-domain version of the channel
% Compute the number of RX frames
nframeRx = floor(length(y) / obj.nfft);
% Reshape y into a nfft x nframes matrix
ymat = reshape(y, obj.nfft, nframeRx);
% TODO: Take the FFT of each column of ymat and store in yfd
% yfd = ...
% TODO: Estimate the frequency domain channel by dividing each frame of
% yfd by the transmitted frequency domain symbols x0Fd. Store the results
% in hestFd
% hestFd = ...
% TODO: Estimate the time-domain channel by taking the IFFT
% of each column of hestFd
% hest = ...
end
end
end