⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 top_level_viterbi_decoding.m

📁 convolution coding program using viterabi algorithm
💻 M
字号:
% top level of the Viterbi decoder
close all;
clear all;
clc
% MATLAB script for viterbi simulation
% the viterbi decoder's constrain lenth is 7, with hard decision.
%setup the inistal state
n = 0; % the total number of testing data package
l = 29; % the input data length
e = 0; % errors found in the simulation
snr = 1; % snr ratio in db.
g = [1 1 1 1 0 0 1; 1 0 1 1 0 1 1]; %sequence generator
k = 1; % input bit number
hard_soft = 1; % 0 hard decision, 1 soft decision
rate = 1; % coding rate with punturing, 1 with rate 1/2, 2 with rate 2/3,
%3 with rate 3/4,
%check the data source length
if rem(l,6)~= 0
fl = 1;
else fl = 0;
end
%convolution coding part
while n < 10000
n= n + 1;
%data generator:
data = data_gen(l);
% convolutional encoder
data_conv = cnv_encd(g, k, data);
% puncturing block
data_pun = puncture(data_conv, rate);
% BPSK modulation and AWGN channel
data_dec = bpsk_awgn(data_pun, hard_soft, snr);
% depuncturing block
data_insert_zero = insert_zero(data_dec, rate, hard_soft, fl);
flag_pun = flag(data_insert_zero, rate);
% Viterbi decoder
data_decoded = viterbi(g,k,data_insert_zero,flag_pun);
% checking the decoded data with data source
for m= 1:l
if (data(m) ~=data_decoded(m)),e = e + 1;
end
end
end
% caculate the BER
p = e/(n*l);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -