how can i implement this equation in matlab where alpha 1 and alpha 2 are powers of user 1 and user 2 respectively?

 採用された回答

syms ro h2 h1 alfa2 alfa1 B
ro=subs(ro,4);h2=subs(h2,3);h1=subs(h1,5);B=subs(B,1);alfa1=subs(alfa1,9);alfa2=subs(alfa2,8);%random numerical values
C2=vpa(B*log2(1+min((alfa2*ro*abs(h2)^2)/(1+ro*alfa1*abs(h2)^2),(ro*alfa2*abs(h1)^2)/(1+ro*alfa1*abs(h1)^2))))

4 件のコメント

usman ali
usman ali 2017 年 11 月 2 日
編集済み: usman ali 2017 年 11 月 2 日
Thank you so much, sir, for help. when I used this equation in this code I am getting an error. Error using * Inner matrix dimensions must agree.
code is::
Pmax = 1;
P1min = 0;
P1max = Pmax;
B = 5000;
N = 1000;
rho = 0:1:30;
h1=(1/sqrt(2))*(randn(N,1)+1i*randn(N,1));
h2=(1/sqrt(2))*(randn(N,1)+1i*randn(N,1));
for aa = 1:1:length (rho);
while (abs(P1max - P1min)) >= 1;
P1 = (P1min+P1max)/2;
P2 = Pmax - P1;
C2=vpa(B*log2(1+min((P2*rho*abs(h2).^2)/(1+rho*P1*abs(h2).^2),(rho*P2*abs(h1).^2)/(1+rho*P1*abs(h1).^2))));
if (C2 < 1)
P1max = P1;
else
P1min = P1;
break
end
end
PU1 = P1; % output
PU2 = Pmax - PU1;
end
usman ali
usman ali 2017 年 11 月 2 日
please can you guide me where i am doing some mistake in this code.
In the while loop, you forgot to mention the index of rho vector. It will be
rho(aa)
usman ali
usman ali 2017 年 11 月 5 日
編集済み: usman ali 2017 年 11 月 5 日
Thank you so much, Sir. now it's working.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2017 年 11 月 2 日

編集済み:

2017 年 11 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by