-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbacktrack.m
39 lines (34 loc) · 950 Bytes
/
backtrack.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
function next = backtrack(sequence_bit1,sequence_bit2, n_path)
next = -10;
reverse_1 = flip(sequence_bit1);
reverse_2 = flip(sequence_bit2);
if n_path == 1
temp = reverse_1;
next = 0;
else
temp = reverse_2;
next = 1;
end
for i=1:length(reverse_1)
if i == 1
if n_path == 1 && temp(i) == 'd'
temp = reverse_2;
next = 1;
n_path = 2;
elseif n_path == 2 && temp(i) == 'u'
temp = reverse_1;
next = 0;
n_path = 1;
end
else
if n_path == 1 && temp(i) == 'd'
temp = reverse_2;
next = 1;
n_path = 2;
elseif n_path == 2 && temp(i) == 'u'
temp = reverse_1;
next = 0;
n_path = 1;
end
end
end