-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEven.m
73 lines (47 loc) · 1.38 KB
/
Even.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
72
73
function [P_Matrix]=Even(k,Dimen)
Dim= size(Dimen);
for j=1:Dim(2)
for i=1:Dim(1)
X=dec2bin(i-1,log2(Dim(1)));
Y=dec2bin(j-1,log2(Dim(2)));
% step1
[IX]=inverse_bit(X);
[IY]=inverse_bit(Y);
if IY(k+1)=='1'
IX(k+1)=xorbin(IX(k+1),IY(k+1));
end
% step2
if IX(k+1)=='1'
for m=1:k
[IY(m),IX(m)]=Swp(IX(m),IY(m));
end
end
% step3
if IY(k+1)=='1' && IX(k+1)=='0'
for m=1:k
IY(m) = xorbin(IY(m),IY(k+1));
IX(m)= xorbin(IX(m),IY(k+1));
end
end
[X]=inverse_bit(IX);
[Y]=inverse_bit(IY);
%%%%%%%%%
w= bin2dec(Y)+1;
l= bin2dec(X)+1;
P_Matrix(w ,l)=Dimen(j ,i);
end
end
end
function [output]=inverse_bit(input)
m=length(input);
output=dec2bin(0,m);
for n=1 : m
output(n)= input(m);
m=m-1;
end
end
function [B,A]=Swp(A,B)
t=A;
A=B;
B=t;
end