The Loops in the first picture are required, the description is below

1 visualización (últimos 30 días)
Matthew Worker
Matthew Worker el 28 de Jun. de 2021
Editada: Rena Berman el 16 de Dic. de 2021
%% Suppose I have W and Theta, k=1:K .. K=(any value) let say 10
%%
Alfa_k=zeros(1,k);
Alfa_i=zeros(1,k);
Angle_h_w=zeros(1,k);
Angle_g_h_w=zeros(1,k);
n0=zeros(1,k);
for t_1=1:k
Alfa_k(t_1) = 1/(abs(H(t_1,:)*W(:,t_1)));
Angle_h_w(t_1) = angle(H(t_1,:)*W(:,t_1));
Alfa_i(t_1) = 0;
for t_2=1:k
Alfa_i(t_1) = Alfa_i(t_1) + 1/(abs(H(t_2,:)*W(:,t_2)));
end
Alfa_i(t_1) = Alfa_i(t_1) - Alfa_k(t_1); % Sum of Alfa_i
end
L_k = n*(Alfa_k./Alfa_i); % Number of IRS Elements Assigned to UE ..
% Total IRS Elements * Proportion of IRS Elements
r = n-(sum(L_k)); %The Remaining IRS Elements ..
% Are Assigned to The Weakest UE
[argvalue, argmax] = max(Alfa_k);
L_k0=L_k(argmax);
L_k0 = L_k0+r;
[Alfa_m,idx]= sort(Alfa_k, 'descend'); % sort UE
L_m = sort(L_k, 'descend');
F = F(idx,:); % sort the whole matrix using the sort idx
W = W(:,idx); % sort the whole matrix using the sort idx
for t_3=1:k
n0(t_3)=(abs(F(t_3,:)*G*W(:,t_3)))
Angle_g_h_w(t_3) = angle(F(t_3,:)*G*W(:,t_3))
end
[argval, arg_max] = max(n0)
Theta_k = -Angle_h_w-Angle_g_h_w
  3 comentarios
Image Analyst
Image Analyst el 15 de Dic. de 2021
Editada: Image Analyst el 15 de Dic. de 2021
Original question attached
%% Suppose I have W and Theta, k=1:K .. K=(any value) let say 10
%%
Alfa_k=zeros(1,k);
Alfa_i=zeros(1,k);
Angle_h_w=zeros(1,k);
Angle_g_h_w=zeros(1,k);
n0=zeros(1,k);
for t_1=1:k
Alfa_k(t_1) = 1/(abs(H(t_1,:)*W(:,t_1)));
Angle_h_w(t_1) = angle(H(t_1,:)*W(:,t_1));
Alfa_i(t_1) = 0;
for t_2=1:k
Alfa_i(t_1) = Alfa_i(t_1) + 1/(abs(H(t_2,:)*W(:,t_2)));
end
Alfa_i(t_1) = Alfa_i(t_1) - Alfa_k(t_1); % Sum of Alfa_i
end
L_k = n*(Alfa_k./Alfa_i); % Number of IRS Elements Assigned to UE ..
% Total IRS Elements * Proportion of IRS Elements
r = n-(sum(L_k)); %The Remaining IRS Elements ..
% Are Assigned to The Weakest UE
[argvalue, argmax] = max(Alfa_k);
L_k0=L_k(argmax);
L_k0 = L_k0+r;
[Alfa_m,idx]= sort(Alfa_k, 'descend'); % sort UE
L_m = sort(L_k, 'descend');
F = F(idx,:); % sort the whole matrix using the sort idx
W = W(:,idx); % sort the whole matrix using the sort idx
for t_3=1:k
n0(t_3)=(abs(F(t_3,:)*G*W(:,t_3)))
Angle_g_h_w(t_3) = angle(F(t_3,:)*G*W(:,t_3))
end
[argval, arg_max] = max(n0)
Theta_k = -Angle_h_w-Angle_g_h_w

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 29 de Jun. de 2021
Example with your second set of code. The array sizes are constructed to be consistent with your code
k = 5;
m = 3;
M = 7;
H = randi(9, k, M)
H = 5×7
6 7 4 5 2 8 4 6 1 6 7 2 1 9 8 9 7 6 7 5 1 2 3 7 6 1 1 6 6 4 7 4 3 4 8
W = randi(9, M, k)
W = 7×5
2 3 2 1 9 6 4 6 1 3 5 7 9 3 8 9 1 9 2 9 5 9 9 9 7 2 8 8 8 2 6 7 1 9 3
n = rand()
n = 0.0108
F = randi(9, k, m)
F = 5×3
2 4 5 2 9 4 7 7 8 5 3 5 2 5 2
G = randi(9, m, M)
G = 3×7
1 2 3 3 1 1 5 2 7 2 9 8 3 8 2 1 4 8 5 4 8
Alfa_k=zeros(1,k);
Alfa_i=zeros(1,k);
Angle_h_w=zeros(1,k);
Angle_g_h_w=zeros(1,k);
n0=zeros(1,k);
for t_1=1:k
Alfa_k(t_1) = 1/(abs(H(t_1,:)*W(:,t_1)));
Angle_h_w(t_1) = angle(H(t_1,:)*W(:,t_1));
Alfa_i(t_1) = 0;
for t_2=1:k
Alfa_i(t_1) = Alfa_i(t_1) + 1/(abs(H(t_2,:)*W(:,t_2)));
end
Alfa_i(t_1) = Alfa_i(t_1) - Alfa_k(t_1); % Sum of Alfa_i
end
L_k = n*(Alfa_k./Alfa_i); % Number of IRS Elements Assigned to UE ..
% Total IRS Elements * Proportion of IRS Elements
r = n-(sum(L_k)); %The Remaining IRS Elements ..
% Are Assigned to The Weakest UE
[argvalue, argmax] = max(Alfa_k);
L_k0=L_k(argmax);
L_k0 = L_k0+r;
[Alfa_m,idx]= sort(Alfa_k, 'descend'); % sort UE
L_m = sort(L_k, 'descend');
F = F(idx,:); % sort the whole matrix using the sort idx
W = W(:,idx); % sort the whole matrix using the sort idx
for t_3=1:k
n0(t_3)=(abs(F(t_3,:)*G*W(:,t_3)))
Angle_g_h_w(t_3) = angle(F(t_3,:)*G*W(:,t_3))
end
n0 = 1×5
1903 0 0 0 0
Angle_g_h_w = 1×5
0 0 0 0 0
n0 = 1×5
1903 2771 0 0 0
Angle_g_h_w = 1×5
0 0 0 0 0
n0 = 1×5
1903 2771 2025 0 0
Angle_g_h_w = 1×5
0 0 0 0 0
n0 = 1×5
1903 2771 2025 1674 0
Angle_g_h_w = 1×5
0 0 0 0 0
n0 = 1×5
1903 2771 2025 1674 3997
Angle_g_h_w = 1×5
0 0 0 0 0
[argval, arg_max] = max(n0)
argval = 3997
arg_max = 5
Theta_k = -Angle_h_w-Angle_g_h_w
Theta_k = 1×5
0 0 0 0 0
  4 comentarios
Matthew Worker
Matthew Worker el 29 de Jun. de 2021
thank you again, do you know how to make this code compatible with the first picture, because that is the main problem for me.
Walter Roberson
Walter Roberson el 29 de Jun. de 2021
No, I do not know how to make it compatible with the first picture. If I were coding it, I would start over without your existing code.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by