找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6485|回复: 1
收起左侧

LDPC编码学习 Matlab程序

[复制链接]
ID:204662 发表于 2017-5-25 11:39 | 显示全部楼层 |阅读模式
LDPC非常好用的工具。
0.png

Matlab程序源程序如下:
  1. %--------------------------------------------------------------------------
  2. %-----Chamitha-de-Alwis----------------------------------------------------
  3. %-----University-of-Surrey-------------------------------------------------
  4. %-----chamithadealwis@hotmail.com------------------------------------------
  5. %--------------------------------------------------------------------------

  6. clear
  7. clc
  8. clear

  9. %--------------------------------------------------------------------------
  10. %-----Set-Simulation-Parameters--------------------------------------------
  11. %--------------------------------------------------------------------------

  12. snrs = [10 13 15];      %SNR values
  13. codeRate = 9/10; %Possible values for codeRate are 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 5/6, 8/9, and 9/10. The block length of the code is 64800
  14. mod_order = 4;  %PSK Modulation Order
  15. frames = 2500;  %Number of frames (fame size is 64800 bits) to be simulated

  16. %--------------------------------------------------------------------------

  17. rounds = size(snrs,2);

  18. messageLength = round(64800*codeRate);

  19. for run = 1:1:rounds

  20. framepattern = [];   
  21.    
  22. snrvalue = snrs(run);

  23. H = dvbs2ldpc(codeRate);

  24. %spy(H);   % Visualize the location of nonzero elements in H.

  25. errors = 0;

  26. hEnc = comm.LDPCEncoder(H);
  27. hMod = comm.PSKModulator(mod_order, 'BitInput',true);
  28. hChan = comm.MIMOChannel('MaximumDopplerShift', 0, 'NumTransmitAntennas',1,'NumReceiveAntennas',1, 'TransmitCorrelationMatrix', 1, 'ReceiveCorrelationMatrix', 1, 'PathGainsOutputPort', true);
  29. hAWGN = comm.AWGNChannel('NoiseMethod','Signal to noise ratio (SNR)','SNR',snrvalue);
  30. % hDemod = comm.PSKDemodulator(4, 'BitOutput',true,'DecisionMethod','Approximate log-likelihood ratio',...
  31. %                              'Variance', 1/10^(hChan.SNR/10));
  32. hDemod = comm.PSKDemodulator(4, 'BitOutput',true,'DecisionMethod','Approximate log-likelihood ratio');                        
  33. hDec = comm.LDPCDecoder(H,'DecisionMethod', 'Soft decision');
  34. %hError = comm.ErrorRate;
  35. for counter = 1:frames
  36.     receiveddataBits = [];
  37.     data           = logical(randi([0 1], messageLength, 1));
  38. %    data = randi([0 hMod.ModulationOrder-1], messageLength, 1);
  39.     encodedData    = step(hEnc, data);


  40.    
  41.    
  42.     modSignal      = step(hMod, encodedData);
  43.    
  44.    
  45.     % Transmit through Rayleigh and AWGN channels
  46.     [chanOut, pathGains] = step(hChan, modSignal);  
  47.     receivedSignal = step(hAWGN, chanOut);
  48.     demodSignal    = step(hDemod, receivedSignal);
  49.     receivedBits   = step(hDec, demodSignal);
  50.     %errorStats     = step(hError, data, receivedBits);
  51.    
  52.     for i=1:1:messageLength
  53.         if receivedBits(i,1) >= 0
  54.             receiveddataBit = 0;
  55.         else
  56.             receiveddataBit = 1;
  57.         end
  58.         receiveddataBits = [receiveddataBits; receiveddataBit];
  59.     end
  60.    
  61.     newErrors = nnz(receiveddataBits-data);
  62.     errors = errors + newErrors;
  63.     if newErrors == 0
  64.         addFramepattern = 1;
  65.     else
  66.         addFramepattern = 0;
  67.     end
  68.     framepattern = [framepattern addFramepattern];
  69.    
  70.     clc
  71.     run
  72.     counter
  73.     errors
  74.     code_errors = (size(framepattern,2) - nnz(framepattern));
  75.     code_errors
  76. end

  77. SumErrors(run) = errors;
  78. ……………………

  79. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
LDPC_AWGN.zip (2.17 KB, 下载次数: 32)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:345094 发表于 2018-6-5 01:06 | 显示全部楼层
误码率信噪比曲线出来结果不正确为什么?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表