信道容量计算CDF值源码程序,程序员在编程的过程中可以参考学习使用,希望对IT程序员有用,此源码程序简单易懂、方便阅读,有很好的学习价值!
clc;
clear;
close all;
warning off;
RandStream.setDefaultStream(RandStream.create('mt19937ar','seed',1));
%定义2*2天线
M = 2;
N = 2;
% Pt = 14;%发射功率
% Gt = 64;%发送天线的增益
% Gr = 64;%接收天线的增益
% R = 0.6;%小区半径
% Phatloss = 128.1 + 37.6*log10(R);%路径损耗
% Shadowfading = 8;%阴影衰落
% PN = 5;%噪声功率
% SNRs = Pt + Gt + Gr - Phatloss - Shadowfading - PN;
SNRs = 10;
tc = 10;
Num_user = 24;
sel = 1;%1,2,3,4,选择四种不同的方法进行仿真
sel2 = 0;%0直接出图,1进行逐个仿真
if sel2 == 1
for j=1:Num_user
j
%计算第一个用户的相关值
In_index = zeros(1,10*j);
though_Output = zeros(1,10*j);
though_Input = zeros(1,10*j);
SNR = SNRs*rand(1,10*j);
%调用调度函数
if sel == 1
[H,number] = func_No_Scheduling(10*j,M,N);
end
if sel == 2
[H,number] = func_Random_Paring_Scheduling(10*j,M,N);
end
if sel == 3
[H,number] = func_Orthogonal_Paring_Scheduling(10*j,M,N);
end
if sel == 4
[H,number] = func_Determinant_Paring_Scheduling(10*j,M,N);
end
%基于MMSE的接收
[M,Nes] = func_MMSE_receiver(H,SNR(number));
sirer = zeros(1,10*j);
sirer(number) = log2(1+Nes);
[though_Output,indexout,uenow]=func_calc(sirer,though_Input,tc,In_index,number);
though_Input = though_Output;
In_index = indexout;
S(1) = sum(log2(1+Nes));
%计算其余用户的相关值
for k=2:10*j
M = 2;
H = zeros();
%调用调度函数
if sel == 1
[H,number] = func_No_Scheduling(10*j,M,N);
end
if sel == 2
[H,number] = func_Random_Paring_Scheduling(10*j,M,N);
end
if sel == 3
[H,number] = func_Orthogonal_Paring_Scheduling(10*j,M,N);
end
if sel == 4
[H,number] = func_Determinant_Paring_Scheduling(10*j,M,N);
end
%基于MMSE的接收
[M,Nes] = func_MMSE_receiver(H,SNR(number));
sirer = zeros(1,10*j);
sirer(number) = log2(1+Nes);
[though_Output,indexout,uenow]=func_calc(sirer,though_Input,tc,In_index,number);
though_Input = though_Output;
In_index = indexout;
S(k) = sum(log2(1+Nes));
end
fair(j) = sum(though_Output)^2/(length(though_Output)*sum(though_Output.^2));
%计算信道容量
SNR_Linear = 10^(SNRs/10);
Capacity(j) = 0.5 * log10(1 + (SNR_Linear * sum(abs(fair(j)))));
end
%根据信道容量计算CDF值
CDFs=func_CDF(Capacity,Num_user);
if sel == 1
save data0.mat CDFs
end
if sel == 2
save data1.mat CDFs
end
if sel == 3
save data2.mat CDFs
end
if sel == 4
save data3.mat CDFs
end
else
load data0.mat
figure
plot(1:0.5:12,CDFs,'k','LineWidth',2);grid on
hold on;
load data1.mat
plot(1:0.5:12,CDFs,'b','LineWidth',2);grid on
hold on;
load data2.mat
plot(1:0.5:12,CDFs,'r','LineWidth',2);grid on
hold on;
load data3.mat
plot(1:0.5:12,CDFs,'g','LineWidth',2);grid on
hold on;
axis([1,12,0,1]);
legend('Receive Diverse','Random Pairing','Orthogonal Pairing','Determinant Pairing');
xlabel('Thoughout');
ylabel('CDF');
end