-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZigzaging.m
33 lines (33 loc) · 947 Bytes
/
Zigzaging.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
function List = Zigzaging(Entropy, n)
List = cell(1, length(Entropy));
for k=1:length(Entropy)
String = zeros(1, n*n, 'double');
Index=1;
for i=1:n
for j=1:i
if mod(i, 2)==1
String(Index) = Entropy{k}(i+1-j, j);
else
String(Index) = Entropy{k}(j, i+1-j);
end
Index=Index+1;
end
end
for i=2:n
for j=i:n
if mod(n-i, 2)==1
String(Index) = Entropy{k}(j, n+i-j);
else
String(Index) = Entropy{k}(n+i-j, j);
end
Index=Index+1;
end
end
Index = find(String, 1, 'last');
if isempty(Index)
Index=0;
end
String(Index+1) = -1000;
List{k} = String(1:Index+1);
end
end