Jamal
2013-05-24 09:39:08 UTC
Hi,
I work on cooperative spectrum sensing for cognitive radio, energy detection;
I have this code there is somthing wrong which I can't find it
anyone can tell me whats wrong in this code
clc; clear all; close all;
u = 5;
sigma = 0:0.2:5;
snr = 20;
pf = gammainc(u,sigma/2)/gamma(u);
g=0;
h=0;
for p=0:(u-2)
gg = (1/factorial(p)) * (sigma./2).^p;
g = g + gg;
hh = (1/factorial(p)) * ((sigma.*snr)/(2*(1+snr))).^p;
h = h + hh;
end
pd = exp(-(sigma/2)) .* g + ((1+snr)./snr)^(u-1) .*(exp(-(sigma./(2+(1+snr)))) - exp(-(sigma/2)) .* h);
pm = 1 - pd;
loglog(pf,pm)
xlabel('Pf: Probability of Fals alarm');
ylabel('Pm: Probability of missed detection');
legend('20 dB');
grid on
I work on cooperative spectrum sensing for cognitive radio, energy detection;
I have this code there is somthing wrong which I can't find it
anyone can tell me whats wrong in this code
clc; clear all; close all;
u = 5;
sigma = 0:0.2:5;
snr = 20;
pf = gammainc(u,sigma/2)/gamma(u);
g=0;
h=0;
for p=0:(u-2)
gg = (1/factorial(p)) * (sigma./2).^p;
g = g + gg;
hh = (1/factorial(p)) * ((sigma.*snr)/(2*(1+snr))).^p;
h = h + hh;
end
pd = exp(-(sigma/2)) .* g + ((1+snr)./snr)^(u-1) .*(exp(-(sigma./(2+(1+snr)))) - exp(-(sigma/2)) .* h);
pm = 1 - pd;
loglog(pf,pm)
xlabel('Pf: Probability of Fals alarm');
ylabel('Pm: Probability of missed detection');
legend('20 dB');
grid on