|
| 1 | +%ModelSim������u0-u15 16���ƣ� 0000000100020003001000110012001300200021002200230030003100320033 |
| 2 | +N=8; K=8; |
| 3 | +u=[0;0;0;1;0;1;1;1]; |
| 4 | +x=encodeLongxi(N,K,u,'AWGN',10); |
| 5 | +y=afterTransmitInChannel(x); |
| 6 | +%�����ӦΪ01101001 |
| 7 | +uhat=decodeLongxi(y,'AWGN',10) |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +N=4; K=4; |
| 12 | +u=[0;1;0;1]; |
| 13 | +x=encodeLongxi(N,K,u,'AWGN',100); |
| 14 | +y=afterTransmitInChannel(x); |
| 15 | +uhat=decodeLongxi(y,'AWGN',100) |
| 16 | + |
| 17 | +N=16; K=16; |
| 18 | +u=[0;1;0;1;0;1;1;0;1;0;0;1;0;1;1;1]; |
| 19 | +x=encodeLongxi(N,K,u,'AWGN',10); |
| 20 | + |
| 21 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 22 | +% NOTE: Except for plotPC(), it is a must to have |
| 23 | +% initPC() run before using any other routine. |
| 24 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 25 | + |
| 26 | +>> N=128; K=64; |
| 27 | + |
| 28 | +>> %%%%%%%%%%%% 1. BSC Channel %%%%%%%%%%%%% |
| 29 | +>> initPC(N,K,'BSC',0.1); % Transition prob 'p' of BSC assumed during code-design = 0.1 |
| 30 | + |
| 31 | + All polar coding parameters & resources initialized. (in a structure - "PCparams") |
| 32 | + N: 128 |
| 33 | + K: 64 |
| 34 | + n: 7 |
| 35 | + FZlookup: [128x1 double] |
| 36 | + design_channelstring: 'BSC' |
| 37 | + design_channelstate: 0.1000 |
| 38 | + LLR: [1x255 double] |
| 39 | + BITS: [2x127 double] |
| 40 | + bitreversedindices: [128x1 double] |
| 41 | + index_of_first0_from_MSB: [128x1 double] |
| 42 | + index_of_first1_from_MSB: [128x1 double] |
| 43 | + |
| 44 | +>> u=(rand(K,1)>0.5); %random message |
| 45 | +>> x=pencode(u); %polar encoding |
| 46 | +>> y=OutputOfChannel(x,'BSC',0.15); %simulate BSC channel with p=0.1 |
| 47 | +>> uhat=pdecode(y,'BSC',0.15); %decode under the same BSC channel setting |
| 48 | + |
| 49 | +>> logical( sum( uhat == u ) == K ) %check for Decoding success! |
| 50 | + |
| 51 | +ans = |
| 52 | + |
| 53 | + 1 |
| 54 | + |
| 55 | +%%%%%%%%%%%%%%% PLOTTING PERFORMANCE CURVES %%%%%%%%%%%%%%%%%% |
| 56 | +>> 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. |
| 57 | + |
| 58 | + * Max. Monte-Carlo Iterations = 10000, ensuring 100 frame errors, and a minimum of 1000 iterations |
| 59 | + |
| 60 | + * Polar Code designed for BSC channel at p=0.100000 |
| 61 | + |
| 62 | + * Channel-states (BSC-p) to be run: |
| 63 | + 0.0100 0.0300 0.0500 0.0700 0.0900 0.1100 0.1300 0.1500 |
| 64 | + |
| 65 | + |
| 66 | +........(lots of text) |
| 67 | + |
| 68 | + |
| 69 | + BSC-p : 0.0100 0.0300 0.0500 0.0700 0.0900 0.1100 0.1300 0.1500 |
| 70 | + |
| 71 | + Frame Error Rates : 0 0.0081 0.0929 0.2880 0.6110 0.8580 0.9680 0.9980 |
| 72 | + |
| 73 | + Bit Error Rates : 0 0.0007 0.0125 0.0494 0.1564 0.2624 0.3650 0.4218 |
| 74 | + |
| 75 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +>> %%%%%%%%%%%%%%%%%%% 2. BEC Channel %%%%%%%%%%%%%%%%%%%%% |
| 80 | +>> initPC(N,K,'BEC',0.1); % Erasure prob 'epsilon' of BEC assumed during code-design = 0.1 |
| 81 | + |
| 82 | + All polar coding parameters & resources initialized. (in a structure - "PCparams") |
| 83 | + N: 128 |
| 84 | + K: 64 |
| 85 | + n: 7 |
| 86 | + FZlookup: [128x1 double] |
| 87 | + design_channelstring: 'BEC' |
| 88 | + design_channelstate: 0.1000 |
| 89 | + LLR: [1x255 double] |
| 90 | + BITS: [2x127 double] |
| 91 | + bitreversedindices: [128x1 double] |
| 92 | + index_of_first0_from_MSB: [128x1 double] |
| 93 | + index_of_first1_from_MSB: [128x1 double] |
| 94 | + |
| 95 | +>> u=(rand(K,1)>0.5); %random message |
| 96 | +>> x=pencode(u); %polar encoding |
| 97 | +>> y=OutputOfChannel(x,'BEC',0.15); %simulate BEC channel with erasure prob=0.1 |
| 98 | +>> uhat=pdecode(y,'BEC',0.15); %decode under the same BEC channel setting |
| 99 | + |
| 100 | +>> logical( sum( uhat == u ) == K ) %check for Decoding success! |
| 101 | + |
| 102 | +ans = |
| 103 | + |
| 104 | + 1 |
| 105 | + |
| 106 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 107 | + |
| 108 | + |
| 109 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 110 | + |
| 111 | +>> %%%%%%%%%%%% 3. AWGN Channel %%%%%%%%%%%%% |
| 112 | +>> initPC(N,K,'AWGN',0); %designSNR=0dB |
| 113 | + |
| 114 | + All polar coding parameters & resources initialized. (in a structure - "PCparams") |
| 115 | + N: 128 |
| 116 | + K: 64 |
| 117 | + n: 7 |
| 118 | + FZlookup: [128x1 double] |
| 119 | + design_channelstring: 'AWGN' |
| 120 | + design_channelstate: 0 |
| 121 | + LLR: [1x255 double] |
| 122 | + BITS: [2x127 double] |
| 123 | + bitreversedindices: [128x1 double] |
| 124 | + index_of_first0_from_MSB: [128x1 double] |
| 125 | + index_of_first1_from_MSB: [128x1 double] |
| 126 | + |
| 127 | +>> u=(rand(K,1)>0.5); %random message |
| 128 | +>> x=pencode(u); %polar encoding |
| 129 | +>> y=OutputOfChannel(x,'AWGN',1); %simulate AWGN channel at Eb/N0=1dB |
| 130 | +>> uhat=pdecode(y,'AWGN',1); %decode under the same AWGN channel setting. |
| 131 | + |
| 132 | +>> logical( sum( uhat == u ) == K ) %check for Decoding success! |
| 133 | + |
| 134 | +ans = |
| 135 | + |
| 136 | + 1 |
| 137 | + |
| 138 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 commit comments