Energy detction of OFDM signal by Matlab

Status
Not open for further replies.

bigstrik

Newbie level 5
Joined
Mar 26, 2013
Messages
9
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Visit site
Activity points
1,346
hi ..... i'am working on a matlab program to apply the sensing technique of energy detection on OFDM signal and i want to plot the relation between Pd and Pf ,,,, i made a vector for Pf [0:.01:1] and calculate the threshold for each value of Pf ,, but the problem with me is that the Pd is always 1 ,,,,, how can i get different pd for each value of Pf
thanks
 

Hi
Kindly elaborate your question. As far as I understand your question is that you are simulating OFDM system and you want to detect OFDM signal based on received signal energy. If signal energy exceeds the threshold you declare OFDM signal to be present otherwise you declare that no signal is present.
In order to get some help regarding that you would have to explain your code or write the code snippet in your post.
 

sorry for my late reply........ i tried to start to implement the energy detection technique with a simple code using QPSK but there was a different between the simulated curve and the theoretical curve ........ i designed the code based on constant false alarm rate , please help me in finding the problem in the code

here is the code :

clear all
clc
N1=1024;
% N = [100:100:1000]; % number of bits or symbols
Eb_N0_dB=-12 ;
Eb_N0=db2pow(Eb_N0_dB);
detect=0;
ip = randint(1,2*N1);
pf=0:.01:1;
for i=1:length(pf)
% s = 2*ip-1;
a=modem.pskmod(4);
a.inputtype='bit';
s=modulate(a,ip.').';

% for i = 1:length(pfvbv)
for m=1:50 %%% number of observations
n = 1/sqrt(2)*[randn(1,N1) + j*randn(1,N1)];
% Noise addition
w=10^(-Eb_N0_dB/20)*n;
y = s+w; % additive white gaussian noise

%%%%%% secondary user%%%%%%%
varn(i)=var(w); %%%%% noise variance
th(i)=varn(i)*(qfuncinv(pf(i))*sqrt(2*N1)+N1); %%%% threshold calculation
%%%%% number of samples N=1024
yf=fft;
en(m)=sum(abs(yf).^2)/N1;%%% Calculating energy
a1(i)=(th(i)/varn(i))-(N1*(Eb_N0+1));
b(i)=(sqrt(2*N1))*(Eb_N0+1);
if en(m)>th(i)
detect=detect+1;
end
end
pd_sim(i)=detect/m;
detect=0;
pd_th(i)=qfunc(a1(i)/b(i));
end
plot(pf,pd_th)
hold on
plot(pf,pd_sim,'r')
legend('theroy','simulated')

% end

% clear all
% clc
% pf=0:.01:1;
% snr_dB=-12;
% n=1024
% for i=1:length(pf)
% snrlin=db2pow(snr_dB);
% varn=1/snrlin;
% lamda(i)=varn*(qfuncinv(pf(i))*sqrt(2*n)+n);
% a(i)=lamda(i)-n*(1+varn);
% b(i)=sqrt(2*n*(1+varn)^2);
% pd(i)=qfunc(a(i)/b(i));
% pdi(i)=qfunc(qfuncinv(pf(i)-1));
% end
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…