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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

【Turbo】基于MATLAB的turbo编译码算法的仿真

發布時間:2023/12/31 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Turbo】基于MATLAB的turbo编译码算法的仿真 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.軟件版本

MATLAB2021a

2.核心代碼

%% Turbo Code % Encoder: RSC (Recursive Systematic Convolution) % Decoder: BCJR iterative decoder%% Parameter declaration close all;clear all;clc; N=1e4; %Block length X=floor(2*rand(1,N)); %Information bit generation Interleaver=randperm(N); %Interleaver(random permutation of first N integers) SNRdB=0:0.5:9; %SNR in dB SNR=10.^(SNRdB/10); %SNR in linear scale Iteration=4; ber=zeros(length(SNR),Iteration); %Simulated BER(Each column corresponds to one iteration) %% Encoding X_pi(1:N)=X(Interleaver(1:N)); %Interleaving input bits for RSC-1 encoderC0=zeros(1,N); %Code Bit for encoder RSC-0 C1=zeros(1,N); %Code Bit for encoder RSC-1 for i=1:Nk = i;while (k >= 1)C0(i) = xor ( C0(i),X(k) );C1(i) = xor ( C1(i),X_pi(k) );k=k-2;end end P0 = xor (X,[0,C0(1:end-1)]); P1 = xor (X_pi,[0,C1(1:end-1)]);Input_matrix=2*[0,1;0,1;0,1;0,1]-1; %First column represents input=0 and second column represents input=1 %Each row represents state 00,10,01 and 11 respectively Parity_bit_matrix=2*[0,1;1,0;0,1;1,0]-1; %Parity bits corresponding to inputs of above matrixmod_code_bit0=2*X-1; %Modulating Code Bits using BPSK Modulation mod_code_bit1=2*P0-1; mod_code_bit2=2*P1-1; fprintf('Encoding completed...\n');%% Decoding for k=1:length(SNR) %Simulation starts hereR0=sqrt(SNR(k))*mod_code_bit0+randn(1,N); % Received Codebits Corresponding to input bitsR1=sqrt(SNR(k))*mod_code_bit1+randn(1,N); % Received Codebits Corresponding to parity bits of RSC-0R2=sqrt(SNR(k))*mod_code_bit2+randn(1,N); % Received Codebits Corresponding to parity bits of RSC-1R0_pi(1:N)=R0(Interleaver(1:N)); %Interleaving received codebits corresponding to input bits to be used by RSC-1BCJR=0; %First iteration will be done by BCJR-0Apriori=ones(2,N); %First row for prob. of i/p 0 and second row for prob. of i/p 1Apriori=Apriori*0.5; %Initializing all apriori to 1/2for iter=1:Iteration %Iterative process starts hereif BCJR==0 %If BCJR is 0 then pass R0 and R1 to calculate GAMMAGAMMA=gamma_1(Apriori,N,Input_matrix,Parity_bit_matrix,R0,R1,SNR(k));else %If BCJR is 1 then pass R0_pi and R2 to calculate GAMMAGAMMA=gamma_1(Apriori,N,Input_matrix,Parity_bit_matrix,R0_pi,R2,SNR(k));endALPHA=alpha_1(GAMMA,N); %Calculation of ALPHA at each stage using GAMMA and ALPHA of previous stageBETA=beta_1(GAMMA,N); %Calculation of BETA at each stage using GAMMA and BETA of next stage%Calculating LAPPR using ALPHA,BETA and GAMMA[~,~,LAPPR_1]=lappr(ALPHA,BETA,GAMMA,N);decoded_bits=zeros(1,N);decoded_bits(LAPPR_1>0)=1; %Decoding is done using LAPPR valuesif BCJR==0 %If the decoder is BCJR-0 thenber(k,iter)=sum(abs((decoded_bits-X))); %calculate BER using input Xlappr_2(1:N)=LAPPR_1(Interleaver(1:N)); %Interleave the LAPPR values and pass to BCJR-1else %If the decoder is BCJR-1 thenber(k,iter)=sum(abs((decoded_bits-X_pi))); %calculate BER using input X_pilappr_2(Interleaver(1:N))=LAPPR_1(1:N); %Re-interleave the LAPPR values and pass to BCJR-0endLAPPR_1=lappr_2;ber(ber==1)=0; %Ignoring 1 bit errorApriori(1,1:N)=1./(1+exp(LAPPR_1)); %Apriori corresponding to input 0Apriori(2,1:N)=exp(LAPPR_1)./(1+exp(LAPPR_1)); %Apriori corresponding to input 1BCJR=~BCJR; %Changing the state of the decoder for the next iterationend %One iteration ends hereu = k/length(SNR) * 100;string = [num2str(round(u)) , '% decoding completed ...'];disp(string); end ber=ber/N; figure; %% Plots for simulated BER semilogy(SNRdB,ber(:,1),'k--','linewidth',2.0); hold on semilogy(SNRdB,ber(:,2),'m-o','linewidth',2.0); hold on semilogy(SNRdB,ber(:,3),'b-<','linewidth',2.0); hold on semilogy(SNRdB,ber(:,4),'r-<','linewidth',2.0); %% Theoretical expression for BER for corresponding convolution code BER=zeros(1,length(SNR)); for j=1:10BER=BER+(2^j)*(j)*qfunc(sqrt((j+4)*SNR)); end semilogy(SNRdB,BER,'c-','linewidth',2.0) title('Turbo decoder performance over AWGN channel for BPSK modulated symbols'); xlabel('SNR(dB)');ylabel('BER'); legend('1st Iteration','2nd Iteration','3rd Iteration','4th Iteration','Theoretical Bound'); grid on axis tight

3.操作步驟與仿真結論

4.參考文獻

[1] Berrou C . Near Shannon limit error-correcting coding and decoding : Turbo-codes[J]. Proc. ICC93, 1993.

D219

5.完整源碼獲得方式

方式1:微信或者QQ聯系博主

方式2:訂閱MATLAB/FPGA教程,免費獲得教程案例以及任意2份完整源碼

總結

以上是生活随笔為你收集整理的【Turbo】基于MATLAB的turbo编译码算法的仿真的全部內容,希望文章能夠幫你解決所遇到的問題。

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