Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How do i modify the code when a=0,a=0.1,...,a=0.9,a=1

1 回表示 (過去 30 日間)
yang-En Hsiao
yang-En Hsiao 2019 年 10 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I want to calculate the Ps when a=0.1,a=0.2,....,a=0.9,a=1.0 , so i think i should have 11 different Ps number,however,the window always show me 11 same number,it seems that it just calculate 11 times when the "a" is the same number.
How do i modify my code?
I think the PsB value when a=0.1 is not equal to the PsB value when a=0.4,so i think Ps should have 11 different value,why is the value the same? i think i must make a mistake in somewhere
Code :
H_A = 1/sqrt(2)*[randn(5,6) + j*randn(5,6)];
H_AB = 1/sqrt(2)*[randn(2,6) + j*randn(2,6)];
H_AC = 1/sqrt(2)*[randn(2,6) + j*randn(2,6)];
[UA,SA,VA]=svd(H_A);
[UAB,SAB,VAB]=svd(H_AB);
[UAC,SAC,VAC]=svd(H_AC);
gamma=10^9;
N0=10^-7;
gN=gamma*N0
%null space of A
null_A=VA((1:6),6);%6*1 vector
%Best beamforming direction of H_AB
BBD_AB=VAB((1:6),1);%6*1 vector
%Best beamforming direction of H_AC
BBD_AC=VAC((1:6),1);%6*1 vector
%BBD_AB has to project on the null_A
AB=null_A*((null_A'*null_A)^(-1))*null_A'*BBD_AB;
%BBD_AC has to project on the null_A
AC=null_A*((null_A'*null_A)^(-1))*null_A'*BBD_AC;
a=0:0.1:1
for i=1:1:length(a)
f_A=( a(i)*AB+(1-a(i))*AC)/norm( (a(i)*AB+(1-a(i))*AC) );
PsB=abs((gN)/(f_A'*H_AB'*H_AB *f_A));
PsC=abs((gN)/(f_A'*H_AC'*H_AC *f_A));
if PsB > PsC
Ps(i)=PsB
else
Ps(i)=PsC
end
end
The window show me
Ps =
Columns 1 through 4
127.6320 127.6320 127.6320 127.6320
Columns 5 through 8
127.6320 127.6320 127.6320 127.6320
Columns 9 through 11
127.6320 127.6320 127.6320
Does anyone know where am i wrong?
  2 件のコメント
Karim
Karim 2019 年 10 月 2 日
If you store "f_A" for each iteration, you will see that you get the same result. Irrespective of the value of "a", thus the result of each loop will be the same. (see code below)
If you are trying to compute the weighted average of AB and AC, you don't need the norm etc. The denominator is the sum of the weights (in this case 1 and you can therefore omit the denominator).
H_A = 1/sqrt(2)*[randn(5,6) + i*randn(5,6)];
H_AB = 1/sqrt(2)*[randn(2,6) + i*randn(2,6)];
H_AC = 1/sqrt(2)*[randn(2,6) + i*randn(2,6)];
[UA,SA,VA]=svd(H_A);
[UAB,SAB,VAB]=svd(H_AB);
[UAC,SAC,VAC]=svd(H_AC);
gamma=10^9;
N0=10^-7;
gN=gamma*N0;
%null space of A
null_A=VA((1:6),6);%6*1 vector
%Best beamforming direction of H_AB
BBD_AB=VAB((1:6),1);%6*1 vector
%Best beamforming direction of H_AC
BBD_AC=VAC((1:6),1);%6*1 vector
%BBD_AB has to project on the null_A
AB=null_A*((null_A'*null_A)^(-1))*null_A'*BBD_AB;
%BBD_AC has to project on the null_A
AC=null_A*((null_A'*null_A)^(-1))*null_A'*BBD_AC;
a = 0:0.1:1;
Ps = zeros(numel(a),1);
f_A_store = zeros(6,numel(a));
for i=1:length(a)
f_A = ( a(i)*AB + (1-a(i))*AC) / norm( (a(i)*AB+(1-a(i))*AC) );
f_A_store(:,i) = f_A;
PsB = abs((gN)/((f_A')*(H_AB')*H_AB *f_A));
PsC = abs((gN)/((f_A')*(H_AC')*H_AC *f_A));
if PsB > PsC
Ps(i)=PsB;
else
Ps(i)=PsC;
end
end
yang-En Hsiao
yang-En Hsiao 2019 年 10 月 2 日
so you mean f_A should modify like this ?
f_A=( a(i)*AB + (1-a(i))*AC) ?
i don't understand why do you think we don't need to norm a(i)*AB + (1-a(i))*AC and The denominator is the sum of the weights,can you explain it more in detail?

回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by