%% Channel Capacity of MIMO
clear;
clc;
global sigma AoA1 AoA2 AoA3 AoA4 AoA5 AoA6
AoA1=10/180*pi
AoA2=40/180*pi
AoA3=70/180*pi
AoA4=90/180*pi
AoA5=100/180*pi
AoA6=120/180*pi
Re_CorrelationMatrix=zeros(4,4);
for mm=1:4
Re_CorrelationMatrix(mm,mm)=1;
end
AngleSpread=15;
sigma=AngleSpread/180*pi;
deltaphi=sqrt(3)*sigma
temp1=AoA1-deltaphi
temp2=AoA1+deltaphi
temp3=AoA2-deltaphi
temp4=AoA2+deltaphi
temp5=AoA3-deltaphi
temp6=AoA3+deltaphi
temp7=AoA4-deltaphi
temp8=AoA4+deltaphi
temp9=AoA5-deltaphi
temp10=AoA5+deltaphi
temp11=AoA6-deltaphi
temp12=AoA6+deltaphi
%one cluster
Q=1/2/deltaphi
Q1=Q
Coefficient_1_2=quadv(@CorrCoe_1d,temp1,temp2)*Q1;
Coefficient_1_3=quadv(@CorrCoe_2d,temp1,temp2)*Q1
Coefficient_1_4=quadv(@CorrCoe_3d,temp1,temp2)*Q1
%
% %two clusters power ratio 2:1
% Q=1/6/deltaphi
% Q1=2*Q
% Q2=Q
%
% Coefficient_1_2=quadv(@CorrCoe_1d,temp1,temp2)*Q1+quadv(@CorrCoe_1d,temp3,temp4)*Q2;
% Coefficient_1_3=quadv(@CorrCoe_2d,temp1,temp2)*Q1+quadv(@CorrCoe_2d,temp3,temp4)*Q2
% Coefficient_1_4=quadv(@CorrCoe_3d,temp1,temp2)*Q1+quadv(@CorrCoe_3d,temp3,temp4)*Q2
%
% three clusters power ratio 3:2:1
Q=1/12/deltaphi
Q1=3*Q
Q2=2*Q
Q3=Q
Coefficient_1_2=quadv(@CorrCoe_1d,temp1,temp2)*Q1+quadv(@CorrCoe_1d,temp3,temp4)*Q2+quadv(@CorrCoe_1d,temp5,temp6)*Q3;
Coefficient_1_3=quadv(@CorrCoe_2d,temp1,temp2)*Q1+quadv(@CorrCoe_2d,temp3,temp4)*Q2+quadv(@CorrCoe_2d,temp5,temp6)*Q3
Coefficient_1_4=quadv(@CorrCoe_3d,temp1,temp2)*Q1+quadv(@CorrCoe_3d,temp3,temp4)*Q2+quadv(@CorrCoe_3d,temp5,temp6)*Q3
% % %four clusters power ratio 4:3:2:1
% Q=1/20/deltaphi
% Q1=4*Q
% Q2=3*Q
% Q3=2*Q
% Q4=Q
% Coefficient_1_2=quadv(@CorrCoe_1d,temp1,temp2)*Q1+quadv(@CorrCoe_1d,temp3,temp4)*Q2+quadv(@CorrCoe_1d,temp5,temp6)*Q3+quadv(@CorrCoe_1d,temp7,temp8)*Q4;
% Coefficient_1_3=quadv(@CorrCoe_2d,temp1,temp2)*Q1+quadv(@CorrCoe_2d,temp3,temp4)*Q2+quadv(@CorrCoe_2d,temp5,temp6)*Q3+quadv(@CorrCoe_2d,temp7,temp8)*Q4
% Coefficient_1_4=quadv(@CorrCoe_3d,temp1,temp2)*Q1+quadv(@CorrCoe_3d,temp3,temp4)*Q2+quadv(@CorrCoe_3d,temp5,temp6)*Q3+quadv(@CorrCoe_3d,temp7,temp8)*Q4
%
% %five clusters power ratio 5:4:3:2:1
% Q=1/30/deltaphi
% Q1=5*Q
% Q2=4*Q
% Q3=3*Q
% Q4=2*Q
% Q5=1*Q
% Coefficient_1_2=quadv(@CorrCoe_1d,temp1,temp2)*Q1+quadv(@CorrCoe_1d,temp3,temp4)*Q2+quadv(@CorrCoe_1d,temp5,temp6)*Q3+quadv(@CorrCoe_1d,temp7,temp8)*Q4+quadv(@CorrCoe_1d,temp9,temp10)*Q5;
% Coefficient_1_3=quadv(@CorrCoe_2d,temp1,temp2)*Q1+quadv(@CorrCoe_2d,temp3,temp4)*Q2+quadv(@CorrCoe_2d,temp5,temp6)*Q3+quadv(@CorrCoe_2d,temp7,temp8)*Q4+quadv(@CorrCoe_2d,temp9,temp10)*Q5;
% Coefficient_1_4=quadv(@CorrCoe_3d,temp1,temp2)*Q1+quadv(@CorrCoe_3d,temp3,temp4)*Q2+quadv(@CorrCoe_3d,temp5,temp6)*Q3+quadv(@CorrCoe_3d,temp7,temp8)*Q4+quadv(@CorrCoe_3d,temp9,temp10)*Q5;
%six clusters power ratio 6:5:4:3:2:1
Q=1/42/deltaphi
Q1=6*Q
Q2=5*Q
Q3=4*Q
Q4=3*Q
Q5=2*Q
Q6=Q
Coefficient_1_2=quadv(@CorrCoe_1d,temp1,temp2)*Q1+quadv(@CorrCoe_1d,temp3,temp4)*Q2+quadv(@CorrCoe_1d,temp5,temp6)*Q3+quadv(@CorrCoe_1d,temp7,temp8)*Q4+quadv(@CorrCoe_1d,temp9,temp10)*Q5+quadv(@CorrCoe_1d,temp11,temp12)*Q6;
Coefficient_1_3=quadv(@CorrCoe_2d,temp1,temp2)*Q1+quadv(@CorrCoe_2d,temp3,temp4)*Q2+quadv(@CorrCoe_2d,temp5,temp6)*Q3+quadv(@CorrCoe_2d,temp7,temp8)*Q4+quadv(@CorrCoe_2d,temp9,temp10)*Q5+quadv(@CorrCoe_2d,temp11,temp12)*Q6;
Coefficient_1_4=quadv(@CorrCoe_3d,temp1,temp2)*Q1+quadv(@CorrCoe_3d,temp3,temp4)*Q2+quadv(@CorrCoe_3d,temp5,temp6)*Q3+quadv(@CorrCoe_3d,temp7,temp8)*Q4+quadv(@CorrCoe_3d,temp9,temp10)*Q5+quadv(@CorrCoe_3d,temp11,temp12)*Q6;
Re_CorrelationMatrix(1,2)=Coefficient_1_2;
Re_CorrelationMatrix(1,3)=Coefficient_1_3;
Re_CorrelationMatrix(1,4)=Coefficient_1_4;
Re_CorrelationMatrix(2,1)=conj(Coefficient_1_2) %4_3;
Re_CorrelationMatrix(2,3)=Coefficient_1_2;
Re_CorrelationMatrix(2,4)=Coefficient_1_3;
Re_CorrelationMatrix(3,1)=conj(Coefficient_1_3) %4_2;
Re_CorrelationMatrix(3,2)=conj(Coefficient_1_2) %4_3;
Re_CorrelationMatrix(3,4)=Coefficient_1_2;
Re_CorrelationMatrix(4,1)=conj(Coefficient_1_4) %4_1;
Re_CorrelationMatrix(4,2)=conj(Coefficient_1_3) %4_2;
Re_CorrelationMatrix(4,3)=conj(Coefficient_1_2) %4_3;
%Re_CorrelationMatrix=eye(4)
Capacity=zeros(1,11);
for mm=0:3:30
for nn=1:1000
WhiteMatrix=sqrt(1/2)*randn(4)+j*sqrt(1/2)*randn(4);
Capacity(mm/3+1)=Capacity(mm/3+1)+log2(det(eye(4)+10^(mm/10)/4*(Re_CorrelationMatrix)'...
*WhiteMatrix*eye(4)*WhiteMatrix'));
end
Capacity(mm/3+1)=Capacity(mm/3+1)/1000;
end
dd=0:3:30;
plot(dd,Capacity)
hold on
grid on
hold on