Skip to content

Commit 4e225bf

Browse files
committed
Indentation corrections
1 parent 7112147 commit 4e225bf

File tree

4 files changed

+69
-70
lines changed

4 files changed

+69
-70
lines changed

cdma.m

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
clc
1111

1212
%--------------------------------------------------------------------------
13-
%----------------- COMUMUNICATION OPTIONS ---------------------------------
13+
%----------------- COMMUNICATION OPTIONS ----------------------------------
1414
%--------------------------------------------------------------------------
1515

1616
%----------------- Quantization -------------------------------------------
@@ -87,7 +87,6 @@
8787

8888

8989
%------------------------- QUANTIZATION -----------------------------------
90-
9190
%Quantization
9291
[y_1, x2_1, errorcuantizacion_1] = cuantizar(x1,opcion,nivel);
9392
[y_2, x2_2, errorcuantizacion_2] = cuantizar(x2,opcion,nivel);
@@ -123,7 +122,6 @@
123122

124123

125124
%---------------------- REMAP MATRIX TO TRANSMIT --------------------------
126-
127125
%------------ USER 1
128126
%Transform
129127
x3=x2_1-1;
@@ -458,8 +456,6 @@
458456
break
459457
end
460458

461-
462-
463459
end
464460

465461
%p=mean(pe);

cuantizar.m

+47-46
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,58 @@
11
function [y, x2, errorcuantizacion] = cuantizar(x,opcion,nivel)
22

3-
% Levels of uniform quantization
4-
dif=(max(x)-min(x))/(nivel-1);
5-
val=[min(x):dif:max(x)];
6-
7-
% y = vector to plot levels of quantization
8-
y=kron(val',ones(1,size(x,1)));
9-
10-
11-
%------------ TYPES OF QUANTIZATION
12-
switch opcion
13-
case 1
14-
%------------ UNIFORM QUANTIZATION
15-
%No amplification
16-
xp=x;
17-
case 2
18-
%------------ MU LAW
19-
mu=255;
20-
xp=sign(x).*(log(1+mu*abs(x))/log(1 + mu));
21-
22-
case 3
23-
%------------ A LAW
24-
A=87.6;
25-
26-
for i=1:length(x)
27-
if abs(x(i))<(1/A)
28-
xp(i,1)=sign(x(i)).*((A*abs(x(i)))/(1+log(A)));
29-
else
30-
xp(i,1)=sign(x(i)).*((1+log(A*abs(x(i))))/(1+log(A)));
3+
% Levels of uniform quantization
4+
dif=(max(x)-min(x))/(nivel-1);
5+
val=[min(x):dif:max(x)];
6+
7+
% y = vector to plot levels of quantization
8+
y=kron(val',ones(1,size(x,1)));
9+
10+
11+
%------------ TYPES OF QUANTIZATION
12+
switch opcion
13+
case 1
14+
%------------ UNIFORM QUANTIZATION
15+
%No amplification
16+
xp=x;
17+
case 2
18+
%------------ MU LAW
19+
mu=255;
20+
xp=sign(x).*(log(1+mu*abs(x))/log(1 + mu));
21+
22+
case 3
23+
%------------ A LAW
24+
A=87.6;
25+
26+
for i=1:length(x)
27+
if abs(x(i))<(1/A)
28+
xp(i,1)=sign(x(i)).*((A*abs(x(i)))/(1+log(A)));
29+
else
30+
xp(i,1)=sign(x(i)).*((1+log(A*abs(x(i))))/(1+log(A)));
31+
end
3132
end
32-
end
3333

3434

35-
end
35+
end
3636

37-
% Value decision: it decides where the value corresponds to one level
38-
% according minimum distance
39-
ref=repmat(xp',nivel,1);
40-
x1=abs(y-ref);
41-
[distancia x2]=min(x1);
37+
% Value decision: it decides where the value corresponds to one level
38+
% according minimum distance
39+
ref=repmat(xp',nivel,1);
40+
x1=abs(y-ref);
41+
[distancia x2]=min(x1);
4242

43-
%------------ QUANTIZATION ERROR
43+
%------------ QUANTIZATION ERROR
4444

45-
%Signal normalization
46-
m=2/(nivel-1);
47-
b=(-nivel-1)/(nivel-1);
48-
xerror=m.*x2+b;
45+
%Signal normalization
46+
m=2/(nivel-1);
47+
b=(-nivel-1)/(nivel-1);
48+
xerror=m.*x2+b;
4949

50-
for i=1:size(xp,1)
51-
if xp(i)==0
52-
xp(i)=0.001;
50+
for i=1:size(xp,1)
51+
if xp(i)==0
52+
xp(i)=0.001;
53+
end
54+
er(i)=abs((xp(i)-xerror(i))/xp(i));
5355
end
54-
er(i)=abs((xp(i)-xerror(i))/xp(i));
55-
end
5656

57-
errorcuantizacion=mean(er);
57+
errorcuantizacion=mean(er);
58+
end

dec_bin.m

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
function bin_state = dec_bin( int_state, m )
2-
3-
% cambia matriz de decimal a binario
4-
5-
for j = 1:length( int_state )
6-
for i = m:-1:1
7-
state(j,m-i+1) = fix( int_state(j)/ (2^(i-1)) );
8-
int_state(j) = int_state(j) - state(j,m-i+1)*2^(i-1);
9-
end
10-
end
112

12-
bin_state = state;
3+
% cambia matriz de decimal a binario
4+
5+
for j = 1:length( int_state )
6+
for i = m:-1:1
7+
state(j,m-i+1) = fix( int_state(j)/ (2^(i-1)) );
8+
int_state(j) = int_state(j) - state(j,m-i+1)*2^(i-1);
9+
end
10+
end
1311

12+
bin_state = state;
13+
14+
end

int_state.m

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
function int_state = int_state( state )
2-
% Copyright 1996 Matthew C. Valenti
3-
% MPRG lab, Virginia Tech.
4-
% for academic use only
2+
% Copyright 1996 Matthew C. Valenti
3+
% MPRG lab, Virginia Tech.
4+
% for academic use only
55

6-
% converts a row vector of m bits into a integer (base 10)
6+
% converts a row vector of m bits into a integer (base 10)
77

8-
[dummy, m] = size( state );
8+
[dummy, m] = size( state );
99

10-
for i = 1:m
11-
vect(i) = 2^(m-i);
12-
end
10+
for i = 1:m
11+
vect(i) = 2^(m-i);
12+
end
1313

14-
int_state = state*vect';
14+
int_state = state*vect';
15+
end

0 commit comments

Comments
 (0)