📄 testsiso.m
字号:
%SISO.m的测试程序
clear
clc
snr_db=3;
snr=10.^(snr_db/10);
N=48; %帧长
% InVar=1.5/snr; %方差
InVar=1.0/snr; %方差
% IntTimes=2; %迭代次数
%sourse=randint(1,2*N);
%编码
%A=sourse(1:2:2*N-1);
%B=sourse(2:2:2*N);
A=[0 0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 0 1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 0 1 0 1 1 0];
B=[0 1 0 0 0 1 1 0 1 1 0 0 0 0 1 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 0 0 1 0];
sourse=[A;B];
sourse=reshape(sourse,1,2*N);
[W1,Y1,Sc]=CRSC(A,B);
% [Ainter Binter]=interleaver(A,B,N);
% [W2,Y2]=CRSC(Ainter,Binter);
%调制并经过AWGN信道
Ar=2*A-1+sqrt(InVar)*randn(1,N);
Yr1=2*Y1-1+sqrt(InVar)*randn(1,N);
Wr1=2*W1-1+sqrt(InVar)*randn(1,N);
Br=2*B-1+sqrt(InVar)*randn(1,N);
% Yr2=2*Y2-1+sqrt(InVar)*randn(1,N);
% Wr2=2*W2-1+sqrt(InVar)*randn(1,N);
%解码
% decoded=DouBinTurboDecode(Ar,Br,Wr1,Yr1,Wr2,Yr2,N,IntTimes,InVar);
[OutLa ,OutLe]=SISO(zeros(3,N),Ar,Br,Wr1,Yr1,InVar,N,Sc);
for k=1:N
MaxAbsIndex=FindMaxAbs(OutLa(:,k));
if(OutLa(MaxAbsIndex,k)<0)
UHat(k)=0;
decoded(2*k-1:2*k)=[0 0];
else
UHat(k)=MaxAbsIndex;
decoded(2*k-1:2*k)=de2bi(MaxAbsIndex,2,'left-msb');
end
end
[ErrorNum ber]=biterr(sourse,decoded);
sprintf('%d numbers transmitted,%d errors,ber is %f\n',2*N,ErrorNum,ber)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -