The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: cognitive radio, energy detection
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  

Posts: 2
Registered: 11/21/12
cognitive radio, energy detection
Posted: Nov 21, 2012 9:51 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

hi, im new to matlab and not used it before and any help, i will be really thankful, im trying to get a graph of PF vs PD
this is my code, but something is wrong, especially for the outputs of y4, im not really sure anymore.

%monte carlo simulation
function [y1,y2,y3,y4]= ed(SNRL,SNRS,SNRH,n) %ed is the energy detection
beta=0.01; % is the probability of flase alarm


for i=1 : length(g)
y0 = randn(n,1000000);
y1= randn(n,1000000)*sqrt(g(i))+y0;

Tgam = gaminv(1-beta,n/2,2/n*(1+g(i))); %threshold
pf1(i)= gamcdf(Tgam,n/2,2/n*(1+g(i)))
pd1 (i) = gamcdf(Tgam,n/2,2/n); % prob of detection
pf2(i)= length (find(sum(y1.^2)/n<Tgam))/1000000;
pd2 (i) = length (find(sum(y0.^2)/n<Tgam))/1000000;

y1=pf1; y2=pd1; y3=pf2; y4=pd2;

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.