日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MATLAB实现的Reed-Muller(RM码,里德-马勒编码)编码解码纠错以及BER分析

發布時間:2023/12/9 编程问答 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MATLAB实现的Reed-Muller(RM码,里德-马勒编码)编码解码纠错以及BER分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MATLAB實現的Reed-Muller編碼解碼糾錯以及BER分析

  • 背景
  • 代碼
    • 計算BER
  • 計算不使用RM編碼情況時的BER(模擬環境與理論情況)
  • 與漢明編碼做對比
  • 總結

背景

本科時信息論與編碼的作業,RM(2,4)編碼

課程為

Information Theory & Coding Vaibhav Kumar, PhD School of Electrical & Electronic Engineering University College Dublin – The Republic of Ireland

下述作業也是老師布置的,如果涉及到版權問題我會刪掉該博客。流程邏輯如下:

數據->RM編碼->BPSK調制->加入AWGN(模擬傳輸時的噪聲)->BPSK解調->解碼(Majority-Logic解碼)->輸出數據

給定生成矩陣為

v0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v4 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 v3 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 v2 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 v1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 v3v4 = 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 v2v4 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 v1v4 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 v2v3 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 v1v3 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 v1v2 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1

接收到的數據可以寫成r=v+e的格式


代碼

clc,clear Eb_N0_log=0:0.5:10; %dB Eb_N0=10.^(Eb_N0_log/10); R_coded=11/16; %R BER_coded=zeros(1,21); %store BER in different Eb/N0 G=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1; %v00 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1; %v40 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1; %v30 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1; %v20 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1; %v10 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1; %v3v40 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1; %v2v40 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1; %v1v40 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1; %v2v30 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1; %v1v30 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1; %v1v2]; %generator matrix for i=1:21 %calculate BER in different Eb/N0SNR_coded=2*R_coded*Eb_N0(i); %calculate SNRmessage=round(rand(1,1980000)); %generate original data u = (a0 a4 a3 a2 a1 a34 a24 a14 a23 a13 a12),px_w=1; %signal's powerpn_w=px_w/SNR_coded; %noise's powererror_number=0; %error bit numberfor index=1:180000 %90000 blocksm=message(1,11*index-10:11*index);%m=[message(11*index-10),message(11*index-9),message(11*index-8),message(11*index-7),message(11*index-6),message(11*index-5),message(11*index-4),message(11*index-3),message(11*index-2),message(11*index-1),message(11*index)]; %one blobk datav=mod(m*G,2); %generate vmessage_modul=1-v*2; %0->1,1->-1 modulationr=message_modul+sqrt(pn_w)*randn(1,16); %add white Gaussian noiser=r<0; %demodulationa12=sum([mod(r(1)+r(2)+r(3)+r(4),2),mod(r(5)+r(6)+r(7)+r(8),2),mod(r(9)+r(10)+r(11)+r(12),2),mod(r(13)+r(14)+r(15)+r(16),2)]==1);if a12>2a12=1;elseif a12<2a12=0;elsea12=round(rand());end %check-sums for a12a13=sum([mod(r(1)+r(2)+r(5)+r(6),2),mod(r(3)+r(4)+r(7)+r(8),2),mod(r(9)+r(10)+r(13)+r(14),2),mod(r(11)+r(12)+r(15)+r(16),2)]==1);if a13>2a13=1;elseif a13<2a13=0;elsea13=round(rand());end %check-sums for a13a23=sum([mod(r(1)+r(3)+r(5)+r(7),2),mod(r(2)+r(4)+r(6)+r(8),2),mod(r(9)+r(11)+r(13)+r(15),2),mod(r(10)+r(12)+r(14)+r(16),2)]==1);if a23>2a23=1;elseif a23<2a23=0;elsea23=round(rand());end %check-sums for a23a14=sum([mod(r(1)+r(2)+r(9)+r(10),2),mod(r(3)+r(4)+r(11)+r(12),2),mod(r(5)+r(6)+r(13)+r(14),2),mod(r(7)+r(8)+r(15)+r(16),2)]==1);if a14>2a14=1;elseif a14<2a14=0;elsea14=round(rand());end %check-sums for a14a24=sum([mod(r(1)+r(3)+r(9)+r(11),2),mod(r(2)+r(4)+r(10)+r(12),2),mod(r(5)+r(7)+r(13)+r(15),2),mod(r(6)+r(8)+r(14)+r(16),2)]==1);if a24>2a24=1;elseif a24<2a24=0;elsea24=round(rand());end %check-sums for a24a34=sum([mod(r(1)+r(5)+r(9)+r(13),2),mod(r(2)+r(6)+r(10)+r(14),2),mod(r(3)+r(7)+r(11)+r(15),2),mod(r(4)+r(8)+r(12)+r(16),2)]==1);if a34>2a34=1;elseif a34<2a34=0;elsea34=round(rand());end %check-sums for a34r=mod(r-a12*G(11,:)-a13*G(10,:)-a23*G(9,:)-a14*G(8,:)-a24*G(7,:)-a34*G(6,:),2);a1=sum([mod(r(1)+r(2),2),mod(r(3)+r(4),2),mod(r(5)+r(6),2),mod(r(7)+r(8),2),mod(r(9)+r(10),2),mod(r(11)+r(12),2),mod(r(13)+r(14),2),mod(r(15)+r(16),2),]==1);if a1>4a1=1;elseif a1<4a1=0;elsea1=round(rand());end %check-sums for a1a2=sum([mod(r(1)+r(3),2),mod(r(2)+r(4),2),mod(r(5)+r(7),2),mod(r(6)+r(8),2),mod(r(9)+r(11),2),mod(r(10)+r(12),2),mod(r(13)+r(15),2),mod(r(14)+r(16),2),]==1);if a2>4a2=1;elseif a2<4a2=0;elsea2=round(rand());end %check-sums for a2a3=sum([mod(r(1)+r(5),2),mod(r(2)+r(6),2),mod(r(3)+r(7),2),mod(r(4)+r(8),2),mod(r(9)+r(13),2),mod(r(10)+r(14),2),mod(r(11)+r(15),2),mod(r(12)+r(16),2),]==1);if a3>4a3=1;elseif a3<4a3=0;elsea3=round(rand());end %check-sums for a3a4=sum([mod(r(1)+r(9),2),mod(r(2)+r(10),2),mod(r(3)+r(11),2),mod(r(4)+r(12),2),mod(r(5)+r(13),2),mod(r(6)+r(14),2),mod(r(7)+r(15),2),mod(r(8)+r(16),2),]==1);if a4>4a4=1;elseif a4<4a4=0;elsea4=round(rand());end %check-sums for a4r=mod(r-a1*G(5,:)-a2*G(4,:)-a3*G(3,:)-a4*G(2,:),2);a0=sum(r==1);if a0>8a0=1;elseif a0<8a0=0;elsea0=round(rand());end %check-sums for a0signal=[a0,a4,a3,a2,a1,a34,a24,a14,a23,a13,a12];error_number=error_number+sum(sum(signal~=m)); %find the number of error bitsendBER_coded(i)=error_number/1980000; end semilogy(Eb_N0_log,BER_coded); xlabel('Eb/N0 [dB]'); ylabel('BER'); title('BER versus Eb/N0');Eb_N0_log=0:0.5:10; %dB Eb_N0=10.^(Eb_N0_log/10); BER =0.5*erfc(sqrt(2*Eb_N0)/sqrt(2)); %Q function hold on; semilogy(Eb_N0_log,BER); xlabel('Eb/N0 [dB]'); ylabel('BER'); title('BER versus Eb/N0');R_uncoded=1; %R BER_uncoded=zeros(1,21); for i=1:21 %calculate BER in different Eb/N0SNR_uncoded=2*R_uncoded*Eb_N0(i); %SNRmessage=round(rand(1,1980000)); %generate original datamessage_modul=1-message.*2; %0->1,1->-1 modulationpx_w=1; %signal's powerpn_w=px_w/SNR_uncoded; %noise's powerr=message_modul+sqrt(pn_w)*randn(1,1980000); %add white Gaussian noiseerror_number=0;r=r<0; %demodulationerror_number=error_number+sum(sum(r~=message)); %find the number of error bitsBER_uncoded(i)=error_number/1980000; end hold on; semilogy(Eb_N0_log,BER_uncoded); xlabel('Eb/N0 [dB]'); ylabel('BER '); title('BER versus Eb/N0'); legend('RM-coded(simulation)','Uncoded(theory)','Uncoded(simulation)');%I extend the horizontal coordinate of Uncoded(theory) and Uncoded(simulation)% Eb_N0_log=0:0.5:11; %dB % Eb_N0=10.^(Eb_N0_log/10); % BER =0.5*erfc(sqrt(2*Eb_N0)/sqrt(2)); %Q function % hold on; % semilogy(Eb_N0_log,BER); % xlabel('Eb/N0 [dB]'); % ylabel('BER'); % title('BER versus Eb/N0'); % % R_uncoded=1; %R % BER_uncoded=zeros(1,23); % for i=1:23 %calculate BER in different Eb/N0 % SNR_uncoded=2*R_uncoded*Eb_N0(i); %SNR % message=round(rand(1,1980000)); %generate original data % message_modul=1-message.*2; %0->1,1->-1 modulation % px_w=1; %signal's power % pn_w=px_w/SNR_uncoded; %noise's power % r=message_modul+sqrt(pn_w)*randn(1,1980000); %add white Gaussian noise % error_number=0; % r=r<0; %demodulation % error_number=error_number+sum(sum(r~=message)); %find the number of error bits % BER_uncoded(i)=error_number/1980000; % end % hold on; % semilogy(Eb_N0_log,BER_uncoded); % xlabel('Eb/N0 [dB]'); % ylabel('BER '); % title('BER versus Eb/N0'); % legend('RM-coded(simulation)','Uncoded(theory)','Uncoded(simulation)');

計算BER

1、隨機生成1980000比特,分為180000 block,每個block稱為m。
2、進行RM編碼。
3、進行BPSK調制。
4、添加高斯白噪聲

5、BPSK解碼。
6、Majority-Logic解碼。計算錯誤比特的個數。


7、計算BER。
結果:

計算不使用RM編碼情況時的BER(模擬環境與理論情況)

1、隨機生成比特。
2、進行BPSK調制。
3、添加高斯白噪聲
4、BPSK解碼。
5、計算錯誤比特的個數。
6、利用第五部分結果計算模擬環境下的BER。
6、使用erfc函數計算理論情況下的BER。
結果:

與漢明編碼做對比

與https://blog.csdn.net/weixin_44480014/article/details/123203931實現的漢明編碼做對比。
結果:

總結

從BER的角度來看,如果Eb/N0小于7.152dB,未編碼系統優于RM編碼系統,如果Eb/N0大于7.152dB,RM編碼系統優于未編碼系統。如果Eb/N0小于7.681dB,漢明編碼系統優于RM編碼系統,如果Eb/N0大于7.681dB,RM編碼系統優于漢明編碼系統。

總結

以上是生活随笔為你收集整理的MATLAB实现的Reed-Muller(RM码,里德-马勒编码)编码解码纠错以及BER分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。