91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-17
  • 語言: Matlab
  • 標簽: MATLAB??

資源簡介

m序列產生與卷積編碼的設計實驗,用MATLAB進行仿真,代碼在壓縮包中。

資源截圖

代碼片段和文件信息

function?demo
input=randi([01][115]);%輸入信號
figure
subplot(221);
drawSig(input);
grid?on;?title(‘Input?Code‘);
M=mseq([1?0?0?1]);
subplot(222);
drawSig(M);
grid?on;?title(‘M?Code‘);
input_r=scramble(input);%加擾
subplot(223);
drawSig(input_r);
grid?on;?title(‘Output?Code?after?scramble‘);
Y=coder(input_r);%進行卷積編碼
subplot(224);
drawSig(Y);
grid?on;?title(‘Output?Code?after?encoding‘);
SNR?=5;
S=awgn(YSNR);%經過高斯信道
G?=?panjue(S);
figure
subplot(221);
drawSig(G);
grid?on;?title(‘Output?Code?after?Gauss?channel‘);
O=decoder(G);%維特比譯碼
subplot(222);
drawSig(O);
grid?on;?title(‘Output?Code?after?viterbi?decoding‘);
Res=scramble(O);%解擾
subplot(223);
drawSig(Res);
grid?on;?title(‘Output?Code?after?descramble‘);?
%?errorrate
end

function??errorrate

SNRdb?=?5:1:20;
msg?=?randi([01][1100]);
cycl?=50;
ber?=zeros(cycllength(SNRdb));
n=length(msg);
for?i=1:cycl
????for?j=1:length(SNRdb)
????????input_r=scramb(msg);
????????code?=?encoding(input_r);
????????addnoise=awgn(codeSNRdb(j)‘measured‘);??
????????Q?=?panjue(addnoise);
????????L=decoder(Q);
????????Out=scramb(L);
????????[numberratio]?=?biterr(msgOut);
????????ber(ij)?=?ratio;
????end
end
ber=mean(ber);
figure
semilogy(SNRdbber‘B‘)title(‘Error?Rate‘);grid?on;
xlabel(‘rb/dB‘);ylabel(‘Pe‘);
end



function?[seq]=mseq(coef)
%?此函數用來生成m序列
%?coef為反饋系數向量
m=length(coef);
len=2^m-1;?%?得到最終生成的m序列的長度?????
backQ=0;?%?對應寄存器運算后的值,放在第一個寄存器
seq=zeros(1len);?%?給生成的m序列預分配
registers?=?[1?zeros(1?m-1)];?%?給寄存器分配初始結果
for?i=1:len
????seq(i)=registers(m);
????backQ?=?mod(sum(coef.*registers)??2);?%特定寄存器的值進行異或運算,即相加后模2
????registers(2:length(registers))?=?registers(1:length(registers)-1);?%?移位
????registers(1)=backQ;?%?把異或的值放在第一個寄存器的位置
end
end

%4級反饋移位寄存器產生16位m序列
function?Y=mxulie()
F(100)=0;
a3=1;
a2=0;
a1=0;
a0=0;
for?i=1:100
????F(i)=a0;
????a0=a1;
????a1=a2;
????a2=a3;
????a3=mod((a3+F(i))2);
end
Y=F;
end


function?y=encoding(s)?
r=[0?0?0];
x=zeros(1length(s)*3);??????%為編碼后的碼字分配空間?
for?i=1:length(s)?
????x(3*i-2)=mod((s(i))2);???%由生成多項式畫出編碼器得來
????x(3*i-1)=mod((s(i)+r(2))2);?
????x(3*i)=mod((s(i)+r(1)+r(2))2);?
????r(3)=r(2);
????r(2)=r(1);???????????????????????????%運算一次后移位
????r(1)=s(i);?
end
y=x;
end

%?1/33卷積編碼
function?Y?=?coder(?X?)
len=length(X);
T=zeros(1len+3);
F=zeros(1len*3);
for?i=4:len+3
????T(i)=X(i-3);
end
for?i=1:len
????F(3*(i-1)+1)=T(i+3);
????F(3*(i-1)+2)=xor(T(i+3)T(i+1));
????F(3*(i-1)+3)=xor(xor(T(i+3)T(i+2))T(i+1));
end
Y=F;
end



function??Y?=?panjue(X)
n=length(X);
G(n)=0;
for?i=1:n
????if?X(i)>0.5
????????G(i)?=1;
????else
????????G(i)?=0;
????end
end
Y=G;
end


%1/33維特比卷積解碼
function?Y?=?decoder(?X?)
len=length(X);
Path=zeros(4len/3‘int8‘);%4條幸存路徑
Path_t=zeros(4len/3‘int8‘);
Da=0;Db=0;Dc=0;Dd=0;%抵達abcd總漢明距離
Pa=1;Pb=2;Pc=3;Pd=4;%abcd路徑指針
T(9)=0;
for?i=1:9
????T(i)=X(i);
end
%a
tp1=dist(T[0?0?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????6809??2019-03-20?20:53??demo.m

評論

共有 條評論