# RF Wireless World

## Home of RF and Wireless Vendors and Resources

One Stop For Your RF and Wireless Need

## Viterbi decoder MATLAB source code

This section of MATLAB source code covers viterbi decoder matlab code including viterbi decoder specifications for convolutional encoder of constraint length 5. It mentions code snippet and steps to develop Viterbi decoder matlab code.

### Specifications of convolutional encoder

Convolution Encoder (3, 1, 4) specifications
Coding rate: 1/3
Constraint length: 5
Output bit length: 3
Message bit length: 1
Maximal memory order / no. of memory elements = 4
Generator Polynomials: 25 (8), 33 (8), 37 (8)

### Specifications of viterbi decoder

codeword length: 20
coding rate: 1/3
constraint length: 5
trace back length: 20
quantization levels: two (Hard decision type)
generator Polynomials: 25 (8), 33 (8), 37 (8)

This viterbi is designed for the above convolutional encoder specifications. Refer convolution encoder basics and Convolutional Encoder matlab code.

#### Viterbi decoder MATLAB Code STEPS

STEP-1:Concatenate three consecutive bits of received encoded sequence to
%Make up a symbol.

STEP-2: Transition Table For Trace Back.

STEP-3:find the length of input and LOOP FOR NUMBER OF TIME UNITS.

STEP-4:CHECKING FOR REDUNDANT STATES

### Viterbi decoder MATLAB Code

Following is the part of the viterbi decoder matlab code.

function [dec_op]=viterbi_decoder(rcvd)
%Concatenate three consecutive bits of received encoded sequence to
%Make up a symbol
input=[];
for j=1:3:length(rcvd)
input=[ input (rcvd(j)* 2^2) + (rcvd(j+1) * 2^1) + (rcvd(j+2) * 2^0)];
end

%%Initialize Ouput Table
Output_Table = [ ...
0 0 7; ...
1 7 0; ...
2 3 4; ...
3 4 3; ...
4 5 2; ...
5 2 5; ...
6 6 1; ...
7 1 6; ...
7 3 4; ...
8 4 3; ...
9 0 7; ...
10 7 0; ...
11 6 1; ...
12 1 6; ...
13 5 2; ...
14 2 5];

%%Initialize Next-State(Ouput State) Table
Next_State =[ ...
0 0 8; ...
1 0 8; ...
2 1 9; ...
3 1 9; ...
4 2 10; ...
5 2 10; ...
6 3 11; ...
7 3 11; ...
8 4 12; ...
9 4 12; ...
10 5 13; ...
11 5 13; ...
12 6 14; ...
13 6 14; ...
14 7 15; ...
15 7 15];

%%%%%%%%%%%%%%%%%%%
%T R A C E - B A C K
%%%%%%%%%%%%%%%%%%%
slm = min(aem(:, 21));
slm_loc =find( aem(:, 21)==slm );
sseq(21) = (slm_loc(1)-1);

for t=20:-1:1
sseq(t) = State_Hist(sseq(t+1) + 1,t+1);
end

dec_op=[];
for k =1 : 20
dec_op(k) = Transition_Table(sseq(k)+1, sseq(k+1)+1);
end