- 经验
- 17
- 分贝
- 0
- 家园分
- 14
- 在线时间:
- 0 小时
- 最后登录:
- 2012-5-23
- 帖子:
- 5
- 精华:
- 0
- 注册时间:
- 2012-5-23
- UID:
- 799090
注册:2012-5-23
|
现在我想将下面的程序改成实现turbo码 下载次数: 2
半小时前
编译码的程序,能够出来turbo码编码前、编码后、译码后的波形,具体的代码在附件中,主程序在下面
clc
clear
SNR = 0:0.5:3;
nframe = 1000;
length_frame = 192;
rate = 1/2;
num_of_iter = 10;
% g = [1 1 1 1 1
% 1 0 0 0 1]; % (37,21)生成和反馈多项式
% g = [1 1 1
% 1 0 1]; % (7,5)生成和反馈多项式
% g = [1 0 1 1
% 1 1 0 1]; % LTE标准Turbo码
g = [1 1 0 1
1 1 1 1]; % (15,17)生成和反馈多项式
for nn=1:length(SNR)
Es_N0 = rate*10^(SNR(nn)/10);
N0 = 1/Es_N0;
for frame=1:nframe
frame
%% source data
data = round(rand(1,length_frame));
%% RSC encoder
[ Turbo_data, interleaver_index ] = Turbo_encoder( data, rate, g ); %rate = 1/2 or 1/3
%% BPSK调制
mod_out = 2*Turbo_data-1;
%% 经过AWGN信道
channel_out = mod_out+sqrt(N0/2)*randn(size(mod_out));
%% log_MAP算法译码
data_out = Turbo_decoder( channel_out, N0, rate, interleaver_index, num_of_iter, g);
error(frame) = sum(xor(data,data_out));
end
BER(nn) = sum(error)/nframe/length_frame
end
hold on
semilogy(SNR,BER,'-bo'); |
|
|