can any one tell me how to make every 1 subcarrier take 2 user ?

조회 수: 4 (최근 30일)
wamedh naseer
wamedh naseer 2022년 9월 3일
답변: Sufiyan 2023년 3월 30일
N=128; % number of subcarriers
K=4; % number of users
SINR = 20; % SINR in dB (average)
% SINR = 10 log10(Signal power / Noise power)
% sigma squared = sigma2 = (Noise power / Signal Power)
% SINR = 10 log10(1 / sigma2) = -10 log10(sigma2)
sigma2 = 10^(-SINR/10);
channel_gain = rand(N,K)*2;
g = channel_gain;
a = zeros(N,K);
subcarrier_allocation = zeros(128,1);
% Initialize allocation
% Assume only 1 user can have every subcarrier
for count = 1:128
[Max_g,user] = max(g(count,:));
subcarrier_allocation(count) = user;
a(count, user) = 1;
end
Ptotal = 1;
[rate_user, power_user] = waterfilling(1,a,g,Ptotal,N);
utility(1) = sum(rate_user);

답변 (1개)

Sufiyan
Sufiyan 2023년 3월 30일
Hi,
You can refer to the code below
N=128; % number of subcarriers
K=4; % number of users
SINR = 20; % SINR in dB (average)
sigma2 = 10^(-SINR/10);
channel_gain = rand(N,K)*2;
g = channel_gain;
a = zeros(N,K);
subcarrier_allocation = zeros(128,1);
% Initialize allocation
% Assume only 1 user can have every subcarrier
for count = 1:2:N
[Max_g,user] = max(g(count,:));
subcarrier_allocation(count) = user;
a(count, user) = 1;
% Assign the next user to the same subcarrier
[Max_g,user] = max(g(count+1,:));
subcarrier_allocation(count+1) = user;
a(count+1, user) = 1;
end
Ptotal = 1;
[rate_user, power_user] = waterfilling(1,a,g,Ptotal,N);
utility(1) = sum(rate_user);

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by