How I can fix this problem

1 次查看(过去 30 天)
Khiem Nguyen
Khiem Nguyen 2021-11-8
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
~~~~~~~

回答(1 个)

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

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by