%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 实现功能:
% 0. 生成Gallager生成矩阵
% 1. bpsk调制,经过高斯白噪声信道
% 2. 采用对数域的和积译码算法
% 3. 计算BER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%生成生成Gallager矩阵
clear all
close all
clc
tic
miu=3;wr=4;wc=3; % 矩阵H的尺寸为:[miu*wc,miu*wr],行数:miu*wc,列数:miu*wr,这里的H为[9 18]矩阵
[H,rows,cols] = Gallager_gen_LDPC(miu,wr,wc); % 调用函数Gallager_gen_LDPC生成Gallager生成矩阵
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[rows,cols]=size(H); %矩阵行与列的大小
n=cols;
k=n-rows;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%初始化
dB=[0:5]; % 定义信噪比的范围单位为dB
SNRpbit=10.^(dB/10); % Eb/No conversion from dB to decimal将dB的单位变成十进制的
N0 = 1./SNRpbit; % Eb=1 求出噪声的单边功率谱密度,单边功率谱密度告诉我们在信号的1赫兹带宽中加入的噪声的功率
R = k/n; % 码率
iteration = 50; % 设置最大迭代次数
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N = round(10^3/n);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BER=zeros(1,length(dB)); % array for Channel Error Rate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Errors=zeros(1,length(N*n));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for z=1:length(dB) %对每个信噪比进行仿真
%%%%%%%%%%%%%%% BPSK调制 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for m=1:N
v = round(rand(1,k));
[G,valid,t]=H2G(H); % 由校验矩阵生成生成矩阵
u=mod(v*G,2);% 由生成矩阵生成码字
tx_waveform=bpsk(u); % 调用BPSK函数,经过BPSK调制为全-1
sigma=sqrt(N0(z)/2); % 因为N0=2*sigma^2
rx_waveform=tx_waveform + sigma*randn(1,length(tx_waveform)); % rx_waveform为接收到的波形,产生一个服从N(0,1)分布的量,然后用它乘上sigma就表示服从N(0,sigma^2)分布
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%译码
vhat = decodeLogDomain(rx_waveform, H, sigma, iteration);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%计算BER
Errors(n*(m-1)+find(u~=vhat))=1; %将译出的码字与传输的码字比较,将对应不相等的位
end
BER(z)=sum(Errors)/(N*n); %计算比特错误率
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
semilogy(dB,BER,'-o'); %画图
title('Bit Error Rate');
ylabel('BER');
xlabel('Eb/No (dB)');
grid on;
toc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【达摩老生出品,必属精品,亲测校正,质量保证】 资源名:matlab_LDPC_编码译码_BPSK调制_误码率_低密度奇偶校验 资源类型:matlab项目全套源码 源码说明: 全部项目源码都是经过测试校正后百分百成功运行的,如果您下载后不能运行可联系我进行指导或者更换。 适合人群:新手及有一定经验的开发人员
资源推荐
资源详情
资源评论
收起资源包目录
matlab_LDPC_编码译码_BPSK调制_误码率_低密度奇偶校验.zip (8个子文件)
matlab_LDPC_编码译码_BPSK调制_误码率_低密度奇偶校验
main.m 4KB
Matlab实现无约束条件下普列姆(Prim)算法.docx 14KB
Gallager_gen_LDPC.m 3KB
bpsk.m 143B
main.asv 4KB
Gallager_gen_LDPC.asv 3KB
H2G.m 2KB
decodeLogDomain.m 3KB
共 8 条
- 1
阿里matlab建模师
- 粉丝: 3644
- 资源: 2807
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页