-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathOFDM_Modulator.m
More file actions
49 lines (41 loc) · 1.63 KB
/
Copy pathOFDM_Modulator.m
File metadata and controls
49 lines (41 loc) · 1.63 KB
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Modulation process
% Data: (N_FFT * Nsym) x Ntxs matrix in frequency domain
% Payload_t: column vector
%
% Copyright (C) 2022-2023 Shiyue He (hsy1995313@gmail.com)
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Payload_t = OFDM_Modulator(ModDataTX)
global N_CP N_FFT N_DATA
global PILOTS
global PILOT_INDEX DATA_INDEX
Nsym = size(ModDataTX, 1) / N_DATA;
Ntxs = size(ModDataTX, 2);
%% OFDM modulator
Payload_t = zeros((N_CP + N_FFT) * Nsym, Ntxs);
Payload_f_itx = zeros(N_FFT, Nsym);
for itx = 1: Ntxs
% Pilot insertion
Payload_f_itx(PILOT_INDEX, :) = repmat(PILOTS{Ntxs}(:, itx), 1, Nsym);
% Data insertion
Payload_f_itx(DATA_INDEX, :) = reshape(ModDataTX(:, itx), N_DATA, Nsym);
% IFFT
Payload_t_itx = sqrt(N_FFT) * ifft(fftshift(Payload_f_itx, 1), N_FFT, 1);
% CP addition
Payload_t(:, itx) = reshape([Payload_t_itx(end-N_CP+1: end, :); Payload_t_itx], [], 1);
end