-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSample_Longxi.asv
139 lines (97 loc) · 4.55 KB
/
Sample_Longxi.asv
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
%印度人的ModelSim的输入u0-u15 16进制: 0000000100020003001000110012001300200021002200230030003100320033
N=8; K=8;
u=[0;0;0;1;0;1;1;1];
x=encodeLongxi(N,K,u,'AWGN',10);
y=afterTransmitInChannel(x);
%编码后应为01101001
uhat=decodeLongxi(y,'AWGN',10)
N=4; K=4;
u=[0;1;0;1];
x=encodeLongxi(N,K,u,'AWGN',100);
y=afterTransmitInChannel(x);
uhat=decodeLongxi(y,'AWGN',100)
N=16; K=16;
u=[0;1;0;1;0;1;0;1;0;1;0;1;0;1;0;1];
x=encodeLongxi(N,K,u,'AWGN',10)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NOTE: Except for plotPC(), it is a must to have
% initPC() run before using any other routine.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> N=128; K=64;
>> %%%%%%%%%%%% 1. BSC Channel %%%%%%%%%%%%%
>> initPC(N,K,'BSC',0.1); % Transition prob 'p' of BSC assumed during code-design = 0.1
All polar coding parameters & resources initialized. (in a structure - "PCparams")
N: 128
K: 64
n: 7
FZlookup: [128x1 double]
design_channelstring: 'BSC'
design_channelstate: 0.1000
LLR: [1x255 double]
BITS: [2x127 double]
bitreversedindices: [128x1 double]
index_of_first0_from_MSB: [128x1 double]
index_of_first1_from_MSB: [128x1 double]
>> u=(rand(K,1)>0.5); %random message
>> x=pencode(u); %polar encoding
>> y=OutputOfChannel(x,'BSC',0.15); %simulate BSC channel with p=0.1
>> uhat=pdecode(y,'BSC',0.15); %decode under the same BSC channel setting
>> logical( sum( uhat == u ) == K ) %check for Decoding success!
ans =
1
%%%%%%%%%%%%%%% PLOTTING PERFORMANCE CURVES %%%%%%%%%%%%%%%%%%
>> plotPC(256,128,'BSC', 0.1, 0.01:0.02:0.16,10000) % Last is #Monte-Carlo-samples. This module runs everything necessary. Doesn't require anything to have initialized before.
* Max. Monte-Carlo Iterations = 10000, ensuring 100 frame errors, and a minimum of 1000 iterations
* Polar Code designed for BSC channel at p=0.100000
* Channel-states (BSC-p) to be run:
0.0100 0.0300 0.0500 0.0700 0.0900 0.1100 0.1300 0.1500
........(lots of text)
BSC-p : 0.0100 0.0300 0.0500 0.0700 0.0900 0.1100 0.1300 0.1500
Frame Error Rates : 0 0.0081 0.0929 0.2880 0.6110 0.8580 0.9680 0.9980
Bit Error Rates : 0 0.0007 0.0125 0.0494 0.1564 0.2624 0.3650 0.4218
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> %%%%%%%%%%%%%%%%%%% 2. BEC Channel %%%%%%%%%%%%%%%%%%%%%
>> initPC(N,K,'BEC',0.1); % Erasure prob 'epsilon' of BEC assumed during code-design = 0.1
All polar coding parameters & resources initialized. (in a structure - "PCparams")
N: 128
K: 64
n: 7
FZlookup: [128x1 double]
design_channelstring: 'BEC'
design_channelstate: 0.1000
LLR: [1x255 double]
BITS: [2x127 double]
bitreversedindices: [128x1 double]
index_of_first0_from_MSB: [128x1 double]
index_of_first1_from_MSB: [128x1 double]
>> u=(rand(K,1)>0.5); %random message
>> x=pencode(u); %polar encoding
>> y=OutputOfChannel(x,'BEC',0.15); %simulate BEC channel with erasure prob=0.1
>> uhat=pdecode(y,'BEC',0.15); %decode under the same BEC channel setting
>> logical( sum( uhat == u ) == K ) %check for Decoding success!
ans =
1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> %%%%%%%%%%%% 3. AWGN Channel %%%%%%%%%%%%%
>> initPC(N,K,'AWGN',0); %designSNR=0dB
All polar coding parameters & resources initialized. (in a structure - "PCparams")
N: 128
K: 64
n: 7
FZlookup: [128x1 double]
design_channelstring: 'AWGN'
design_channelstate: 0
LLR: [1x255 double]
BITS: [2x127 double]
bitreversedindices: [128x1 double]
index_of_first0_from_MSB: [128x1 double]
index_of_first1_from_MSB: [128x1 double]
>> u=(rand(K,1)>0.5); %random message
>> x=pencode(u); %polar encoding
>> y=OutputOfChannel(x,'AWGN',1); %simulate AWGN channel at Eb/N0=1dB
>> uhat=pdecode(y,'AWGN',1); %decode under the same AWGN channel setting.
>> logical( sum( uhat == u ) == K ) %check for Decoding success!
ans =
1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%