Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MATLAB Code for simualting the spreading using Walsh Codes

656 views
Skip to first unread message

Anne

unread,
May 5, 2012, 12:34:28 PM5/5/12
to
A = [-1 -1 1 1]; %Spread waveform representation of user A's signal
B = [-1 1 -1 1]; %Spread waveform representation of user B's signal
C = [1 1 -1 -1]; %Spread waveform representation of user C's signal

% Generating the code and its timing sequence:

% to generate a 4 x 4 Hadamard matrix (which is the matrix of 1's and -1's
% and the columns are orthogonal):
N = 4;
H = hadamard(N);
% Picking full second row of Hadamard matrix:
cA = H(2,:);
% Picking full third row of Hadamard matrix:
cB = H(3,:);
% Picking full fourth row of Hadamard matrix:
cC = H(4,:);

% Number of samples per chip:
Tc_samp = ones(1,4);

% Initializing empty matrices:
codeA = [];
codeB = [];
codeC = [];

for k = 1 : length(cA)

codeA = [codeA cA(k)*Tc_samp];
codeB = [codeB cB(k)*Tc_samp];
codeC = [codeC cC(k)*Tc_samp];

end
codeA
% Generation of Tx Data:

Tx_data = [];

for k = 1 : length(A)

uA = A(k)*codeA;
uB = B(k)*codeB;
uC = C(k)*codeC;

Tx_data = [Tx_data uA+uB+uC];
end
Tx_data

NN = length(Tx_data)

uAb = [];
uBb = [];
uCb = [];

for k = 1 : NN / 16

index = (k - 1)*NN/4 + 1 : k*NN/4;
uAb = [uAb sum(Tx_data(index).*codeA)];
uBb = [uBb sum(Tx_data(index).*codeB)];
uCb = [uCb sum(Tx_data(index).*codeC)];

end
uAb
% Error:

res1 = A-uAb/16;
res2 = B-uBb/16;
res3 = C-uCb/16;

note:
please help me in understanding each statement of this code.
0 new messages