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

 Akzeptierte Antwort

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 Kommentare

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
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)
Thank you so much, Sir. now it's working.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 2 Nov. 2017

Bearbeitet:

am 5 Nov. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by