-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparamconv2.m
More file actions
41 lines (37 loc) · 1.16 KB
/
paramconv2.m
File metadata and controls
41 lines (37 loc) · 1.16 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
function [ T ] = paramconv2( g )
n=length(g); % Length of the code
for i=1:n
gtmp(i) = base2dec(int2str(g(i)),8); % from octal to decimal
end
G = fliplr(dec2bin(gtmp)-'0');
M = length(G(1,:))-1;
size = 2^M;
T = -1 * ones(size);
nb = length(g);
for i=1:2:size
m = [ 0 dec2bin(i-1,M) - '0'];
T(i, (i+1)/2) = 0;
for j=1:nb
k = mod(sum(m.*G(j,:)), 2);
T(i, (i+1)/2) = T(i, (i+1)/2) + k * 2^(nb-j);
end
m = [ 1 dec2bin(i-1,M) - '0'];
T(i, (size)/2 + (i+1)/2) = 0;
for j=1:nb
k = mod(sum(m.*G(j,:)), 2);
T(i, (size/2) +(i+1)/2) = T(i, (size/2) +(i+1)/2) + k * 2^(nb-j);
end
m = [ 0 dec2bin(i,M) - '0'];
T(i+1, (i+1)/2) = 0;
for j=1:nb
k = mod(sum(m.*G(j,:)), 2);
T(i+1, (i+1)/2) = T(i+1, (i+1)/2) + k * 2^(nb-j);
end
m = [ 1 dec2bin(i,M) - '0'];
T(i+1, (size)/2 + (i+1)/2) = 0;
for j=1:nb
k = mod(sum(m.*G(j,:)), 2);
T(i+1, (size/2) +(i+1)/2) = T(i+1, (size/2) +(i+1)/2) + k * 2^(nb-j);
end
end
end