amit
Posts:
2
Registered:
11/21/12
|
|
Re: cognitive radio
Posted:
Nov 21, 2012 10:05 AM
|
|
hi, im also stuck on my matlab code for cognitive radio, it doesnt seem to work. i need graphs for pf vs pd and then introduce noise later on. my code so far is: Could really do with some help and pointers. thanks! amit703@hotmail.com
%monte carlo simulation function [y1,y2,y3,y4]= ed(SNRL,SNRS,SNRH,n) %ed is the energy detection g1= SNRL:SNRS:SNRH; g=10.^(g1/10); beta=0.01; % is the probability of flase alarm
pf1=zeros(1,length(g)); pd1=zeros(1,length(g)); pf2=zeros(1,length(g)); pd2=zeros(1,length(g));
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; end y1=pf1; y2=pd1; y3=pf2; y4=pd2;
|
|