How I can fix this problem

This is my code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clear all
clc
for N=8:2:20
tn = 7;
M = 7; L = 5;
attSR = -40; attPU = -60; % dB
Nt = N;
h = zeros(Nt,M); % Nt antenna to M SRs
g = zeros(Nt,L); % Nt antenna to L PUs
for ii=1:M % to each SRs
h(:,ii) = (1/sqrt(1/attSR))* sqrt(1/2)*(randn(Nt,1)+1i*randn(Nt,1)) ;
H(:,:,ii) = h(:,ii)*h(:,ii)'; %before (7a) to 1 SR
end
for ii=1:L
g(:,ii) = (1/sqrt(1/attPU))* sqrt(1/2)*(randn(Nt,1)+1i*randn(Nt,1)) ;
G(:,:,ii) = g(:,ii)*g(:,ii)' ; %before (7a) to 1 PU
end
end
~~~~~~~

Réponses (1)

VBBV
VBBV le 8 Nov 2021
Modifié(e) : VBBV le 8 Nov 2021

1 vote

clear all
clear all
clc
i = 1;LL = 8:2:20;
for N=8:2:20
tn = 7;
M = 7; L = 5;
attSR = -40; attPU = -60; % dB
Nt = N;
h = zeros(Nt,M); % Nt antenna to M SRs
g = zeros(Nt,L); % Nt antenna to L PUs
H = zeros(Nt,Nt,length(LL));
G = zeros(Nt,Nt,length(LL));
for ii=1:M % to each SRs
h(:,ii) = (1/sqrt(1/attSR))* sqrt(1/2)*(randn(Nt,1)+1i*randn(Nt,1)) ;
%H(:,:,i) = h(:,ii)*h(:,ii)'; %before (7a) to 1 SR
end
H = h*h.';HH(1:Nt,1:Nt,i) = H;
for ii=1:L
g(:,ii) = (1/sqrt(1/attPU))* sqrt(1/2)*(randn(Nt,1)+1i*randn(Nt,1)) ;
%G(:,:,i) = g(:,ii)*g(:,ii)' ; %before (7a) to 1 PU
end;
G = g*g.';GG(1:Nt,1:Nt,i) = G;
i = i+1;
end
You can try this approach

2 commentaires

VBBV
VBBV le 8 Nov 2021
Check for HH and GG matrices which have the final results
Khiem Nguyen
Khiem Nguyen le 8 Nov 2021
When i read your code. I really know my mistakes. I truly thanks you very much. Have a good day!!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Design, Analysis, Benchmarking, and Verification dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by