clc;
clear;
close all;
warning off;
addpath 'down\';
% Number of users
K = 10;
% Number of BR antennas
N = 64;
% Number of attempts
Np = 1000;
% Area
l = 300;
a = l^2;
X_cell = [-l/2:1:l/2];
Y_cell = [-l/2:1:l/2];
% Cell position
Uxc = 0;
Uyc = 0;
% Users random distribution (K x Np)
Ux = round(l.*rand(K,Np) - l/2);
Uy = round(l.*rand(K,Np) - l/2);
% MAT. (K x Np) Distance Recever - Transmiter for each random user from
% the cell
D = zeros(K, Np);
for np=1:Np
for k=1:K
D(k, np) = sqrt((Ux(k, np) - Uxc)^2 + (Uy(k, np) - Uyc)^2);
end
end
% Path Loss and Power Noise parameters
PLo = 10^(-0.1 * 84);
do = 35;
No_dBm = -140;
No = (1e-3) * 10^(0.1 * No_dBm);
F = 1;
eta = 3.5;
% MAT. (K x Np) Path Loss for each random user
PL_R = zeros(K, Np);
for np=1:Np
for k=1:K
PL_R(k, np) = sqrt(2 * PLo)./sqrt(1 + (D(k, np)./do).^(eta));
end
end
% MAT. (N x K x Np) Fast Fading
H = (randn(N, K, Np) + sqrt(-1)*randn(N, K, Np))/sqrt(2);
% MAT. (N x K x Np) Slow Fading
for np=1:Np
h(:,:,np) = PL_R(:,np)' .* H(:,:,np);
end
% SCA. Band
B = 1e9;
% SCA. Noise Power
Pn = No * B * F;
% SCA. Performance
Efficiency = 1;
Performance = 1 / Efficiency;
% VEC. Users Power in dB and Naturals
P_dB_max = [-30:2:10];
P_max = 10.^(0.1*P_dB_max);
% MAT. (K x length(P_max)) Uniform Power values
P = zeros(K, length(P_max));
% MAT. (K x length(P_max) x Np) of SNR, Channel State Information and Capacity
% for Uniform Power Conditions
SNR = zeros(K, length(P_max), Np);
CSI = zeros(K, length(P_max), Np);
C = zeros(K, length(P_max), Np);
% VEC. (length(P_max) x Np) Sum Capacity
Ctot = zeros(length(P_max), Np);
% MAT. (K x length(P_max) x Np) of SINR, Channel State Information and Capacity
% for Uniform Power Conditions with Interference
SINR = zeros(K, length(P_max), Np);
CSI_I = zeros(K, length(P_max), Np);
C_I = zeros(K, length(P_max), Np);
% VEC. (length(P_max) x Np) Sum Capacity
Ctot_I = zeros(length(P_max), Np);
% MAT. (K x length(P_max) x Np) Optimal Power values from Water Filling and
% Water Level
P_opt = zeros(K, length(P_max), Np);
WaterLevel = zeros(length(P_max), Np);
% MAT. (K x length(P_max) x Np) of SNR, Channel State Information and Capacity
% for Water Filling
SNR_WF = zeros(K, length(P_max), Np);
CSI_WF = zeros(K, length(P_max), Np);
C_WF = zeros(K, length(P_max), Np);
% VEC. (length(P_max) x Np) Sum Capacity
Ctot_WF = zeros(length(P_max), Np);
% MAT. (K x length(P_max) x Np) of SINR, Channel State Information and Capacity
% for Water Filling with Interference
SINR_WFI = zeros(K, length(P_max), Np);
CSI_WFI = zeros(K, length(P_max), Np);
C_WFI = zeros(K, length(P_max), Np);
% VEC. (length(P_max) x Np) Sum Capacity
Ctot_WFI = zeros(length(P_max), Np);
% VEC. (K x 1) Dissipated Power
P_c = 1;
% VEC. (length(P_max) x Np) Energy Efficiency
EE = zeros(length(P_max), Np);
% VEC. (K x length(P_max) x Np) Optimal Power values from Dinkelbach with Water Filling
P_opt_EE = zeros(K, length(P_max), Np);
% VEC. (length(P_max) x Np) Optimal Sum Capacity for EE
Ctot_EE = zeros(length(P_max), Np);
% VEC. (length(P_max) x Np) Energy Efficiency
EE_opt = zeros(length(P_max), Np);
% MAT. (K x length(P_max) x Np) of SINR, Channel State Information and Capacity
% for Dinkelbach with Interference
SINR_EE_opt_I = zeros(K, length(P_max), Np);
CSI_EE_opt_I = zeros(K, length(P_max), Np);
C_EE_opt_I = zeros(K, length(P_max), Np);
% VEC. (length(P_max) x Np) Sum Capacity
Ctot_EE_opt_I = zeros(length(P_max), Np);
% VEC. (length(P_max) x Np) Energy Efficiency
EE_opt_I = zeros(length(P_max), Np);
% VEC. (length(P_max) x Np) Energy Efficiency
EE_WF = zeros(length(P_max), Np);
% Sum Capacities and Energy Efficiency Calculation
for np=1:Np
for i=1:length(P_max)
% Uniform power conditions
P(:,i) = (P_max(i) / K) * ones(K,1);
% Rate
[Ctot(i,np), C(:,i,np), SNR(:,i,np), CSI(:,i,np)] = SumCapacityCalc(h(:,:,np), Pn, P(:,i), B, false);
[Ctot_I(i,np), C_I(:,i,np), SINR(:,i,np), CSI_I(:,i,np)] = SumCapacityCalc(h(:,:,np), Pn, P(:,i), B, true);
% Energy Efficiency
[EE(i,np)] = EnergyEfficiencyCalc(Ctot_I(i,np), Performance, P_max(i), P_c);
% Power Optimization
[P_opt(:,i,np), WaterLevel(i,np)] = WaterFilling(CSI(:,i,np), P_max(i));
% Rate
[Ctot_WF(i,np), C_WF(:,i,np), SNR_WF(:,i,np), CSI_WF(:,i,np)] = SumCapacityCalc(h(:,:,np), Pn, P_opt(:,i,np), B, false);
[Ctot_WFI(i,np), C_WFI(:,i,np), SINR_WFI(:,i,np), CSI_WFI(:,i,np)] = SumCapacityCalc(h(:,:,np), Pn, P_opt(:,i,np), B, true);
% Energy Efficiency
[EE_WF(i,np)] = EnergyEfficiencyCalc(Ctot_I(i,np), Performance, sum(P_opt(:,i,np)), P_c);
[EE_opt(i,np), P_opt_EE(:,i,np), Ctot_EE(i,np)] = Dinkelbach(B, CSI(:,i,np), Performance, P_c, Ctot(i,np), P_max(i), h(:,:,np), Pn, i, EE_WF(:,np), EE_opt(:,np), P_opt_EE(:,:,np));
[Ctot_EE_opt_I(i,np), C_EE_opt_I(:,i,np), SINR_EE_opt_I(:,i,np), CSI_EE_opt_I(:,i,np)] = SumCapacityCalc(h(:,:,np), Pn, P_opt_EE(:,i,np), B, true);
[EE_opt_I(i,np)] = EnergyEfficiencyCalc(Ctot_EE_opt_I(i,np), Performance, sum(P_opt_EE(:,i,np)), P_c);
end
end
% Average value on all attempts for all Power values
Ctot_I_av = mean(Ctot_I, 2) / B; % (length(P_max) x Np) -> (length(P_max) x 1)
Ctot_WF_av = mean(Ctot_WF, 2) / B; % (length(P_max) x Np) -> (length(P_max) x 1)
Ctot_WFI_av = mean(Ctot_WFI, 2) / B; % (length(P_max) x Np) -> (length(P_max) x 1)
EE_av = mean(EE, 2) / 1e6; % (length(P_max) x Np) -> (length(P_max) x 1)
EE_opt_av = mean(EE_opt, 2) / 1e6; % (length(P_max) x Np) -> (length(P_max) x 1)
EE_opt_I_av = mean(EE_opt_I, 2) / 1e6; % (length(P_max) x Np) -> (length(P_max) x 1)
% Plot
% Random users plot
figure
pbaspect([1 1 1]);
title('Random users distribution with the BR Station for one attempt');
hold on;
plot(Ux(:, Np), Uy(:, Np), 'x', 'linewidth', 1, 'markersize', 5);
axis ([-l/2 l/2 -l/2 l/2]);
xlabel ('m');
ylabel ('m');
% Cell plot
plot(Uxc, Uyc, '*', 'linewidth', 1, 'markersize', 5);
grid on;
% Sum Capacities plot
figure
pbaspect([1 1 1]);
title(['Sum Rates average with antennas = ', num2str(N)]);
hold on;
% with WF and no interference
semilogy(P_dB_max, Ctot_WF_av, '-og', 'linewidth', 2, 'markersize', 3);
% with WF and interference
semilogy(P_dB_max, Ctot_WFI_av, '-or', 'linewidth', 2, 'markersize', 3);
% with Uniform Power Conditions and interference
semilogy(P_dB_max, Ctot_I_av, '-ob', 'linewidth', 2, 'markersize', 3);
xlabel ('Power dB [dB W]');
ylabel ('Sum Rate [bit / s / Hz]');
legend('No Interference and Water Filling','Interference and Water Filling', 'Interference and Uniform Power Conditions', 'Location', 'northwest');
grid on;
% Optimal Powers plot
figure
pbaspect([2 1 1]);
title(['Power distribution by Water Filling for one attempt with total Power = ', num2str(P_max(i))]);
hold on;
bar(P_opt(:,i,Np), 'r');
yline(WaterLevel(i,Np), '--');
xlim([0 K+1]);
xlabel ('Users');
ylabel ('1 / \nu');
grid on;
% CSI plot
subplot(2, 4, 7);
pbaspect([2 1 1]);
title('Inverse Channel State Information for one attempt');
hold on;
bar(1./CSI_I(:,i,Np));
xlim([0 K+1]);
xlabel ('Users');
ylabel ('1 / CSI');
grid on;
% Energy Efficiencies plot
figure
pbaspect([1 1 1]);
title(['Energy Efficiencies average with antennas = ', num2str(N)]);
hold on;
% with Dinkelbach and no interference
semilogy(P_dB_max, EE_opt_av, '-o', 'linewidth', 2, 'markersize', 3);
% with Dinkelbach and interference
semilogy(P_dB_max, EE_opt_I_av, '-o', 'linewidth', 2, 'markersize', 3);
% with Uniform Power Conditions and interference
semilogy(P_dB_max, EE_av, '-o', 'linewidth', 2, 'markersize', 3);
xlabel ('Power dB [dB W]');
ylabel ('Energy Efficiency [Megabit / Joule]');
legend('No Interference and Dinkelbach', 'Interference and Dinkelbach', 'Interference and Uniform Power Conditions', 'Location', 'northwest');
grid on;
% End Script

mYlEaVeiSmVp
- 粉丝: 2362
最新资源
- 孤岛型微电网中改进下垂控制策略:'虚拟阻抗与无功均分的应用'
- 医药洁净室温湿度串级PID控制:基于200smart PLC的创新实现与挑战 专业版
- 基于Vuejs框架构建的现代化前端单页面应用项目-包含热重载开发服务器和Webpack生产环境构建配置-通过npm脚本命令实现依赖安装开发调试与生产打包-使用vue-loader.zip
- MATLAB中灰狼算法与改狼算法对23种测试函数的性能探究及应用前景 系统版
- 基于混合决策规则与Wasserstein度量的分布式鲁棒多阶段框架:适应风电渗透下的机组不确定性承诺与调度策略优化
- 电力电子领域Z源逆变器并网闭环仿真的L滤波器动态性能分析与应用
- 单相有源Boost PFC功率因数矫正电路设计原理与应用(220V交流转400V直流,功率200W)
- 基于Abaqus与Matlab蜂群算法耦合的结构优化程序研究及其工程应用 - Abaqus
- 基于配置化数据表格与动态图表展示的交互式数据可视化工具-支持拖拽排序-自定义样式-实时预览-多格式导出-响应式布局-数据绑定-配置驱动-JSON导入导出-Excel兼容-数据筛选-.zip
- 电机控制领域FOC电流环PI参数自整定Simulink仿真模型及其应用
- 一个目标检测图像增强的示例脚本
- 基于遗产算法的多目标分布式电源选址定容策略仿真研究:以投资成本等三目标实现方案验证 - 多目标优化
- BabeLua,一款vs的lua开发软件
- (雷同的那个是营销号)YOLOv8检测模块组合优化改进(成功涨点):添加GAM注意力机制;添加小目标检测头;替换为Wise-IoU损失函数+完整web端展示(实现简单目标跟踪功能)
- 基于MATLAB的LSTM与分位数回归多输入单输出时间序列预测模型
- MATLAB实现电-气-热综合能源系统耦合优化调度模型及其应用 综合能源系统 (2025-08-24)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


