-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathac_seq.m
71 lines (68 loc) · 1.47 KB
/
ac_seq.m
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
61
62
63
64
65
66
67
68
69
70
71
function Seq = ac_seq(I)
[s s1] = size(I);
Seq = [];
for j = 1:s
clear If;
clear cnt;
clear Int;
clear last;
count = 0;
z = 1;
for i = 2:64
if(I(j,i)==0)
count = count + 1;
last(z) = i;
z = z + 1;
else
count = 0;
z = 1;
end
end
If = I(j,:);
if(count>0)
%If(last(1)) = 10;
if(last(1)<=64)
If(last(1):64) = [];
end
end
Ig = If(:,2:end);
len = length(Ig);
k = 1;
while(k<=63)
if(k>len)
% Code 1:
Seq = [Seq '1'];
break;
else
% Code 0:
Seq = [Seq '0'];
V = Ig(k);
while(V==0)
% Code 0:
Seq = [Seq '0'];
k = k + 1;
V = Ig(k);
end
% Code 1:
Seq = [Seq '1'];
% Encode V:
if(V<0)
Seq = [Seq '1'];
else
Seq = [Seq '0'];
end
Sz = abs(V) - 1;
n = floor(log2(Sz));
for i = 1:n+1
Seq = [Seq '1'];
end
Seq = [Seq '0'];
if(n>0)
Szr = Sz - (2^n);
Seq = [Seq dec2bin(Szr,n)];
end
end
k = k + 1;
end
end
end