polar协作polar码和非协作polar码的误码率性能matlab仿真
Posted fpga&matlab
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了polar协作polar码和非协作polar码的误码率性能matlab仿真相关的知识,希望对你有一定的参考价值。
1.软件版本
matlab2017b
2.本算法理论知识
《基于Polar码的协作编码和分集技术研究》
3.部分源码
clc;
clear all;
close all;
warning off;
addpath 'functions\\'
%数据块大小
SNR = [1,2,3,4,4.5];
rate1 = 0.54;
rate2 = 0.45;
n = 8;
N = 2^n;
[Vals,Inds]= func_rates(n,0.5);
for i=1:length(SNR)
%设置误码率参数
Bit_err(i) = 0;
Num_err = 0;
%误码率累加器
Numbers = 0;
K1 = round(rate1*N);
K2 = round(rate2*N);
frozen_pos1 = Inds(1:N-K1);
free_pos1 = sort(Inds(N-K1+1:N),'ascend');
frozen_pos2 = Inds(1:N-K2);
free_pos2 = sort(Inds(N-K2+1:N),'ascend');
z1 = ones(N,1);
z1(frozen_pos1)= 0;
z2 = ones(N,1);
z2(frozen_pos2)= 0;
sigma = 1/sqrt(10^(SNR(i)/10));
while Num_err <= 50000
fprintf('SNR = %f\\n', SNR(i));
Num_err
data_in1 = randsrc(K1,1,[0 1]);
u = zeros(N,1);
u(free_pos1) = data_in1;
x = func_encode(u);
Trans_BPSK = 2*x-1;
%S->D
%S->D
Rec_sd_1 = Trans_BPSK + sigma*randn(N,1);
Rec_sd = Rec_sd_1;
%S->R
%S->R
Rec_sr_1 = Trans_BPSK + sigma*randn(N,1);
Rec_sr = Rec_sr_1;
%中继点的判决
%先译码
y1 = Rec_sr;
L1 = exp(-2*y1);
v1 = func_SCdecoder(L1,z1);
data_out1 = v1(free_pos1);
u2 = zeros(N,1);
u2(free_pos2) = data_out1(1:K2)';
x2 = func_encode(u2);
Trans_BPSK2 = 2*x2-1;
Rec_rd_1 = Trans_BPSK2 + sigma*randn(N,1);
Rec_rd = Rec_rd_1;
%接收端
y2 = Rec_sd;
L2 = exp(-2*y2);
v2 = func_SCdecoder(L2,z2);
data_out2 = v2(free_pos2);
y3 = Rec_rd;
L3 = exp(-2*y3);
v3 = func_SCdecoder(L3,z2);
data_out3 = v3(free_pos2);
nberr1 = length(find(data_out2~=data_in1(1:K2)'));
nberr2 = length(find(data_out3~=data_in1(1:K2)'));
Num_err = Num_err+min(nberr1,nberr2);
Numbers = Numbers+1;
end
Bit_err(i) = Num_err/(length(data_in1)*Numbers);
end
save R3.mat SNR Bit_err
4.仿真结论
5.参考文献
[1]陆婷婷. 极化码的编解码研究及仿真[D]. 南京理工大学, 2013.A14-27
以上是关于polar协作polar码和非协作polar码的误码率性能matlab仿真的主要内容,如果未能解决你的问题,请参考以下文章
python Python:cmath,polar(),complex()
数据可视化之MATPLOTLIB实战:PLT.POLAR()函数 绘制极线图 (转载)