-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstbc_coding.m
111 lines (94 loc) · 3.75 KB
/
stbc_coding.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
function [data_coded] = stbc_coding(data, coding_mode)
len = length(data);
if strcmp(coding_mode, 'g2')
len = len * 1;
data_coded = zeros(len, 2);
for i = 1:2:len
data_coded(i, 1) = data(i);
data_coded(i, 2) = data(i+1);
data_coded(i+1, 1) = -conj(data(i+1));
data_coded(i+1, 2) = conj(data(i));
end
elseif strcmp(coding_mode, 'g3')
len = len * 2;
data_coded = zeros(len, 3);
for i = 1:8:len
k = (i-1)/2 + 1;
data_coded(i, 1) = data(k);
data_coded(i, 2) = data(k+1);
data_coded(i, 3) = data(k+2);
data_coded(i+1, 1) = -data(k+1);
data_coded(i+1, 2) = data(k);
data_coded(i+1, 3) = -data(k+3);
data_coded(i+2, 1) = -data(k+2);
data_coded(i+2, 2) = data(k+3);
data_coded(i+2, 3) = data(k);
data_coded(i+3, 1) = -data(k+3);
data_coded(i+3, 2) = -data(k+2);
data_coded(i+3, 3) = data(k+1);
data_coded(i+4:i+7, :) = conj(data_coded(i:i+3, :));
end
elseif strcmp(coding_mode, 'g4')
len = len*2;
data_coded = zeros(len, 4);
for i = 1:8:len
k = (i-1)/2 + 1;
data_coded(i, 1) = data(k);
data_coded(i, 2) = data(k+1);
data_coded(i, 3) = data(k+2);
data_coded(i, 4) = data(k+3);
data_coded(i+1, 1) = -data(k+1);
data_coded(i+1, 2) = data(k);
data_coded(i+1, 3) = -data(k+3);
data_coded(i+1, 4) = data(k+2);
data_coded(i+2, 1) = -data(k+2);
data_coded(i+2, 2) = data(k+3);
data_coded(i+2, 3) = data(k);
data_coded(i+2, 4) = -data(k+1);
data_coded(i+3, 1) = -data(k+3);
data_coded(i+3, 2) = -data(k+2);
data_coded(i+3, 3) = data(k+1);
data_coded(i+3, 4) = data(k);
data_coded(i+4:i+7, :) = conj(data_coded(i:i+3, :));
end
elseif strcmp(coding_mode, 'h3')
len = len*4/3;
data_coded = zeros(len, 4);
for i = 1:4:len
k = (i-1)*3/4 + 1;
data_coded(i, 1) = data(k);
data_coded(i, 2) = data(k+1);
data_coded(i, 3) = data(k+2)/sqrt(2);
data_coded(i+1, 1) = -conj(data(k+1));
data_coded(i+1, 2) = conj(data(k));
data_coded(i+1, 3) = data(k+2)/sqrt(2);
data_coded(i+2, 1) = conj(data(k+2))/sqrt(2);
data_coded(i+2, 2) = conj(data(k+2))/sqrt(2);
data_coded(i+2, 3) = (-data(k) - conj(data(k)) + data(k+1) - conj(data(k+1)))/2;
data_coded(i+3, 1) = conj(data(k+2))/sqrt(2);
data_coded(i+3, 2) = -conj(data(k+2))/sqrt(2);
data_coded(i+3, 3) = (data(k) - conj(data(k)) + data(k+1) + conj(data(k+1)))/2;
end
elseif strcmp(coding_mode, 'h4')
len = len*4/3;
data_coded = zeros(len, 4);
for i = 1:4:len
k = (i-1)*3/4 + 1;
data_coded(i, 1) = data(k);
data_coded(i, 2) = data(k+1);
data_coded(i, 3) = data(k+2)/sqrt(2);
data_coded(i, 4) = data(k+2)/sqrt(2);
data_coded(i+1, 1) = -conj(data(k+1));
data_coded(i+1, 2) = conj(data(k));
data_coded(i+1, 3) = data(k+2)/sqrt(2);
data_coded(i+1, 4) = -data(k+2)/sqrt(2);
data_coded(i+2, 1) = conj(data(k+2))/sqrt(2);
data_coded(i+2, 2) = conj(data(k+2))/sqrt(2);
data_coded(i+2, 3) = (-data(k) - conj(data(k)) + data(k+1) - conj(data(k+1)))/2;
data_coded(i+2, 4) = (data(k) - conj(data(k)) - data(k+1) - conj(data(k+1)))/2;
data_coded(i+3, 1) = conj(data(k+2))/sqrt(2);
data_coded(i+3, 2) = -conj(data(k+2))/sqrt(2);
data_coded(i+3, 3) = (data(k) - conj(data(k)) + data(k+1) + conj(data(k+1)))/2;
data_coded(i+3, 4) = (-data(k) - conj(data(k)) - data(k+1) + conj(data(k+1)))/2;
end
end