-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsimulation_dataset_generation.m
More file actions
51 lines (37 loc) · 1.14 KB
/
simulation_dataset_generation.m
File metadata and controls
51 lines (37 loc) · 1.14 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
49
50
51
root = '/';
%% Parameters
len_patch = 32; % Length of patch
sampsPerSym = 4; % Upsampling factor
modulationTypesStr = '32FSK ';
modulationTypes = 32;
numModulationTypes = length(modulationTypes);
noiseSnrList = 10:2:28;
lenNoiseSnrList = length(noiseSnrList);
%% Data Generation
for M = modulationTypes
numPatch = 288;
numInstance = numPatch;
for noiseSnr = noiseSnrList
xt = zeros(numInstance, len_patch);
yt = zeros(numInstance, len_patch*sampsPerSym);
cnt = 0;
for patch = 1:numPatch
cnt = cnt + 1;
% Generate random data
x = randi([0 M-1],len_patch,1);
% Modulate
freqsep = 4; fs = 128;
y = fskmod(x, M, freqsep, sampsPerSym, fs);
% AWGN channel
yc = awgn(y, noiseSnr);
% Normalize average power to 1
avg_pow = sum(abs(yc).^2)/length(yc);
yc = yc / sqrt(avg_pow);
% Store in array
xt(cnt,:) = x;
yt(cnt,:) = yc;
end
% Save data
save(sprintf('%s%sdB.mat',root,int2str(noiseSnr)), 'yt', 'xt')
end
end