Mimo Matlab Code

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7
At a glance
Powered by AI
The MATLAB code is calculating the channel capacity of MIMO systems with and without channel state information at the transmitter (CSIT) for different numbers of transmitter and receiver antennas.

The code is using singular value decomposition to decompose the channel matrix and calculate its eigenvalues. It then uses these values to compute capacity with and without CSIT using equal power allocation and water filling respectively. Plots are generated to compare the capacities.

Capacity without CSIT assumes equal power allocation across antennas while capacity with CSIT uses water filling to allocate power optimally based on channel conditions. CSIT provides higher capacity due to this optimal power allocation.

MATLAB CODE:

1. CAPACITY WITH AND WITHOUT CSIT FOR 5x10 MIMO SYSTEM


clc;
clear all;
close all;
Nt=5;
Nr=10;

%---------No. of transmitter antennas


%---------No. of receiver antennas

snrdB=0:1:10; %-----------snr values in dB, for which capacity will


be computed
snr=10.^(snrdB/10);
Cut=zeros(1,length(snr));
%---------capacity of a uninformed
transmitter i.e., without CSIT
Cit=zeros(1,length(snr));
%---------capacity of an informed
transmitter i.e., with CSIT
Cut_tot=zeros(1,length(snr));
Cit_tot=zeros(1,length(snr));
count=100;
for k=1:count
H=randn(Nr,Nt)+i*randn(Nr,Nt); %---------channel matrix H
[U,S,V]=svd(H); %----------singular value decomposition of H
sv=diag(S); %--------------non-zero singular values of H
ev=sv.*sv; %--------------eigen values of H
r=rank(H); %--------------computing rank of H
for i=1:length(snr)
%CAPACITY CALCULATION FOR EQUAL POWER ALLOCATION WITHOUR CSIT
for j=1:r
Cut(i)=Cut(i)+log2(1+((snr(i)/Nt)*ev(j)));
end
%WATER POURING ALGORITHM FOR CALCULATION OF CAPACITY WITH CSIT
p=1;
Pi=zeros(1,r);
while(Pi(r-p+1)<=0)
x=0;
for j=1:r-p+1
x=x+(1/ev(j));
end
Mu=(Nt/(r-p+1))*(1+(1/snr(i))*x);
for j=1:r-p+1
Pi(j)=Mu-(Nt/((snr(i))*ev(j)));

end
if Pi(r-p+1)<=0
Pi(r-p+1)=0;
end
p=p+1;
end
for j=1:r
Cit(i)=Cit(i)+log2(1+((snr(i)/Nt)*Pi(j)*ev(j)));
end
end
Cut_tot=Cut_tot+Cut;
Cit_tot=Cit_tot+Cit;
end
Cut_avg=Cut_tot/count;
Cit_avg=Cit_tot/count;
for i=1:length(snr)
diff(i)=Cit_avg(i)-Cut_avg(i);
end
%----------------PLOTS----------------------%
figure
plot(snrdB,Cut_avg,'-*r')
hold on
plot(snrdB,Cit_avg,'-o')
hold on
plot(snrdB,diff,'->g')
xlabel('SNR in dB')
ylabel('Capacity')
legend('without CSIT','with CSIT','difference in capacity')

2. CAPACITY WITH AND WITHOUT CSIT FOR 10X5 MIMO SYSTEM


clc;
clear all;
close all;
Nt=10;
%---------No. of transmitter antennas
Nr=5; %---------No. of receiver antennas
snrdB=0:1:10; %-----------snr values in dB, for which capacity will
be computed
snr=10.^(snrdB/10);
Cut=zeros(1,length(snr));
%---------capacity of a uninformed
transmitter i.e., without CSIT
Cit=zeros(1,length(snr));
%---------capacity of an informed
transmitter i.e., with CSIT

Cut_tot=zeros(1,length(snr));
Cit_tot=zeros(1,length(snr));
count=100;
for k=1:count
H=randn(Nr,Nt)+i*randn(Nr,Nt); %---------channel matrix H
[U,S,V]=svd(H); %----------singular value decomposition of H
sv=diag(S); %--------------non-zero singular values of H
ev=sv.*sv; %--------------eigen values of H
r=rank(H); %--------------computing rank of H
for i=1:length(snr)
%CAPACITY CALCULATION FOR EQUAL POWER ALLOCATION WITHOUR CSIT
for j=1:r
Cut(i)=Cut(i)+log2(1+((snr(i)/Nt)*ev(j)));
end
%WATER POURING ALGORITHM FOR CALCULATION OF CAPACITY WITH CSIT
p=1;
Pi=zeros(1,r);
while(Pi(r-p+1)<=0)
x=0;
for j=1:r-p+1
x=x+(1/ev(j));
end
Mu=(Nt/(r-p+1))*(1+(1/snr(i))*x);
for j=1:r-p+1
Pi(j)=Mu-(Nt/((snr(i))*ev(j)));
end
if Pi(r-p+1)<=0
Pi(r-p+1)=0;
end
p=p+1;
end
for j=1:r
Cit(i)=Cit(i)+log2(1+((snr(i)/Nt)*Pi(j)*ev(j)));
end
end
Cut_tot=Cut_tot+Cut;
Cit_tot=Cit_tot+Cit;
end
Cut_avg=Cut_tot/count;
Cit_avg=Cit_tot/count;
for i=1:length(snr)
diff(i)=Cit_avg(i)-Cut_avg(i);

end
%----------------PLOTS----------------------%
figure
plot(snrdB,Cut_avg,'-*r')
hold on
plot(snrdB,Cit_avg,'-o')
hold on
plot(snrdB,diff,'->g')
xlabel('SNR in dB')
ylabel('Capacity')
legend('without CSIT','with CSIT','difference in capacity')

PLOTS:
1. Nt<Nr

2. Nt>Nr

EC6325
MIMO COMMUNICATION
SYSTEMS
ASSIGNMENT

SUBMITTED BY:
NAMITHA R
S2 TELECOMMUNICATION
M110253EC

OBSERVATION:
1.Nt>Nr
diff =

3.3068
3.4490
3.5999
3.7543
4.3157
4.4270
4.5244
4.6082

3.9072

4.0539

4.1909

0.0251

0.0169

0.0112

2.Nt<Nr
diff =

0.1053
0.0755
0.0532
0.0368
0.0074
0.0048
0.0031
0.0020

You might also like