-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviterbi_decoder_euclidean.m
More file actions
61 lines (43 loc) · 1.21 KB
/
Copy pathviterbi_decoder_euclidean.m
File metadata and controls
61 lines (43 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function [ ue ] = viterbi_decoder_euclidean( v, state_table, s, U, prob)
%VITERBI_DECODER Summary of this function goes here
% Detailed explanation goes here
%% matriz de custo e de posição
C = Inf(2^s, U +1);
P = zeros(2^s, U +1);
R = zeros(2^s, U +1);
C(1,1) = 0;
%%
for i = 1:U
partition = v((3*i-2):(3*i));
for j = 1:2^s
for k = [0 1]
next_j = next_state(k, j, s);
aux = C(j, i) + abs(euclidean_weight( partition, changez2o(de2bi(state_table(j ,1+k), 3, 'left-msb'))));
if C(next_j, i+1) > aux
C(next_j, i+1) = aux;
P(next_j, i+1) = j;
R(next_j, i+1) = k;
end
end
end
%C
%R
%P
end
%%
min = Inf;
min_j = 1;
for j = 1:2^s
if C(j, U +1) < min
min = C(j, U +1);
min_j = j;
end
end
ue = zeros(1, U);
if prob ~= 0.5
for i = (U+1):-1:2
ue(i-1) = R(min_j, i);
min_j = P(min_j, i);
end
end
end