-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathPlotMiMimo.m
180 lines (158 loc) · 6.55 KB
/
PlotMiMimo.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
% =========================================================================
%
% Deep-learning based MIMO precoding for finite-alphabet signaling
%
% Low-complexity linear precoding for MIMO channels with discrete inputs
% Plotting results
%
% Max Girnyk
% Stockholm, 2014-10-01
%
% =========================================================================
%
% This Matlab script produces results used in the following paper:
%
% M. A. Girnyk, "Deep-learning based linear precoding for MIMO channels
% with finite-alphabet signaling," Physical Communication 48(2021) 101402
%
% Paper URL: https://arxiv.org/abs/2111.03504
%
% Version: 1.0 (modified 2021-11-14)
%
% License: This code is licensed under the Apache-2.0 license.
% If you use this code in any way for research that
% results in a publication, please cite the above paper
%
% =========================================================================
clear all; close all; clc;
% Add all the subfolders to the path.
currentFilePath = fileparts(which(mfilename));
addpath(genpath(currentFilePath));
% SET SIMULATION NAMES ! ##################################################
% simNames = {'190516141657_01', 190516140037, '190422212253'}; % either a case or an entire sim
simNames = {'211115003222'};
% =========================================================================
visualsPath = [pwd, '\Visuals'];
simDataPath = [pwd, '\SimData'];
functionsPath = [pwd, '\Functions'];
nSimNames = length(simNames);
if (nSimNames==1)
if iscell(simNames)
if (isa(simNames{1}, 'double'))
simNames{1} = num2str(simNames{1});
end
delimiter = regexp(simNames{1}, '_');
if isempty(delimiter)
isSingleSim = 1;
end
else
if (isa(simNames, 'double'))
simNames = num2str(simNames);
end
delimiter = regexp(simNames, '_');
if isempty(delimiter)
isSingleSim = 1;
end
end
else
isSingleSim = 0;
end
fprintf('================================================================================================================\n');
fprintf('Load results... ');
[simCaseNameList, simNameList] = parseSimIds(simNames);
nSimCases = length(simCaseNameList);
resultStruct = {};
for iSimCase = 1:nSimCases
simFolderPath = [simDataPath, '\', simNameList{iSimCase}];
caseSubfolderPath = [simFolderPath, '\' simCaseNameList{iSimCase}];
fileList = dir([caseSubfolderPath, '\*.mat']);
nFiles = length(fileList);
resultStruct{iSimCase} = {};
for iFile = 1:nFiles
simFileName = fileList(iFile).name;
simFilePath = [caseSubfolderPath, '\', simFileName];
if (exist(simFilePath))
load(simFilePath);
end
if (isfield(simCaseStruct, 'performance'))
resultStruct{iSimCase}.miBpcu(iFile) = simCaseStruct.performance.miBpcu;
resultStruct{iSimCase}.timeElapsedSec(iFile) = simCaseStruct.performance.timeElapsedSec;
else
resultStruct{iSimCase}.miBpcu(iFile) = NaN;
resultStruct{iSimCase}.timeElapsedSec(iFile) = NaN;
end
resultStruct{iSimCase}.snrDb(iFile) = simCaseStruct.channel.currentSnrDb;
if (isfield(simCaseStruct, 'precoding'))
if (isfield(simCaseStruct.precoding, 'precoder'))
resultStruct{iSimCase}.precoders{iFile} = simCaseStruct.precoding.precoder;
end
else
resultStruct{iSimCase}.precoders{iFile} = NaN;
end
end % for iFile = 1:nFiles
resultStruct{iSimCase}.legendEntry = simCaseStruct.plotting.legendEntry;
resultStruct{iSimCase}.lineType = simCaseStruct.plotting.lineType;
resultStruct{iSimCase}.lineMarker = simCaseStruct.plotting.lineMarker;
resultStruct{iSimCase}.lineColor = simCaseStruct.plotting.lineColor;
resultStruct{iSimCase}.channelTag = simCaseStruct.channel.channelTag;
resultStruct{iSimCase}.channelMatReal = simCaseStruct.channel.channelMatReal;
resultStruct{iSimCase}.channelMatImag = simCaseStruct.channel.channelMatImag;
clear simCaseStruct
end % for iSimCase = 1:nSimCases
fprintf('DONE!\n');
fprintf('================================================================================================================\n');
% PLOTS ===================================================================
% Plot params
legendFontSize = 14;
axisFontSize = 16;
lineWidth = 0.5;
% Plot MI ------------------
figMi = figure(1);
hold on; grid on
for iSimCase = 1 : length(resultStruct)
[~, iSnrDb] = sort(resultStruct{iSimCase}.snrDb);
plot(resultStruct{iSimCase}.snrDb(iSnrDb), 2*resultStruct{iSimCase}.miBpcu(iSnrDb), 'Color', resultStruct{iSimCase}.lineColor,...
'LineStyle', resultStruct{iSimCase}.lineType, 'Marker', resultStruct{iSimCase}.lineMarker, 'LineWidth', lineWidth, 'DisplayName', resultStruct{iSimCase}.legendEntry);
end
xlabel('Signal-to-noise ratio [dB]', 'interpreter', 'latex', 'FontSize', axisFontSize);
ylabel('Mutual information [bit/sym]', 'interpreter', 'latex', 'FontSize', axisFontSize);
set(gca, 'fontsize', legendFontSize);
legend(gca, 'show', 'Location', 'SouthEast')
set(figMi, 'Units', 'Inches');
pos = get(figMi, 'Position');
set(figMi, 'PaperPositionMode', 'Auto', 'PaperUnits', 'Inches', 'PaperSize', [pos(3), pos(4)])
if isSingleSim
if iscell(simNames)
figFolderPath = [visualsPath, '\', simNames{1}];
figMiName = ['plot_mi_', simNames{1}, '.pdf'];
else
figFolderPath = [visualsPath, '\', simNames];
figMiName = ['plot_mi_', simNames, '.pdf'];
end
if (~exist(figFolderPath))
mkdir(figFolderPath);
end
figMiPath = [figFolderPath, '\', figMiName];
print(figMi, figMiPath, '-dpdf', '-r0');
end
% Plot time ------------------
figTime = figure(2);
hold on; grid on
for iSimCase = 1 : length(resultStruct)
[~, iSnrDb] = sort(resultStruct{iSimCase}.snrDb);
plot(resultStruct{iSimCase}.snrDb(iSnrDb), resultStruct{iSimCase}.timeElapsedSec(iSnrDb), 'Color', resultStruct{iSimCase}.lineColor,...
'LineStyle', resultStruct{iSimCase}.lineType, 'Marker', resultStruct{iSimCase}.lineMarker, 'LineWidth', lineWidth, 'DisplayName', resultStruct{iSimCase}.legendEntry);
end
xlabel('Signal-to-noise ratio [dB]', 'interpreter', 'latex', 'FontSize', axisFontSize);
ylabel('Time [min]', 'interpreter', 'latex', 'FontSize', axisFontSize);
set(gca, 'fontsize', legendFontSize);
legend(gca,'show','Location','NorthEast')
set(figTime, 'Units', 'Inches');
pos = get(figTime, 'Position');
set(figTime, 'PaperPositionMode', 'Auto', 'PaperUnits', 'Inches', 'PaperSize', [pos(3), pos(4)])
if isSingleSim
figFolderPath = [visualsPath, '\', simNames{1}];
figTimeName = ['plot_time_', simNames{1}, '.pdf'];
figTimePath = [figFolderPath, '\', figTimeName];
print(figTime, figTimePath, '-dpdf', '-r0');
end