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

📄 convmainusemex.m

📁 卷积码的编码及解码代码
💻 M
字号:
% Convolutional code simple demonstration
% Everything start here
%
%
% Copyright Bagawan S. Nugroho, 2006

clear all; clc;

% Parameters (change as necessary)
N = 126;             % Number of data
SNR = .5;            % Signal to noise ratio in dB

% Generator matrix (change as necessary)
% R = 3, transfer function = [g0 = 557; g1 = 663; g2 = 711]
% This example of G can be found in the 3GPP specifications (see text)
G = [1 0 1 1 0 1 1 1 1;1 1 0 1 1 0 0 1 1;1 1 1 0 0 1 0 0 1];

% Other generator matrix examples
% R = 2, transfer function = [g0 = 7; g1 = 5]
% G = [1 1 1;1 0 1];

% R = 2, transfer function = [g0 = 561; g1 = 753]
% G = [1 0 1 1 1 0 0 0 1;1 1 1 1 0 1 0 1 1]

% K, shift register length
% R, code rate denominator (1/R)
[R, K] = size(G);

% Number of state
nrSt = 2^(K - 1);

% Create random binary data
dSource = round(rand(1, N));

% Convolutional encoder
codedBit = convEncoder(G, dSource);

% BPSK modulation
txSym = 2*codedBit - 1;

% AWGN of channel
rxSym = awgn(txSym, SNR);

% Codewords generation
[c0 c1] = codeWord(nrSt, G);

% Demultiplex the data
bitLen = length(rxSym)/R;
demulData = reshape(rxSym, R, bitLen);

% Soft viterbi decoding
decodedBit = convViterbi(demulData, c0, c1, K);

% Bit error
[num rat] = bitErrFast(dSource, decodedBit);

% Output processing
fprintf('Number of error: %d\n', num);
fprintf('Bit error ratio: %d\n', rat);

⌨️ 快捷键说明

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