-
Notifications
You must be signed in to change notification settings - Fork 3
/
ber_noise.m
62 lines (49 loc) · 1.66 KB
/
ber_noise.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
function ber_noise
clear all
close all
CLIENTS= 1;
FilesPath= '~/Documentos/PONs/Reporte/Graphs/';
% cd /home/victor/Documentos/PONs/Reporte/Graphs/
% INPUTFILE='/home/victor/Documentos/PONs/Reporte/Graphs/AT_1_30.dat';
% INPUTFILE='/home/victor/Documentos/PONs/Reporte/Graphs/AT_1_25.dat';
% INPUTFILE='/home/victor/Documentos/PONs/Reporte/Graphs/AT_1_20.dat';
% INPUTFILE='/home/victor/Documentos/PONs/Reporte/Graphs/AT_1_19.dat';
% INPUTFILE='/home/victor/Documentos/PONs/Reporte/Graphs/AT_1_15.dat';
% INPUTFILE='/home/victor/Documentos/PONs/Reporte/Graphs/AT_1_9.dat';
% INPUTFILE='/home/victor/Documentos/PONs/Reporte/Graphs/AT_1_7.dat';
% INPUTFILE='AT_1_30.dat';
INPUTFILE='AT_1_25.dat'; % Pas de memoire!
% INPUTFILE='AT_1_20.dat';
% INPUTFILE='AT_1_19.dat';
% INPUTFILE='AT_1_15.dat';
% INPUTFILE='AT_1_9.dat';
% INPUTFILE='AT_1_7.dat';
OUTPUTFILE=['BERSNR',INPUTFILE];
fidOUTPUTFILE= fopen(OUTPUTFILE,'w');
fprintf(fidOUTPUTFILE,'#OSNR\tBER\n');
INPUTFILE=[FilesPath,INPUTFILE];
% OSNR parameters [dB] [added \simeq K]
OSNRSTART= -20;
OSNRSTEP= 5E-1; % linear step
OSNRSTOP= 10;
% DSNR parameters [dB]
DSNRdB= 99;
for OSNRdB= OSNRSTART:OSNRSTEP:OSNRSTOP
fprintf(1,'calculando OSNR=\t%i\n',OSNRdB);
BitsDisc= noisesim(CLIENTS, DSNRdB, OSNRdB, INPUTFILE);
% Input file
InpFile= fopen(INPUTFILE,'r');
InBitString= fread(InpFile,'char');
fclose(InpFile);
% error count
count= size(BitsDisc,1);
errors= 0;
for i=1:size(BitsDisc,1)
if (InBitString(i)~=BitsDisc(i) )
errors= errors+ 1;
end
end
BER= errors/ count;
fprintf(fidOUTPUTFILE,'%e\t%e\n',OSNRdB,BER);
end
fclose(fidOUTPUTFILE);