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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
% snr_curves_plot.m
%
% Companion script for unittest/raw_data_curves
1;
function state_vec = set_graphics_state_print()
textfontsize = get(0,"defaulttextfontsize");
linewidth = get(0,"defaultlinelinewidth");
markersize = get(0, "defaultlinemarkersize");
set(0, "defaulttextfontsize", 16);
set(0, "defaultaxesfontsize", 16);
set(0, "defaultlinelinewidth", 1);
state_vec = [textfontsize linewidth markersize];
endfunction
function set_graphics_state_screen(state_vec)
textfontsize = state_vec(1);
linewidth = state_vec(2);
markersize = state_vec(3);
set(0, "defaulttextfontsize", textfontsize);
set(0, "defaultaxesfontsize", textfontsize);
set(0, "defaultlinelinewidth", linewidth);
set(0, "defaultlinemarkersize", markersize);
endfunction
function [snr_ch per] = snr_scatter(source, mode, channel, colour)
suffix = sprintf("_%s_%s_%s",source, mode, channel);
snr = load(sprintf("snr%s.txt",suffix));
offset = load(sprintf("offset%s.txt",suffix));
snr -= offset;
snr_x = []; snrest_y = [];
for i=1:length(snr)
fn = sprintf('snrest%s_%d.txt',suffix,i);
if exist(fn,'file') == 2
snrest=load(fn);
if i == length(snr)
plot(snr(i)*ones(1,length(snrest)), snrest, sprintf('%s;%s %s;',colour,source,mode));
else
plot(snr(i)*ones(1,length(snrest)), snrest, sprintf('%s',colour));
end
snr_x = [snr_x snr(i)]; snrest_y = [snrest_y mean(snrest)];
end
end
plot(snr_x, snrest_y, sprintf('%s', colour));
endfunction
function [snr_ch per] = per_snr(mode, colour)
snrch = load(sprintf("snrch_%s.txt",mode));
snroffset = load(sprintf("snroffset_%s.txt",mode));
snrch -= snroffset;
per = load(sprintf("per_%s.txt",mode));
plot(snrch, per, sprintf('%so-;%s;', colour, mode));
endfunction
function snrest_snr_screen(source, channel)
clf; hold on;
snr_scatter(source, 'datac0', channel,'b+-')
snr_scatter(source, 'datac1', channel,'g+-')
snr_scatter(source, 'datac3', channel,'r+-')
snr_scatter(source, 'datac4', channel,'c+-')
snr_scatter(source, 'datac13', channel,'m+-')
xlabel('SNR (dB)'); ylabel('SNRest (dB)'); grid('minor');
axis([-12 12 -12 12]);
a = axis;
plot([a(1) a(2)],[a(1) a(2)],'bk-');
hold off; grid;
if strcmp(source,'ctx')
title(sprintf('SNR estimate versus SNR (%s) (no compression)', channel));
else
title(sprintf('SNR estimate versus SNR (%s) (with compression)', channel));
end
legend('location','northwest');
endfunction
function snrest_snr_print(source, channel)
state_vec = set_graphics_state_print();
snrest_snr_screen(source, channel);
print(sprintf("snrest_snr_%s.png", source), "-dpng", "-S1000,800");
set_graphics_state_screen(state_vec);
endfunction
function ber_per_v_snr(source, mode, channel, colour)
suffix = sprintf("_%s_%s_%s.txt",source, mode, channel);
snr = load(sprintf("snr%s",suffix));
offset = load(sprintf("offset%s",suffix));
snr -= offset;
ber = load(sprintf("ber%s",suffix)) + 1E-6;
per = load(sprintf("per%s",suffix)) + 1E-6;
semilogy(snr, ber, sprintf('%s;%s %s ber;', colour, source, mode));
semilogy(snr, per, sprintf('%s;%s %s per;', colour, source, mode),'linewidth',3,'markersize',10);
endfunction
function per_v_snr(source, mode, channel, colour)
suffix = sprintf("_%s_%s_%s.txt",source, mode, channel);
snr = load(sprintf("snr%s",suffix));
offset = load(sprintf("offset%s",suffix));
snr -= offset;
per = load(sprintf("per%s",suffix)) + 1E-6;
if strcmp(channel,"awgn")
semilogy(snr, per, sprintf('%s;%s %s;', colour, mode, channel));
else
semilogy(snr, per, sprintf('%s;%s %s;', colour, mode, channel),'linewidth',3,'markersize',10);
end
endfunction
function thruput_v_snr(source, mode, channel, colour)
suffix = sprintf("_%s_%s_%s.txt",source, mode, channel);
snr = load(sprintf("snr%s",suffix));
offset = load(sprintf("offset%s",suffix));
snr -= offset;
per = load(sprintf("per%s",suffix)) + 1E-6;
if strcmp(mode,"datac0") Rb=291; end;
if strcmp(mode,"datac1") Rb=980; end;
if strcmp(mode,"datac3") Rb=321; end;
if strcmp(mode,"datac4") Rb=87; end;
if strcmp(mode,"datac13") Rb=65; end;
if strcmp(channel,"awgn")
plot(snr, Rb*(1-per), sprintf('%s;%s %s;', colour, mode, channel));
else
plot(snr, Rb*(1-per), sprintf('%s;%s %s;', colour, mode, channel),'linewidth',3,'markersize',10);
end
endfunction
function octave_ch_noise_screen(channel)
clf; hold on;
ber_per_v_snr('oct','datac0',channel,'bo-')
ber_per_v_snr('ch' ,'datac0',channel,'bx-')
ber_per_v_snr('oct','datac1',channel,'go-')
ber_per_v_snr('ch' ,'datac1',channel,'gx-')
ber_per_v_snr('oct','datac3',channel,'ro-')
ber_per_v_snr('ch' ,'datac3',channel,'rx-')
xlabel('SNR (dB)'); grid;
hold off;
if strcmp(channel,"awgn")
axis([-6 8 1E-3 1]);
else
axis([-2 12 1E-3 1]);
end
title(sprintf('Comparsion of Measuring SNR from Octave and ch tool (%s)', channel));
endfunction
function octave_ch_noise_print(channel)
state_vec = set_graphics_state_print();
octave_ch_noise_screen(channel);
print(sprintf("octave_ch_noise_%s.png", channel), "-dpng","-S1000,800");
set_graphics_state_screen(state_vec);
endfunction
function octave_c_tx_screen(channel)
clf; hold on;
ber_per_v_snr('oct','datac0',channel,'bo-')
ber_per_v_snr('ctx','datac0',channel,'bx-')
ber_per_v_snr('oct','datac1',channel,'go-')
ber_per_v_snr('ctx','datac1',channel,'gx-')
ber_per_v_snr('oct','datac3',channel,'ro-')
ber_per_v_snr('ctx','datac3',channel,'rx-')
xlabel('SNR (dB)'); grid;
hold off;
if strcmp(channel,"awgn")
axis([-6 8 1E-3 1]);
else
axis([-2 12 1E-3 1]);
end
title(sprintf('Comparsion of Octave Tx and C Tx (no compression) (%s)', channel));
endfunction
function octave_c_tx_print(channel)
state_vec = set_graphics_state_print();
octave_c_tx_screen(channel);
print(sprintf("octave_c_tx_%s.png", channel), "-dpng","-S1000,800");
set_graphics_state_screen(state_vec);
endfunction
function octave_c_tx_comp_screen(channel)
clf; hold on;
ber_per_v_snr('oct','datac0',channel,'bo-')
ber_per_v_snr('ctxc','datac0',channel,'bx-')
ber_per_v_snr('oct','datac1',channel,'go-')
ber_per_v_snr('ctxc','datac1',channel,'gx-')
ber_per_v_snr('oct','datac3',channel,'ro-')
ber_per_v_snr('ctxc','datac3',channel,'rx-')
xlabel('SNR (dB)'); grid;
hold off;
if strcmp(channel,"awgn")
axis([-6 8 1E-3 1]);
else
axis([-2 12 1E-3 1]);
end
title(sprintf('Comparsion of Octave Tx and C Tx (with compression) (%s)', channel));
endfunction
function octave_c_tx_comp_print(channel)
state_vec = set_graphics_state_print();
octave_c_tx_comp_screen(channel);
print(sprintf("octave_c_tx_comp_%s.png", channel), "-dpng","-S1000,800");
set_graphics_state_screen(state_vec);
endfunction
% composite AWGN and MPP for compressed
function c_tx_comp_screen
clf; hold on;
per_v_snr('ctxc','datac0','awgn','bo-')
per_v_snr('ctxc','datac1','awgn','go-')
per_v_snr('ctxc','datac3','awgn','ro-')
per_v_snr('ctxc','datac4','awgn','co-')
per_v_snr('ctxc','datac13','awgn','mo-')
per_v_snr('ctxc','datac0','mpp','bx-')
per_v_snr('ctxc','datac1','mpp','gx-')
per_v_snr('ctxc','datac3','mpp','rx-')
per_v_snr('ctxc','datac4','mpp','cx-')
per_v_snr('ctxc','datac13','mpp','mx-')
xlabel('SNR (dB)'); ylabel('PER'); grid;
hold off;
axis([-10 10 1E-3 1]);
title('PER of C Raw Data Modes (with compression)');
endfunction
function c_tx_comp_print;
state_vec = set_graphics_state_print();
c_tx_comp_screen;
print("c_tx_comp.png", "-dpng","-S1000,800");
set_graphics_state_screen(state_vec);
endfunction
function c_tx_comp_thruput_screen
clf; hold on;
thruput_v_snr('ctxc','datac0','awgn','bo-')
thruput_v_snr('ctxc','datac1','awgn','go-')
thruput_v_snr('ctxc','datac3','awgn','ro-')
thruput_v_snr('ctxc','datac4','awgn','co-')
thruput_v_snr('ctxc','datac13','awgn','mo-')
thruput_v_snr('ctxc','datac0','mpp','bx-')
thruput_v_snr('ctxc','datac1','mpp','gx-')
thruput_v_snr('ctxc','datac3','mpp','rx-')
thruput_v_snr('ctxc','datac4','mpp','cx-')
thruput_v_snr('ctxc','datac13','mpp','mx-')
xlabel('SNR (dB)'); ylabel('bits/s'); grid;
hold off;
axis([-10 10 0 1000]);
title(' Throughput for C Tx (with compression)');
legend('location','west');
endfunction
function c_tx_comp_thruput_print;
state_vec = set_graphics_state_print;
c_tx_comp_thruput_screen;
print("c_tx_comp_thruput.png", "-dpng","-S1000,800");
set_graphics_state_screen(state_vec);
endfunction
#{
figure(1); octave_ch_noise_screen;
figure(2); octave_c_tx_screen;
figure(3); octave_c_tx_comp_screen
figure(4); snrest_snr_screen;
figure(5); octave_ch_noise_print;
figure(6); octave_c_tx_print;
figure(7); octave_c_tx_comp_print;
figure(8); snrest_snr_print;
#}
|