-
Notifications
You must be signed in to change notification settings - Fork 0
/
OVSFCode.m
166 lines (149 loc) · 4.01 KB
/
OVSFCode.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
clear all;
clc;
%--------------------------------------------------------------------------
c11 = [1];
aux = c11;
%Potencia de generacion de chip, 2^pott
%2^5 = 32 , maxima longitud de chip
pott = 5;
for i = 1:pott
[m,n] = size(aux);
% m
ix = 0;
%Para las filas de cada matriz
for xi = 1:m
cx = [aux(xi,:) , aux(xi,:);
aux(xi,:) , -aux(xi,:)];
if(ix == 0)
cy = cx;
ix = 1;
elseif(ix == 1)
cy = [cy;cx];
ix = 1;
end
end
% cy;
%Guardar matrices en su respectivo
aux = cy;
switch i
case 1
rmin16 = aux;
case 2
rmin8 = aux;
case 3
rmin4 = aux;
case 4
rmin2 = aux;
case 5
rmin = aux;
otherwise
rmin = 0;
end
end
%--------------------------------------------------------------------------
%
% rmin16 %c(2,1), c(2,2)
% rmin8 %c(4,1), c(4,2), c(4,3), c(4,4)
% rmin4 %c(8,1), c(8,2), c(8,3), c(8,4), c(8,5), c(8,6), c(8,7), c(8,8)...
% rmin2
% rmin
%Para generar cada usuario
%4 usuarios de tasa Rmin
rmin(29,:);
rmin(30,:);
rmin(31,:);
rmin(32,:);
%2 usuarios de tasa 2Rmin
rmin2(11,:);
rmin2(12,:);
%1 usuario de tasa 4Rmin
rmin4(4,:);
%X usuarios de tasa RminX
usuarios = [1 -1 -1 1]; %1 bits po cada uno (4 usuarios)
usuarios2= [1 1 -1 -1]; %2 bits por cada uno (2 usuarios)
usuarios4= [1 -1 1 1]; %4 bits por cada uno (1 usuario)
%Codigo * usuario
xc1 = rmin(29,:).*usuarios(1,1);
xc2 = rmin(30,:).*usuarios(1,2);
xc3 = rmin(31,:).*usuarios(1,3);
xc4 = rmin(32,:).*usuarios(1,4);
xc5x1 = rmin2(11,:).*usuarios2(1,1);
xc5x2 = rmin2(11,:).*usuarios2(1,2);
xc5x = [xc5x1 xc5x2];
xc5y1 = rmin2(12,:).*usuarios2(1,3);
xc5y2 = rmin2(12,:).*usuarios2(1,4);
xc5y = [xc5y1 xc5y2];
xc61 = rmin4(4,:).*usuarios4(1,1);
xc62 = rmin4(4,:).*usuarios4(1,2);
xc63 = rmin4(4,:).*usuarios4(1,3);
xc64 = rmin4(4,:).*usuarios4(1,4);
xc6 = [xc61 xc62 xc63 xc64];
%--------------------------------------------------------------------------
s1d = xc1 + xc2 + xc3 + xc4 + xc5x + xc5y + xc6;
[m tn] = size(s1d);
t = 0:tn-1;
%--------------------------------------------------------------------------
%Receptor, dedispersion. Multiplicar por codigo e integrar
des(1,:) = s1d(1,:) .* rmin(29,:);
des(2,:) = s1d(1,:) .* rmin(30,:);
des(3,:) = s1d(1,:) .* rmin(31,:);
des(4,:) = s1d(1,:) .* rmin(32,:);
s2b = zeros(1,32);
trans = zeros(1,32);
for i = 1:4 %filas
for ii = 1:32
s2b(i) = s2b(i) + des(i,ii);
end
if s2b(i) < 0
trans(i) = -1;
elseif s2b(i) > 0
trans(i) = 1;
end
end
des2(1,:) = s1d(1:16) .* rmin2(11,:);
des2(2,:) = s1d(17:32).* rmin2(11,:);
des2(3,:) = s1d(1:16) .* rmin2(12,:);
des2(4,:) = s1d(17:32).* rmin2(12,:);
s2b2x = zeros(1,16);
trans2x = zeros(1,16);
for i = 1:4 %filas
for ii = 1:16
s2b2x(i) = s2b2x(i) + des2(i,ii);
end
if s2b2x(i) < 0
trans2x(i) = -1;
elseif s2b2x(i) > 0
trans2x(i) = 1;
end
end
des4(1,:) = s1d(1:8) .* rmin4(4,:);
des4(2,:) = s1d(9:16) .* rmin4(4,:);
des4(3,:) = s1d(17:24).* rmin4(4,:);
des4(4,:) = s1d(25:32).* rmin4(4,:);
s2b4 = zeros(1,8);
trans4 = zeros(1,8);
for i = 1:4 %filas
for ii = 1:8
s2b4(i) = s2b4(i) + des4(i,ii);
end
if s2b4(i) < 0
trans4(i) = -1;
elseif s2b4(i) > 0
trans4(i) = 1;
end
end
%--------------------------------------------------------------------------
%Comparativa transmisor receptor
usuarios
trans
usuarios2
trans2x
usuarios4
trans4
%--------------------------------------------------------------------------
figure(1)
stem(t,s1d);
grid on;
xlabel('t');
ylabel('amplitud');
title('s(t), señal resultante');