CDMA System Design: Evaluating Walsh & Gold Codes & MIMO Transceiver
VerifiedAdded on 2023/06/14
|24
|4584
|120
Project
AI Summary
This project provides a detailed solution for a CDMA system design, focusing on the implementation and performance analysis of Walsh codes, Gold codes, and a single-user MIMO transceiver. The project includes MATLAB code for simulating a 30-user CDMA system with spreading gains of 64 (Walsh code) and 31 (Gold code), as well as code for evaluating the performance of a single-user MIMO transceiver without forward error correction. Various aspects of CDMA design techniques are explored through questions and MATLAB simulations, covering topics such as signal generation, spreading, despreading, and BER (Bit Error Rate) analysis under different SNR (Signal-to-Noise Ratio) conditions. Performance comparisons of CDMA systems using different diversity techniques are also presented. The project concludes with an emphasis on the effects that strongly influence the performance of CDMA systems.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.

TELECOMMUNICATION
Code Division Multiple Access
Name:
Professor:
Date:
Code Division Multiple Access
Name:
Professor:
Date:
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

Abstract
In wireless channel system, a single antenna is used at the source, and another single
antenna is used at the destination. This leads to hitches with multipath effects [1]. When an
electromagnetic field meets a barrier such as mountains, valleys, structures, and service wires,
the signals are dispersed, and thus take different routes to reach the receiver. Scattering of the
signal leads to hitches such as cut-out, fading and intermittent reception. In digital channel
systems such as wireless Internet, it can lead to a reduced signal speed and a rise in the number
of errors [2]–[7]. Adoption of more than one antennas, with the broadcast of compound signals
at the source and the destination, eradicates the distress instigated by multipath wave broadcast.
Introduction
A various access structure based on spread-spectrum transmission technique is referred to
as code division multiple access CDMA. In this system, the information signal is to a wide
extent spread to a wide bandwidth by an exceptional code which aids in minimization of
intrusion hence increasing systems processing speed [8]. In design assignment we are required
to design a simple a simple 30 user CDMA system with spreading Walsh code gain of 64 and
31-gold code. In the second part we are required to design a single-user MIMO transceiver
without forward error correction code and evaluate its performance. Multiple input Multiple
output systems also known as MIMO is where multiple antennas at both ends of the link helps
exploit other advantages other than diversity and array gains [11]. MIMO facilitate the ability to
increase the transmission of throughput through spatial multiplexing capability of MIMO
channels. Question 2 through to 6 are designs to achieve high channel capability of CDMA and
their analysis. These designs help us understand more on various CDMA design techniques.
Question 1
Matlab code:
In wireless channel system, a single antenna is used at the source, and another single
antenna is used at the destination. This leads to hitches with multipath effects [1]. When an
electromagnetic field meets a barrier such as mountains, valleys, structures, and service wires,
the signals are dispersed, and thus take different routes to reach the receiver. Scattering of the
signal leads to hitches such as cut-out, fading and intermittent reception. In digital channel
systems such as wireless Internet, it can lead to a reduced signal speed and a rise in the number
of errors [2]–[7]. Adoption of more than one antennas, with the broadcast of compound signals
at the source and the destination, eradicates the distress instigated by multipath wave broadcast.
Introduction
A various access structure based on spread-spectrum transmission technique is referred to
as code division multiple access CDMA. In this system, the information signal is to a wide
extent spread to a wide bandwidth by an exceptional code which aids in minimization of
intrusion hence increasing systems processing speed [8]. In design assignment we are required
to design a simple a simple 30 user CDMA system with spreading Walsh code gain of 64 and
31-gold code. In the second part we are required to design a single-user MIMO transceiver
without forward error correction code and evaluate its performance. Multiple input Multiple
output systems also known as MIMO is where multiple antennas at both ends of the link helps
exploit other advantages other than diversity and array gains [11]. MIMO facilitate the ability to
increase the transmission of throughput through spatial multiplexing capability of MIMO
channels. Question 2 through to 6 are designs to achieve high channel capability of CDMA and
their analysis. These designs help us understand more on various CDMA design techniques.
Question 1
Matlab code:

%% Clearing and closing any open files.
clear all
close all
clc
%% Generation of data for each user
N=30;
gain_1=31;
gain_2=64;
data_set=[];
for p=1:N
s=rand(1,10);
r=[];
for t=1:10
if s(t)>0.5
r=[r 1];
else if s(t)<0.5
r=[r 0];
end
end
end
data_set(p,:)=r;
end
data_set=2*data_set-1;
%% CDMA using Walsh code
walsh=hadamard(gain_2);
signal_1=[];
for p=1:N
a=walsh(p,:);
q=[];
for r=1:10
s=data_set(1,r)*a;
q=[q s];
end
signal_1=[signal_1;q];
end
% combining the signal from each user
combined_1=[];
for t=1:29
combined_1=signal_1(t,:)+signal_1(t+1,:);
end
%% Generating Gold code
G=31; % Code length
K=10; % Number of Codes or code sequences
%.................Generation of first perferred PN
sequence................
sd1 =randsrc(1,5,[0 1]); % First user's seed.
PN1=[]; % Spreading code vector of user-1
clear all
close all
clc
%% Generation of data for each user
N=30;
gain_1=31;
gain_2=64;
data_set=[];
for p=1:N
s=rand(1,10);
r=[];
for t=1:10
if s(t)>0.5
r=[r 1];
else if s(t)<0.5
r=[r 0];
end
end
end
data_set(p,:)=r;
end
data_set=2*data_set-1;
%% CDMA using Walsh code
walsh=hadamard(gain_2);
signal_1=[];
for p=1:N
a=walsh(p,:);
q=[];
for r=1:10
s=data_set(1,r)*a;
q=[q s];
end
signal_1=[signal_1;q];
end
% combining the signal from each user
combined_1=[];
for t=1:29
combined_1=signal_1(t,:)+signal_1(t+1,:);
end
%% Generating Gold code
G=31; % Code length
K=10; % Number of Codes or code sequences
%.................Generation of first perferred PN
sequence................
sd1 =randsrc(1,5,[0 1]); % First user's seed.
PN1=[]; % Spreading code vector of user-1

for j=1:G
PN1=[PN1 sd1(1)];
if sd1(1)==sd1(4)
temp1=0;
else temp1=1;
end
sd1(1)=sd1(2);
sd1(2)=sd1(3);
sd1(3)=sd1(4);
sd1(4)=sd1(5);
sd1(5)=temp1;
end
%.................Generation of Second perferred PN
sequence...............
sd2 =randsrc(1,5,[0 1]);
PN2=[];
for j=1:G
PN2=[PN2 sd2(1)];
if sd2(1)==sd2(2)
temp1=0;
else temp1=1;
end
if sd2(4)==temp1
temp2=0;
else temp2=1;
end
if sd2(5)==temp2
temp3=0;
else temp3=1;
end
sd2(1)=sd2(2);
sd2(2)=sd2(3);
sd2(3)=sd2(4);
sd2(4)=sd2(5);
sd2(5)=temp3;
end
%.........................Generation of Gold
Codes.........................
Co_Mat=[];
for codes=1:K
code=[];
PN2(31)=PN2(1);
for k=1:G-1
PN2(k)=PN2(k+1);
end
for j=1:G
code=[code xor(PN1(j),PN2(j))];
PN1=[PN1 sd1(1)];
if sd1(1)==sd1(4)
temp1=0;
else temp1=1;
end
sd1(1)=sd1(2);
sd1(2)=sd1(3);
sd1(3)=sd1(4);
sd1(4)=sd1(5);
sd1(5)=temp1;
end
%.................Generation of Second perferred PN
sequence...............
sd2 =randsrc(1,5,[0 1]);
PN2=[];
for j=1:G
PN2=[PN2 sd2(1)];
if sd2(1)==sd2(2)
temp1=0;
else temp1=1;
end
if sd2(4)==temp1
temp2=0;
else temp2=1;
end
if sd2(5)==temp2
temp3=0;
else temp3=1;
end
sd2(1)=sd2(2);
sd2(2)=sd2(3);
sd2(3)=sd2(4);
sd2(4)=sd2(5);
sd2(5)=temp3;
end
%.........................Generation of Gold
Codes.........................
Co_Mat=[];
for codes=1:K
code=[];
PN2(31)=PN2(1);
for k=1:G-1
PN2(k)=PN2(k+1);
end
for j=1:G
code=[code xor(PN1(j),PN2(j))];
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

end
Co_Mat=[Co_Mat code'];
end
for row=1:G
for col=1:K
if Co_Mat(row,col)==0
Co_Mat(row,col)=-1;
end
end
end
% combining with the data signa
signal_2=[];
for x=1:N
b=Co_Mat(x,:);
y=[];
for v=1:10
l=data_set(1,v)*b;
y=[y l];
end
signal_2=[signal_2;y];
end
% combining the signal from each user
combined_2=[];
for z=1:29
combined_2=signal_2(z,:)+signal_2(z+1,:);
end
%% plotting
figure;
for u=1:3
subplot(4,1,u)
bar(signal_1(u,1:200))
if u==1
title('Signal for user 1 walsh code')
else if u==2
title('Signal for user 2 wash code')
else if u==3
title('Signal for user 3 walsh code')
end
end
end
end
figure;
for o=1:3
subplot(4,1,o)
bar(signal_2(o,1:31))
if o==1
Co_Mat=[Co_Mat code'];
end
for row=1:G
for col=1:K
if Co_Mat(row,col)==0
Co_Mat(row,col)=-1;
end
end
end
% combining with the data signa
signal_2=[];
for x=1:N
b=Co_Mat(x,:);
y=[];
for v=1:10
l=data_set(1,v)*b;
y=[y l];
end
signal_2=[signal_2;y];
end
% combining the signal from each user
combined_2=[];
for z=1:29
combined_2=signal_2(z,:)+signal_2(z+1,:);
end
%% plotting
figure;
for u=1:3
subplot(4,1,u)
bar(signal_1(u,1:200))
if u==1
title('Signal for user 1 walsh code')
else if u==2
title('Signal for user 2 wash code')
else if u==3
title('Signal for user 3 walsh code')
end
end
end
end
figure;
for o=1:3
subplot(4,1,o)
bar(signal_2(o,1:31))
if o==1

title('Signal for user 1 Gold code')
else if o==2
title('Signal for user 2 Gold code')
else if o==3
title('Signal for user 3 Gold code')
end
end
end
end
subplot(4,1,4)
bar(combined_1)
title('Combined signal')
Results:
else if o==2
title('Signal for user 2 Gold code')
else if o==3
title('Signal for user 3 Gold code')
end
end
end
end
subplot(4,1,4)
bar(combined_1)
title('Combined signal')
Results:

Signal for user 1 walsh code
0 50 100 150 200 250
-1
0
1
Signal for user 2 wash code
0 50 100 150 200 250
-1
0
1
Signal for user 3 walsh code
0 50 100 150 200 250
-1
0
1
Signal for user 1 Gold code
0 5 10 15 20 25 30 35
-1
0
1
Signal for user 2 Gold code
0 5 10 15 20 25 30 35
-1
0
1
Signal for user 3 Gold code
0 5 10 15 20 25 30 35
-1
0
1
Combined signal
0 100 200 300 400 500 600 700
-2
0
2
Question 2
0 50 100 150 200 250
-1
0
1
Signal for user 2 wash code
0 50 100 150 200 250
-1
0
1
Signal for user 3 walsh code
0 50 100 150 200 250
-1
0
1
Signal for user 1 Gold code
0 5 10 15 20 25 30 35
-1
0
1
Signal for user 2 Gold code
0 5 10 15 20 25 30 35
-1
0
1
Signal for user 3 Gold code
0 5 10 15 20 25 30 35
-1
0
1
Combined signal
0 100 200 300 400 500 600 700
-2
0
2
Question 2
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Matlab code:
clc;
clear all;
close all;
d=[];
o=1000;
Data=((randi(1,o))>.5)+0;
p=16;
walsh=hadamard(p);
% orthogoanl code matrix
Walsh_code= walsh(3,:)+1
u=1;
l=length(Walsh_code);
for s=1:o
for t=1:l
d(1,u)=xor(Data(1,s),Walsh_code(1,t));
u=u+1;
end
end
figure
v=10;
a = rectpulse(Data(1,:),10);
subplot(3,1,1);
stem(a);
title('\bf Original_Bit_Sequence');
title('\bf TRANSMITTED_MESSAGE');
b = rectpulse(Walsh_code(1,:),10);
subplot(3,1,2);
stem(b);
title('\bf Gold_Code');
%.........................
e = rectpulse(d(1,:),10);
subplot(3,1,3);
stem(e);
title('\bf Spreaded_Sequence')
%-------Demodulation to get original message signal---------
c=1;
u=1;
los= length(d);
while u < los
s=0;
for t=1:l
temp(1,t) = xor(d(1,u),Walsh_code(1,t));
u=u+1;
s=s+temp(1,t);
end
if(s==0)
clc;
clear all;
close all;
d=[];
o=1000;
Data=((randi(1,o))>.5)+0;
p=16;
walsh=hadamard(p);
% orthogoanl code matrix
Walsh_code= walsh(3,:)+1
u=1;
l=length(Walsh_code);
for s=1:o
for t=1:l
d(1,u)=xor(Data(1,s),Walsh_code(1,t));
u=u+1;
end
end
figure
v=10;
a = rectpulse(Data(1,:),10);
subplot(3,1,1);
stem(a);
title('\bf Original_Bit_Sequence');
title('\bf TRANSMITTED_MESSAGE');
b = rectpulse(Walsh_code(1,:),10);
subplot(3,1,2);
stem(b);
title('\bf Gold_Code');
%.........................
e = rectpulse(d(1,:),10);
subplot(3,1,3);
stem(e);
title('\bf Spreaded_Sequence')
%-------Demodulation to get original message signal---------
c=1;
u=1;
los= length(d);
while u < los
s=0;
for t=1:l
temp(1,t) = xor(d(1,u),Walsh_code(1,t));
u=u+1;
s=s+temp(1,t);
end
if(s==0)

w(1,c) = 0;
else
w(1,c) = 1;
end
c=c+1;
end
despreaded_signal= w;
%-----Plotting-----
figure
x=[];
for u=1:8
if w(1,u)==0
z=zeros(1,10);
else
z=ones(1,10);
end
x=[x z]
end
subplot(3,1,1);
stem(e);
title(' sequence');
title(' Rx MESSAGE');
b = rectpulse(Walsh_code(1,:),10);
subplot(3,1,2);
stem(b);
title(' Gold Code');
subplot(3,1,3);
stem(x);
title('\bf Despreaded_Sequence')
Results:
else
w(1,c) = 1;
end
c=c+1;
end
despreaded_signal= w;
%-----Plotting-----
figure
x=[];
for u=1:8
if w(1,u)==0
z=zeros(1,10);
else
z=ones(1,10);
end
x=[x z]
end
subplot(3,1,1);
stem(e);
title(' sequence');
title(' Rx MESSAGE');
b = rectpulse(Walsh_code(1,:),10);
subplot(3,1,2);
stem(b);
title(' Gold Code');
subplot(3,1,3);
stem(x);
title('\bf Despreaded_Sequence')
Results:

Question 3
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

Matlab codes:
clc ;
clear all ;
close all;
L = randn(1,4*100000) ;
V=1;
M=[];
for o = 1:4
for Z = 1:100000
if ( L(V)>=0)
M(o,Z)=1 ;
else
D1(o,j)=?1 ;
end
V = V+1 ;
end
end
for o = 1:4
Z=1;
for W = 1:50000
D(o,W)=M(o,Z)+(M(o,Z+1))*i;
Z=Z+2;
end
end
C=[?1 ?1 ?1 ?1;
?1 1 ?1 1;
?1 ?1 1 1;
?1 1 1 ?1];
T = length(C);
I = size(D);
L = I(1);
I = I(2);
T = [];
G = zeros(I,M);
for n = 1:L
Z = zeros(I,M);
for o = 1:I
for m = 1:M
Z(o,m) = [D(n,o)*C(n,m)];
end
end
G = G + Z;
end
for o=1:I
G1(o,:)=ifft(G(o,:));
end
for snr=1:20
clc ;
clear all ;
close all;
L = randn(1,4*100000) ;
V=1;
M=[];
for o = 1:4
for Z = 1:100000
if ( L(V)>=0)
M(o,Z)=1 ;
else
D1(o,j)=?1 ;
end
V = V+1 ;
end
end
for o = 1:4
Z=1;
for W = 1:50000
D(o,W)=M(o,Z)+(M(o,Z+1))*i;
Z=Z+2;
end
end
C=[?1 ?1 ?1 ?1;
?1 1 ?1 1;
?1 ?1 1 1;
?1 1 1 ?1];
T = length(C);
I = size(D);
L = I(1);
I = I(2);
T = [];
G = zeros(I,M);
for n = 1:L
Z = zeros(I,M);
for o = 1:I
for m = 1:M
Z(o,m) = [D(n,o)*C(n,m)];
end
end
G = G + Z;
end
for o=1:I
G1(o,:)=ifft(G(o,:));
end
for snr=1:20

for o=1:I
G2(o,:)=awgn(G1(o,:),snr,0);
end
for o=1:I
G3(o,:)=fft(G2(o,:));
end
B1 = [];
for n = 1:L
TOT = zeros(1,I);
R = zeros(I,M);
for o = 1:I
for m = 1:M
R(o,m) = G3(o,m) * C (n,m);
TOT(o) = TOT(o) + R (o,m);
end
end
B1 = [B1 ; TOT / M];
end
B1;
B2=zeros(M,I);
for v = 1:M
for Z = 1:I
p= real(B1(v,Z));
if (p>=0)
B2(v,Z)=1 ;
else
B2(v,j)=?1 ;
end
end
end
B3=zeros(M,I);
for o = 1:M
for Z = 1:I
p= imag(B1(o,Z));
if (p>=0)
B3(o,Z)=1 ;
else
B3(o,j)=?1 ;
end
end
end
B4=B2+(B3*i);
err = D?B4 ;
no_errs=0;
for o=1:M
for Z=1:I
if(err(o,Z)~=0)
G2(o,:)=awgn(G1(o,:),snr,0);
end
for o=1:I
G3(o,:)=fft(G2(o,:));
end
B1 = [];
for n = 1:L
TOT = zeros(1,I);
R = zeros(I,M);
for o = 1:I
for m = 1:M
R(o,m) = G3(o,m) * C (n,m);
TOT(o) = TOT(o) + R (o,m);
end
end
B1 = [B1 ; TOT / M];
end
B1;
B2=zeros(M,I);
for v = 1:M
for Z = 1:I
p= real(B1(v,Z));
if (p>=0)
B2(v,Z)=1 ;
else
B2(v,j)=?1 ;
end
end
end
B3=zeros(M,I);
for o = 1:M
for Z = 1:I
p= imag(B1(o,Z));
if (p>=0)
B3(o,Z)=1 ;
else
B3(o,j)=?1 ;
end
end
end
B4=B2+(B3*i);
err = D?B4 ;
no_errs=0;
for o=1:M
for Z=1:I
if(err(o,Z)~=0)

no_errs=no_errs+1;
end
end
end
ber(snr)=no_errs/(I*M);
end
ber
snr=1:20
plot(snr,ber)
Results:
Question 4
Matlab code:
%% clearing both workspace and command window
clear all;
clc
close all
BER=[];
SNR=-10:2:6;
EbNo=10.^(SNR./10);
for Eb=EbNo;
end
end
end
ber(snr)=no_errs/(I*M);
end
ber
snr=1:20
plot(snr,ber)
Results:
Question 4
Matlab code:
%% clearing both workspace and command window
clear all;
clc
close all
BER=[];
SNR=-10:2:6;
EbNo=10.^(SNR./10);
for Eb=EbNo;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

BER=[BER ber(Eb)];
end
no=0.5*erfc(10.^(SNR/10));
figure;
plot(SNR,BER,'r',SNR,no,'b')
hold on;
legend('with forward error correction','without forward error
correction')
title('Performance of a multiuser MIMO')
xlabel('SNR--->')
ylabel('BER---->')
grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function to determine BER
function result=ber(Eb)
%%step 1
%Generating information bit
N=10.^4;
b=rand(1,N);
%generating 1 and 0 bits
a_k=[];
for i=1:N
if b(i)>0.5
a_k=[a_k 1];
else if b(i)<0.5
a_k=[a_k 0];
end
end
end
%converting 1 and 0 to 1 and -1 respectively
a_k_eq=2*a_k-1;
%generating information bits in terms of Eb
if Eb<=0
x_k=a_k_eq*-1*sqrt(-1*Eb);
else if Eb>0;
x_k=a_k_eq*sqrt(Eb);
end
end
%Generating noise sample n1k,nQk according to Gaussian
distribution
%n_k=n1k+j*nQk
delta=1;
n_k=sqrt(delta./2).*(randn(1,N)+sqrt(-1)*randn(1,N));
%Generating the received signal for each SNR condition
%i.e r(r)=x(k)+n(k)
r_k=x_k+n_k;
%performing detection
end
no=0.5*erfc(10.^(SNR/10));
figure;
plot(SNR,BER,'r',SNR,no,'b')
hold on;
legend('with forward error correction','without forward error
correction')
title('Performance of a multiuser MIMO')
xlabel('SNR--->')
ylabel('BER---->')
grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function to determine BER
function result=ber(Eb)
%%step 1
%Generating information bit
N=10.^4;
b=rand(1,N);
%generating 1 and 0 bits
a_k=[];
for i=1:N
if b(i)>0.5
a_k=[a_k 1];
else if b(i)<0.5
a_k=[a_k 0];
end
end
end
%converting 1 and 0 to 1 and -1 respectively
a_k_eq=2*a_k-1;
%generating information bits in terms of Eb
if Eb<=0
x_k=a_k_eq*-1*sqrt(-1*Eb);
else if Eb>0;
x_k=a_k_eq*sqrt(Eb);
end
end
%Generating noise sample n1k,nQk according to Gaussian
distribution
%n_k=n1k+j*nQk
delta=1;
n_k=sqrt(delta./2).*(randn(1,N)+sqrt(-1)*randn(1,N));
%Generating the received signal for each SNR condition
%i.e r(r)=x(k)+n(k)
r_k=x_k+n_k;
%performing detection

dem=[];
for t=1:N
if real(r_k(t))>0
dem=[dem 1];
else if real(r_k(t))<=0
dem=[dem 0];
end
end
end
%determining correct and errored bits
correct=[];
error=[];
for u=1:N;
if dem(u)~=a_k(u)
error=[error 0];
else if dem(u)~=a_k(u)
correct=[correct 1];
end
end
end
%% step 2
%counting the total number errors occured
d=length(error);
%% step 3
%determining BER
result=d./N;
end
Results:
for t=1:N
if real(r_k(t))>0
dem=[dem 1];
else if real(r_k(t))<=0
dem=[dem 0];
end
end
end
%determining correct and errored bits
correct=[];
error=[];
for u=1:N;
if dem(u)~=a_k(u)
error=[error 0];
else if dem(u)~=a_k(u)
correct=[correct 1];
end
end
end
%% step 2
%counting the total number errors occured
d=length(error);
%% step 3
%determining BER
result=d./N;
end
Results:

-10 -8 -6 -4 -2 0 2 4 6
SNR--->
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
BER---->
Performance of a multiuser MIMO
with forward error correction
without forward error correction
Question 5
Matlab code:
%% clearing both workspace and command window
clear all;
clc
close all
%% Task 2.1
% Evaluating BER performance of BPSK over AWGN channel
BER=[];
SNR=-10:2:6;
EbNo=10.^(SNR./10);
for Eb=EbNo;
task=1;
BER=[BER ber(Eb,1)];
end
no=0.5*erfc(10.^(SNR/10));
BER1=[];
SNR=-10:2:6;
EbNo=10.^(SNR./10);
for Eb=EbNo;
BER1=[BER1 ber(Eb,2)];
end
SNR--->
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
BER---->
Performance of a multiuser MIMO
with forward error correction
without forward error correction
Question 5
Matlab code:
%% clearing both workspace and command window
clear all;
clc
close all
%% Task 2.1
% Evaluating BER performance of BPSK over AWGN channel
BER=[];
SNR=-10:2:6;
EbNo=10.^(SNR./10);
for Eb=EbNo;
task=1;
BER=[BER ber(Eb,1)];
end
no=0.5*erfc(10.^(SNR/10));
BER1=[];
SNR=-10:2:6;
EbNo=10.^(SNR./10);
for Eb=EbNo;
BER1=[BER1 ber(Eb,2)];
end
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

figure;
plot(SNR,BER,'r',SNR,no,'b',SNR,BER1,'g')
legend('Matched filter','Decorrelator','MMSE')
title('BER analysis')
xlabel('SNR--->')
ylabel('BER---->')
grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function to determine BER
function result=ber(Eb,task)
%%step 1
%Generating information bit
N=10.^4;
b=rand(1,N);
%generating 1 and 0 bits
a_k=[];
for i=1:N
if b(i)>0.5
a_k=[a_k 1];
else if b(i)<0.5
a_k=[a_k 0];
end
end
end
%converting 1 and 0 to 1 and -1 respectively
a_k_eq=2*a_k-1;
%generating information bits in terms of Eb
if Eb<=0
x_k=a_k_eq*-1*sqrt(-1*Eb);
else if Eb>0;
x_k=a_k_eq*sqrt(Eb);
end
end
%Generating noise sample n1k,nQk according to Gaussian
distribution
%n_k=n1k+j*nQk
delta=1;
n_k=sqrt(delta./2).*(randn(1,N)+sqrt(-1)*randn(1,N));
%Generating flat fading channel
h_k=randn(1,N)+sqrt(-1)*randn(1,N);
%Generating the received signal for each SNR condition
%i.e r(r)=x(k)+n(k)
if task==1
r_k=x_k+n_k;
else if task==2;
d_k=x_k.*h_k+n_k;
r_k=d_k.*conj(h_k);
plot(SNR,BER,'r',SNR,no,'b',SNR,BER1,'g')
legend('Matched filter','Decorrelator','MMSE')
title('BER analysis')
xlabel('SNR--->')
ylabel('BER---->')
grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function to determine BER
function result=ber(Eb,task)
%%step 1
%Generating information bit
N=10.^4;
b=rand(1,N);
%generating 1 and 0 bits
a_k=[];
for i=1:N
if b(i)>0.5
a_k=[a_k 1];
else if b(i)<0.5
a_k=[a_k 0];
end
end
end
%converting 1 and 0 to 1 and -1 respectively
a_k_eq=2*a_k-1;
%generating information bits in terms of Eb
if Eb<=0
x_k=a_k_eq*-1*sqrt(-1*Eb);
else if Eb>0;
x_k=a_k_eq*sqrt(Eb);
end
end
%Generating noise sample n1k,nQk according to Gaussian
distribution
%n_k=n1k+j*nQk
delta=1;
n_k=sqrt(delta./2).*(randn(1,N)+sqrt(-1)*randn(1,N));
%Generating flat fading channel
h_k=randn(1,N)+sqrt(-1)*randn(1,N);
%Generating the received signal for each SNR condition
%i.e r(r)=x(k)+n(k)
if task==1
r_k=x_k+n_k;
else if task==2;
d_k=x_k.*h_k+n_k;
r_k=d_k.*conj(h_k);

end
end
%performing detection
dem=[];
for t=1:N
if real(r_k(t))>0
dem=[dem 1];
else if real(r_k(t))<=0
dem=[dem 0];
end
end
end
%determining correct and errored bits
correct=[];
error=[];
for u=1:N;
if dem(u)~=a_k(u)
error=[error 0];
else if dem(u)~=a_k(u)
correct=[correct 1];
end
end
end
%% step 2
%counting the total number errors occured
d=length(error);
%% step 3
%determining BER
result=d./N;
end
Results:
end
%performing detection
dem=[];
for t=1:N
if real(r_k(t))>0
dem=[dem 1];
else if real(r_k(t))<=0
dem=[dem 0];
end
end
end
%determining correct and errored bits
correct=[];
error=[];
for u=1:N;
if dem(u)~=a_k(u)
error=[error 0];
else if dem(u)~=a_k(u)
correct=[correct 1];
end
end
end
%% step 2
%counting the total number errors occured
d=length(error);
%% step 3
%determining BER
result=d./N;
end
Results:

-10 -8 -6 -4 -2 0 2 4 6
SNR--->
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
BER---->
BER analysis
Matched filter
Decorrelator
MMSE
Question 6
Matlab code:
clear all
clc
close all
N = 10^6; % number of bits or symbols
Eb_N0_dB = [0:25]; % multiple Eb/N0 values
nRx = 2;
for ii = 1:length(Eb_N0_dB)
% Transmitter
ip = rand(1,N)>0.5;
s = 2*ip-1;
sCode = 1/sqrt(2)*kron(reshape(s,2,N/2),ones(1,2)) ;
% channel
h = 1/sqrt(2)*[randn(nRx,N) + j*randn(nRx,N)];
n = 1/sqrt(2)*[randn(nRx,N) + j*randn(nRx,N)];
y = zeros(nRx,N);
yMod = zeros(nRx*2,N);
hMod = zeros(nRx*2,N);
for kk = 1:nRx
SNR--->
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
BER---->
BER analysis
Matched filter
Decorrelator
MMSE
Question 6
Matlab code:
clear all
clc
close all
N = 10^6; % number of bits or symbols
Eb_N0_dB = [0:25]; % multiple Eb/N0 values
nRx = 2;
for ii = 1:length(Eb_N0_dB)
% Transmitter
ip = rand(1,N)>0.5;
s = 2*ip-1;
sCode = 1/sqrt(2)*kron(reshape(s,2,N/2),ones(1,2)) ;
% channel
h = 1/sqrt(2)*[randn(nRx,N) + j*randn(nRx,N)];
n = 1/sqrt(2)*[randn(nRx,N) + j*randn(nRx,N)];
y = zeros(nRx,N);
yMod = zeros(nRx*2,N);
hMod = zeros(nRx*2,N);
for kk = 1:nRx
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

hMod = kron(reshape(h(kk,:),2,N/2),ones(1,2)); %
repeating the same channel for two symbols
hMod = kron(reshape(h(kk,:),2,N/2),ones(1,2));
temp = hMod;
hMod(1,[2:2:end]) = conj(temp(2,[2:2:end]));
hMod(2,[2:2:end]) = -conj(temp(1,[2:2:end]));
% Channel and noise Noise addition
y(kk,:) = sum(hMod.*sCode,1) +
10^(-Eb_N0_dB(ii)/20)*n(kk,:);
% Receiver
yMod([2*kk-1:2*kk],:) =
kron(reshape(y(kk,:),2,N/2),ones(1,2));
% forming the equalization matrix
hEq([2*kk-1:2*kk],:) = hMod;
hEq(2*kk-1,[1:2:end]) = conj(hEq(2*kk-1,[1:2:end]));
hEq(2*kk, [2:2:end]) = conj(hEq(2*kk, [2:2:end]));
end
% equalization
hEqPower = sum(hEq.*conj(hEq),1);
yHat = sum(hEq.*yMod,1)./hEqPower; % [h1*y1 + h2y2*, h2*y1 -
h1y2*, ... ]
yHat(2:2:end) = conj(yHat(2:2:end));
% receiver - hard decision decoding
ipHat = real(yHat)>0;
% counting the errors
nErr(ii) = size(find([ip- ipHat]),2);
end
simBer = nErr/N; % simulated ber
EbN0Lin = 10.^(Eb_N0_dB/10);
theoryBer_nRx1 = 0.5.*(1-1*(1+1./EbN0Lin).^(-0.5));
p = 1/2 - 1/2*(1+1./EbN0Lin).^(-1/2);
theoryBerMRC_nRx2 = p.^2.*(1+2*(1-p));
pAlamouti = 1/2 - 1/2*(1+2./EbN0Lin).^(-1/2);
theoryBerAlamouti_nTx2_nRx1 = pAlamouti.^2.*(1+2*(1-pAlamouti));
close all
figure
semilogy(Eb_N0_dB,theoryBer_nRx1,'bp-','LineWidth',2);
hold on
semilogy(Eb_N0_dB,theoryBerMRC_nRx2,'kd-','LineWidth',2);
repeating the same channel for two symbols
hMod = kron(reshape(h(kk,:),2,N/2),ones(1,2));
temp = hMod;
hMod(1,[2:2:end]) = conj(temp(2,[2:2:end]));
hMod(2,[2:2:end]) = -conj(temp(1,[2:2:end]));
% Channel and noise Noise addition
y(kk,:) = sum(hMod.*sCode,1) +
10^(-Eb_N0_dB(ii)/20)*n(kk,:);
% Receiver
yMod([2*kk-1:2*kk],:) =
kron(reshape(y(kk,:),2,N/2),ones(1,2));
% forming the equalization matrix
hEq([2*kk-1:2*kk],:) = hMod;
hEq(2*kk-1,[1:2:end]) = conj(hEq(2*kk-1,[1:2:end]));
hEq(2*kk, [2:2:end]) = conj(hEq(2*kk, [2:2:end]));
end
% equalization
hEqPower = sum(hEq.*conj(hEq),1);
yHat = sum(hEq.*yMod,1)./hEqPower; % [h1*y1 + h2y2*, h2*y1 -
h1y2*, ... ]
yHat(2:2:end) = conj(yHat(2:2:end));
% receiver - hard decision decoding
ipHat = real(yHat)>0;
% counting the errors
nErr(ii) = size(find([ip- ipHat]),2);
end
simBer = nErr/N; % simulated ber
EbN0Lin = 10.^(Eb_N0_dB/10);
theoryBer_nRx1 = 0.5.*(1-1*(1+1./EbN0Lin).^(-0.5));
p = 1/2 - 1/2*(1+1./EbN0Lin).^(-1/2);
theoryBerMRC_nRx2 = p.^2.*(1+2*(1-p));
pAlamouti = 1/2 - 1/2*(1+2./EbN0Lin).^(-1/2);
theoryBerAlamouti_nTx2_nRx1 = pAlamouti.^2.*(1+2*(1-pAlamouti));
close all
figure
semilogy(Eb_N0_dB,theoryBer_nRx1,'bp-','LineWidth',2);
hold on
semilogy(Eb_N0_dB,theoryBerMRC_nRx2,'kd-','LineWidth',2);

semilogy(Eb_N0_dB,theoryBerAlamouti_nTx2_nRx1,'c+-','LineWidth',2
);
semilogy(Eb_N0_dB,simBer,'mo-','LineWidth',2);
axis([0 25 10^-5 0.5])
grid on
legend('user 1', 'use 2', 'user 3', 'user 4');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('BER performnce)');
Results:
0 5 10 15 20 25
Eb/No, dB
10-5
10-4
10-3
10-2
10-1
Bit Error Rate
BER performnce)
user 1
use 2
user 3
user 4
);
semilogy(Eb_N0_dB,simBer,'mo-','LineWidth',2);
axis([0 25 10^-5 0.5])
grid on
legend('user 1', 'use 2', 'user 3', 'user 4');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('BER performnce)');
Results:
0 5 10 15 20 25
Eb/No, dB
10-5
10-4
10-3
10-2
10-1
Bit Error Rate
BER performnce)
user 1
use 2
user 3
user 4

Conclusion
This design work emphasizes on those effects that have a strong influence on the
performance of CDMA system using PN sequence code, walsh-code and gold sequence code
[12]. The performance comparison of CDMA system using various diversity techniques has been
designed. Therefore the design work was successful.
This design work emphasizes on those effects that have a strong influence on the
performance of CDMA system using PN sequence code, walsh-code and gold sequence code
[12]. The performance comparison of CDMA system using various diversity techniques has been
designed. Therefore the design work was successful.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

References
[1] J. D. Boerman, J. T. Bernhard, "Performance study of pattern reconfigurable antennas in
MIMO communication systems", Transactions on Antennas and Propag, vol. 56, no. 1,
pp. 231-236, January 2008.
[2] L. Moustakas, H. U. Baranger, L. Balents, A. M. Sengupta, S. H. Simon, "Communication
through a diffusive medium coherence and capacity", science, vol. 287, no. 5451, pp.
287-290, January. 2000.
[3] B. Gershman, N. D. Sidiropolous, "Space-time Processing for MIMO Communications Eds."
in West Sussex, U. K. Wiley, 2005.
[4] C. Waldschmidt, T. Fugen, W. Wiesbeck, "Spiral and dipole antennas for indoor MIMO-
systems," IEEE Antennas Wireless Propag. Lett, vol. 1, no. 1, pp. 176-178, 2002.
[5] M. S. Sharawi, M. A. Jan, D. N. Alo, "Four-shaped 2×2 multi-standard compact Multiple-
Input-Multiple-Output antenna system for long term evolution mobile handsets", IET
Microw. Antennas Propel, vol. 6, pp. 685-696, 2012.
[6] T. C. Tang, K.H. Lin, "MIMO antenna design in thin film integrated passive device", IEEE
Trans on Components Packaging and Manufacturing Technology, vol. 4, no. 4, April
2014.
[7] R. Suga, H. Nakano, Y. Hirachi, J. Hirokawa, M. Ando, "Cost effective 60 GHz antenna
package with end-fire radiation for wireless file transfer system", IEEE Trans. Microw.
Theory Tech, vol. 58, no. 12, pp. 3989-3995, December 2010.
[8] Biglieri, E. (2010). MIMO wireless communications. Cambridge: Cambridge University
Press.
[1] J. D. Boerman, J. T. Bernhard, "Performance study of pattern reconfigurable antennas in
MIMO communication systems", Transactions on Antennas and Propag, vol. 56, no. 1,
pp. 231-236, January 2008.
[2] L. Moustakas, H. U. Baranger, L. Balents, A. M. Sengupta, S. H. Simon, "Communication
through a diffusive medium coherence and capacity", science, vol. 287, no. 5451, pp.
287-290, January. 2000.
[3] B. Gershman, N. D. Sidiropolous, "Space-time Processing for MIMO Communications Eds."
in West Sussex, U. K. Wiley, 2005.
[4] C. Waldschmidt, T. Fugen, W. Wiesbeck, "Spiral and dipole antennas for indoor MIMO-
systems," IEEE Antennas Wireless Propag. Lett, vol. 1, no. 1, pp. 176-178, 2002.
[5] M. S. Sharawi, M. A. Jan, D. N. Alo, "Four-shaped 2×2 multi-standard compact Multiple-
Input-Multiple-Output antenna system for long term evolution mobile handsets", IET
Microw. Antennas Propel, vol. 6, pp. 685-696, 2012.
[6] T. C. Tang, K.H. Lin, "MIMO antenna design in thin film integrated passive device", IEEE
Trans on Components Packaging and Manufacturing Technology, vol. 4, no. 4, April
2014.
[7] R. Suga, H. Nakano, Y. Hirachi, J. Hirokawa, M. Ando, "Cost effective 60 GHz antenna
package with end-fire radiation for wireless file transfer system", IEEE Trans. Microw.
Theory Tech, vol. 58, no. 12, pp. 3989-3995, December 2010.
[8] Biglieri, E. (2010). MIMO wireless communications. Cambridge: Cambridge University
Press.

[9] Sibille, A., Oestges, C., & Zanella, A. (2011). MIMO: From theory to implementation.
Burlington, MA: Academic Press.
[10] Duman, T. M., & Ghrayeb, A. (2008). Coding for MIMO Communication Systems. New
York, NY: John Wiley & Sons.
[11] Kaiser, T., & Zheng, F. (2010). Ultra wideband systems with MIMO. Chichester, West
Sussex, and U.K: Wiley.
[12] Van, R. P., Lotter, M. P., & Van, W. D. (2011). Space-time processing for CDMA mobile
communications. New York: Springer.
Burlington, MA: Academic Press.
[10] Duman, T. M., & Ghrayeb, A. (2008). Coding for MIMO Communication Systems. New
York, NY: John Wiley & Sons.
[11] Kaiser, T., & Zheng, F. (2010). Ultra wideband systems with MIMO. Chichester, West
Sussex, and U.K: Wiley.
[12] Van, R. P., Lotter, M. P., & Van, W. D. (2011). Space-time processing for CDMA mobile
communications. New York: Springer.
1 out of 24

Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024 | Zucol Services PVT LTD | All rights reserved.