资源简介
卷积码的仿真程序
,得到误码率曲线,在不同码率和生成码字下对应不同的纠错能力,反应在误码率曲线上
代码片段和文件信息
% simulation of convolutional encoding / Viterbi decoding
clear all;
clc
codeselect=1;
switch codeselect
case 1
Gpoly=[27 31];
case 2
Gpoly=[6 2 6; 2 4 4];
case 3
Gpoly=[4 2 6; 1 4 7];
case 4
Gpoly=[60 30 70; 14 40 74];
otherwise
Gpoly=[70 30 20 40; 14 50 0 54; 4 10 74 40];
end
%===============================================================
% Find key descriptors of the convolutional code
%===============================================================
display_info=1;
[K M nu n k coderate StateTable]=getcodeparameters(Gpoly);
% StateTable
%===============================================================
% Generate Data
%===============================================================
NoBits=1000; % How many bit are to be sent
EbNodBVals=[0:1:3];
BER=zeros(10length(EbNodBVals));
BER2=BER;
countSNRs=0;
for Simulation=1:10
for SNR=1:length(EbNodBVals)
countSNRs=countSNRs+1;
NoOfBitErrors=0;
TotalNoOfBits=0;
TotalNoOfCodedBits=0;
NoofCodedBitErrors=0;
BERtemp=Inf;
while NoOfBitErrors<10
m=floor(rand(1NoBits).*2); % generate data bits
%===============================================================
% Prepare data by adding leading/trailing zeros to start/end in the zero
% state
%===============================================================
% first add k*nu leading zeros to start from 0 state
m2=[zeros(1k.*nu) m zeros(1k.*nu)];
NoOfLeadingAddedZeros=k.*nu;
% add extra zeros to make m a multiple of k
if rem(length(m2)k) > 0 % length(m) must be a multiple of k
% No of input bits to encoder
ExtraZeros=zeros(size(1:k-rem(length(m)k)));
NoOfExtraZeros=length(ExtraZeros);
m2=[m2 ExtraZeros]; % add the zeros
NoOFTrailingAddedZeros=k.*nu+NoOfExtraZeros;
else
NoOFTrailingAddedZeros=k.*nu;
end
%===============================================================
% Encode Data Using Covolutional encoder
%===============================================================
[cc_binPathThroughTrellis]=encoder(m2knStateTable);
%[cc_bin]=encoder(mknStateTable); %If PathThroughTrellis isn‘t needed
%===============================================================
% simulate Channel
%===============================================================
% simulate BPSK modulator
s=2.*c_bin-1;
% noise
EbNo=10.^(EbNodBVals(SNR)./10);
EsNo=EbNo.*coderate;
Es=1;
No=Es./EsNo;
sigma=sqrt(No.*2)./2;
noise=sigma.*randn(size(s));
sr=s+n
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5602 2009-06-10 18:05 procedure_orgit\AverageBER.fig
文件 4956 2009-12-15 21:23 procedure_orgit\BER_channel.m
文件 2555 2009-06-10 17:24 procedure_orgit\BER_NOchannel.m
文件 336 2007-03-13 19:51 procedure_orgit\bin2deci.m
文件 237 2007-03-13 20:16 procedure_orgit\deci2bin.m
文件 3723 2009-06-10 17:29 procedure_orgit\decoder.m
文件 994 2009-06-10 17:32 procedure_orgit\encoder.m
文件 3968 2009-06-10 17:32 procedure_orgit\getcodeparameters.m
文件 621 2009-06-08 13:12 procedure_orgit\oct2bin.m
目录 0 2009-12-15 21:20 procedure_orgit
----------- --------- ---------- ----- ----
22992 10
- 上一篇:SCMA调制解调matlab仿真代码
- 下一篇:qpsk3.m
评论
共有 条评论