% MIMO_Capacity.m
clear all;clc;
Nt = 1; % 8.发射天线的数目为1
Nr = 1; % 9.接收天线的数目为1
SampleNum = 10000; % 10.蒙特卡洛仿真时的抽样数量
SNR_dB = 2:2:20; % 11.信噪比(单位dB)
for nSNR = 1:length(SNR_dB)
SNR_dB(nSNR)
rho = 10^(SNR_dB(nSNR)/10); % 13-15.完成信噪比的单位转换
for nSample = 1:SampleNum
H = (randn(Nr,Nt)+sqrt(-1)*randn(Nr,Nt))/sqrt(2); % 18.瑞利衰落信道矩阵
Cn(nSNR,nSample) = log2(real(det(min(Nt,Nr)+rho*H*H'/Nt)));
end
Capacity1(nSNR) = mean( Cn(nSNR,:) ); % 22.求遍历信道容量
tempC1 = sort(Cn(nSNR,:));
end
Nt = 3; % 26-42.收发两端天线的数目为3
Nr = 3;
SampleNum = 10000;
SNR_dB = 2:2:20;
for nSNR = 1:length(SNR_dB)
SNR_dB(nSNR)
rho = 10^(SNR_dB(nSNR)/10);
for nSample = 1:SampleNum
H = (randn(Nr,Nt)+sqrt(-1)*randn(Nr,Nt))/sqrt(2);
Cn(nSNR,nSample) = log2(real(det(min(Nt,Nr)+rho*H*H'/Nt)));
end
Capacity2(nSNR) = mean( Cn(nSNR,:) );
tempC2 = sort(Cn(nSNR,:));
end
Nt = 5; % 44-60.收发两端天线的数目为5
Nr = 5;
SampleNum = 10000;
SNR_dB = 2:2:20;
for nSNR = 1:length(SNR_dB)
SNR_dB(nSNR)
rho = 10^(SNR_dB(nSNR)/10);
for nSample = 1:SampleNum
H = (randn(Nr,Nt)+sqrt(-1)*randn(Nr,Nt))/sqrt(2);
Cn(nSNR,nSample) = log2(real(det(min(Nt,Nr)+rho*H*H'/Nt)));
end
Capacity3(nSNR) = mean( Cn(nSNR,:) );
tempC3 = sort(Cn(nSNR,:));
end
Nt = 7; % 62-78.收发两端天线的数目为7
Nr = 7;
SampleNum = 10000;
SNR_dB = 2:2:20;
for nSNR = 1:length(SNR_dB)
SNR_dB(nSNR)
rho = 10^(SNR_dB(nSNR)/10);
for nSample = 1:SampleNum
H = (randn(Nr,Nt)+sqrt(-1)*randn(Nr,Nt))/sqrt(2);
Cn(nSNR,nSample) = log2(real(det(min(Nt,Nr)+rho*H*H'/Nt)));
end
Capacity4(nSNR) = mean( Cn(nSNR,:) );
tempC4 = sort(Cn(nSNR,:));
end
Nt = 9; % 80-96.收发两端天线的数目为9
Nr = 9;
SampleNum = 10000;
SNR_dB = 2:2:20;
for nSNR = 1:length(SNR_dB)
SNR_dB(nSNR)
rho = 10^(SNR_dB(nSNR)/10);
for nSample = 1:SampleNum
H = (randn(Nr,Nt)+sqrt(-1)*randn(Nr,Nt))/sqrt(2);
Cn(nSNR,nSample) = log2(real(det(min(Nt,Nr)+rho*H*H'/Nt)));
end
Capacity5(nSNR) = mean( Cn(nSNR,:) );
tempC5 = sort(Cn(nSNR,:));
end
figure(1) % 98.开始仿真作图
nSNR = length(SNR_dB);
plot(tempC1, (1:SampleNum)/SampleNum, 'r-');
hold on;
plot(tempC2, (1:SampleNum)/SampleNum, 'g-');
hold on;
plot(tempC3, (1:SampleNum)/SampleNum, 'b-');
hold on;
plot(tempC4, (1:SampleNum)/SampleNum, 'y-');
hold on;
plot(tempC5, (1:SampleNum)/SampleNum, 'c-');
hold on;
xlabel('信道容量 (bit/s/Hz)');
ylabel('概率分布');
legend('1X1','3X3','5X5','7X7','9X9')
grid on;
figure(2)
plot(SNR_dB, Capacity1, 'r-');
hold on;
plot(SNR_dB, Capacity2, 'g-');
hold on;
plot(SNR_dB, Capacity3, 'b-');
hold on;
plot(SNR_dB, Capacity4, 'y-');
hold on;
plot(SNR_dB, Capacity5, 'c-');
hold on;
xlabel('信噪比(dB)');
ylabel('遍历容量');
legend('1X1','3X3','5X5','7X7','9X9');
grid on;
- 1
- 2
- 3
- 4
- 5
- 6
前往页