% debugging
function PolarCode_Simulation
%% 编码参数
clc;clear;clear all;
L =16; R=1/2; K=L*R;
n=log2(L);
TM = TransformMatrixGeneration(n);%有比特翻转
SNR=[0:0.5:4];
% generator = [1 1 0 0 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 1 0 1 1];
% c = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % x^k
generator = [1 1 0 0 1];
c = [1 0 0 0 0 ]; % x^k
CRC_len=length(generator)-1; r_len=K-CRC_len;
ChannelType='BAWGNC';
%% 仿真结果记录
bit_count_SC = zeros(size(SNR));
frame_count_SC= zeros(size(SNR));
bler_SC= zeros(size(SNR));
%% 最大蒙特卡洛次数
MaxCircle = 1000;
for i=1:length(SNR)
sigma = sqrt(0.5*10^(-0.1*SNR(i))/R);
[ChannelSet, LLR]=guassian_approximation(L,K,sigma);
G = TM(:,ChannelSet); % 生成矩阵
for cir = 1:MaxCircle
x_m = randi([0, 1], r_len,1);
multip = conv(c,x_m);
[divid, remainder]=deconv(multip,generator);
remainder=(mod(remainder(end-3:end),2))'; % 对除法的余数做模二运算
code=[x_m;remainder]; % 只是在原序列后面加上CRC码
x_s = BinaryMatrixProduct(G,code);
x_a = 1-2*x_s;
%% 信道
noise = sigma*randn(L,1);
y= x_a+ noise;
%% 解调
x_m_SC = SC_Decode(y, ChannelSet, sigma, ChannelType); % Path Metric
x_m_sc=x_m_SC(1:r_len);
[divid, remainder]=deconv(x_m_SC,generator); % 对多项式的除,就等于做反卷积
remainder=mod(remainder(end-3:end),2); % 对除法的余数做模二运算
% if isequal(remainder,[0;0;0;0]);
% msgbox(['CRC校验正确!']);
% else
% msgbox(['CRC校验错误']);
% end
frame_count_SC(i) = frame_count_SC(i) + any(x_m_sc ~=x_m);
if frame_count_SC(i) > 20
break;
end
end
bler_SC(i) = frame_count_SC(i)/cir
% ber_SC(i) = bit_count_SC(i)/cir /K;
end
semilogy(SNR, bler_SC, '-+');
hold on
end
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
polar代码MATLAB (1).rar (23个子文件)
polar代码MATLAB (1)
fun_f.m 199B
BGenerate.m 260B
fai_inv.m 346B
int2bin.m 155B
PolarCode_Simulation.m 2KB
delete.m 1KB
PolarCode_Simulation_1.m 1KB
SC_Decode.m 2KB
LikeHoodRatio_1.m 536B
ChannelChoose.m 830B
SC_Decode_1.m 1KB
bin2int.m 86B
DoIter.m 805B
fun_g.m 262B
LogLikeHood.m 401B
fai.m 177B
LikeHoodRatio.m 566B
guassian_approximation.m 521B
TransformMatrixGeneration.m 351B
GA.m 202B
BinaryMatrixProduct.m 71B
path_metric.m 154B
Channel.m 478B
共 23 条
- 1
御道御小黑
- 粉丝: 58
- 资源: 1万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论18