Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Energy Detection plot of Pd vs Snr

Status
Not open for further replies.

Olatunjisa

Newbie level 2
Newbie level 2
Joined
Aug 18, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
58
pls i need help in plotting Pd vs Snr using Energy Detection technique in Cognitive Radio spectrum sensing. I've been successful with the ROC plot of Pd vs Pf. But the Pd vs Snr (db) is not producing the expected result. Pls kindly help me out. the codes i'm working with are given below:

close all;
clear all;
clc;
m=1000;
N =2*m; %sample points N=T/Ts=T/1/2W=2TW

Pf =0.01 %False alarm
totalaccum= 0;
snr_avgdB =-20:20; %SNR=Ps/(N0*W)
snr_avg = power(10,snr_avgdB/10); %db to linear snr

for i=1:length(Pf)
Over_Num = 0;
Th(i) = chi2inv(1-Pf(i),2*m);
%Th(i) = gaminv(1-Pf(i),m,1)*2; %Threshold for given Pf(i)according to Digham 2003
for kk = 1:1000 %Monter-Carlo times
%If Transmmiting Single tone
t = 1:N; %samples
x = sin(pi*t); %single tone, Fs=2F0
noise = randn(1,N); %Noise production
pn = mean(noise.^2); %Noise power average
% pn = (std(noise))^2; %Noise power average
amp = sqrt(noise.^2*snr_avg);
x=amp.*x./abs(x);
SNRdB_Sample=10*log10(x.^2./(noise.^2));
signal = x(1:N);
ps = mean(abs(signal).^2); %signal average power
%awgn channels

Rev_sig = signal + noise; %received signal for detection
accum_power(i) = sum(abs(Rev_sig.^2))/pn; %accumulated received power(normalized to noise power)
if accum_power(i)>Th(i)
Over_Num = Over_Num +1; %decide 1 or 0, present or absent
end
end
Pd_sim(i) = Over_Num / kk; %Detection probability computation

end
figure
loglog(,Pd_sim,'*r');%Complementary ROC Curve
title('Complementary ROC of CED with SNR=-15')
grid on
axis([0.1,1,0.1,1]);
xlabel('Snr (db)');
ylabel('Pd');
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top