Two conditions and not same.
Ältere Kommentare anzeigen
clear all;
clc;
close all;
sigma = 1;
snrdb = 0:5:40;
p =10^4* 10.^(snrdb/10);
eta = 0.5;
u = 0.55;
yth = 0.1;
alp = 0.4;
R = 1;
h = 2;
eb = 0.1;
m = 2;
T = 1;
pth = 2;
for i= 1:length(snrdb)
j=0;k=0;
M=100000;
A = (yth * sigma) ./ p(i);
B = pth ./ p(i);
C = (yth * T * sigma * (1 - alp)) / (eta * alp * T * p(i) * 2 * (1 - u));
D = eb / (eta * alp * T * p(i));
for N= 1:1:M
c=gamrnd(2,0.5,1);
d2=2;
a=gamrnd(1,1,1);
d1=gamrnd(1,1,1);
snr=a/d1^2;
snr1 = (C .* d2.^2) / (B + D);
snr2 = (C .* d2.^2) / (A + D);
lower_limit = ((C * d2^2 - D * c) * d1^2) / c;
upper_limit = (pth * d1^2) / p(i);
if (a > lower_limit && c > 0.1 && c < 2)
j=j+1;
else
j=j;
end
if (a < lower_limit && c > 0.1 && c < 2)
k=k+1;
else
k=k;
end
end
pout(i)=(j/M);
pout1(i)=k/M;
pout2(i)=1-pout1(i);
end
semilogy(snrdb,pout,'-y','LineWidth',0.6,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerSize',6)
hold on
semilogy(snrdb,pout2,'--r','LineWidth',0.6,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerSize',6)
From the above code value of pout and pout2 must be same, but i am getting different values. PLEASE resolve this.
2 Kommentare
Dyuman Joshi
am 14 Aug. 2023
"From the above code value of pout and pout2 must be same"
Why must the values be same? Their definitions are different.
anuradha verma
am 14 Aug. 2023
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
