How I can fix this problem

3 views (last 30 days)
Khiem Nguyen
Khiem Nguyen on 8 Nov 2021
Commented: Khiem Nguyen on 8 Nov 2021
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
~~~~~~~

Answers (1)

VBBV
VBBV on 8 Nov 2021
Edited: VBBV on 8 Nov 2021
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 Comments
VBBV
VBBV on 8 Nov 2021
Check for HH and GG matrices which have the final results
Khiem Nguyen
Khiem Nguyen on 8 Nov 2021
When i read your code. I really know my mistakes. I truly thanks you very much. Have a good day!!

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!