-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModulator.m
More file actions
34 lines (31 loc) · 1.86 KB
/
Modulator.m
File metadata and controls
34 lines (31 loc) · 1.86 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
function y=Modulator(u, Mode)
%% Initialization
% persistent QPSK QAM16 QAM64
% if isempty(QPSK)
QPSK = comm.PSKModulator(4, 'BitInput', true, ...
'PhaseOffset', pi/4, ...
'SymbolMapping', 'Custom', ...
'CustomSymbolMapping', [0 2 3 1]);
QAM16 = comm.RectangularQAMModulator(16, 'BitInput',true,...
'NormalizationMethod','Average power',...
'SymbolMapping', 'Custom', ...
'CustomSymbolMapping', [11 10 14 15 9 8 12 13 1 0 4 5 3 2 6 7]);
% QAM64 = comm.RectangularQAMModulator(64, 'BitInput',true,...
% 'NormalizationMethod','Average power',...
% 'SymbolMapping', 'Custom', ...
% 'CustomSymbolMapping', [47 46 42 43 59 58 62 63 45 44 40 41 ...
% 57 56 60 61 37 36 32 33 49 48 52 53 39 38 34 35 51 50 54 55 7 ...
% 6 2 3 19 18 22 23 5 4 0 1 17 16 20 21 13 12 8 9 25 24 28 29 15 ...
% 14 10 11 27 26 30 31]);
% end
%% Processing
switch Mode
case 1
y=step(QPSK, u);
case 2
y=step(QAM16, u);
case 3
y=step(QAM64, u);
otherwise
error('Invalid Modulation Mode. Use {1,2, or 3}');
end