Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

Topic: cognitive radio
Replies: 47   Last Post: Dec 5, 2012 1:46 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
sesham srinu

Posts: 14
Registered: 9/13/09
Re: cognitive radio
Posted: May 8, 2010 12:51 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Vivi Sera" <vivi.seraphic@gmail.com> wrote in message <hrmljm$htd$1@fred.mathworks.com>...
> I am doing a term project in spectrum sensing as well, probably focus on cooperative schemes, but will start with the conventional one, such as energy detection, matched filter, etc etc. If any of you have some good scripts for me to start off, would it be okay for you to share with me, please? I really appreciate it!
hai iam sesham srinu from university of hyderabad,india
%Entropy estimation of a stochastic signal for primary user detection for the matched filter case


clear all;clc;

%**************************************Input parameters**********************************************************************************

b = [ 1 0 0 1 1]; % Input bit stream

N=[16 32 64];

for j=1:length(N)
snr_db=0:1:20;
g=length(snr_db);
%*************************************BPSK signal generation, Matched filtering and Sampling********************************************
for z=1:length(snr_db)

[signal]=bpsk(b); %BPSK signal generation
signal_fad=b_fad(signal); %fading
[s_matched signal_noise noise]=match(signal_fad,snr_db(z)); % matched filtered output of Qpsk signal


%************************************Entropy anlaysis after matched filter output is sampled********************************************


L=N(j); %No.of bins

s=s_matched(1:N(j)); % N no.of samples Sampled output of matched filter

x=[ ];
x=s(1:N(j)); %block of N samples of matched filter to make decision

noise=noise(1:N(j));

K=4;
sq=sum(x.^2)/N(j);
sigma = sqrt(sum(x.^2)/N(j));
%**********************************checking for chebyeshev inequality*******************************************************************
count=0;
for i=1:N(j)
if(abs((x(i)-mean(x)))>(K*sigma))
count=count+1;

else
count=count;
end
end

if ((count/N(j))<= (1/(K^2)))

%display('Design value of K is correct ');

else
%display('Design value of K is incorrect and try for another value');

end

% %***********************************Histogram of x**************************************************************************************
v1=(2*K*sigma)/(L); % Width of each bin
v=-K*sigma:v1 :K*sigma; % a vector specifying the centres of bins from where to start and stop.

%***********************************Checking for no.of values of x fallong inside the kth bin********************************************

pa11=0;
pa01=0; y1=0;e(z)=0;
for k=1:L;

number_samples=0;



lk(k)=v(k)-(v1/2);
lkplus1(k)=v(k)+(v1/2);

for i=1:N(j)
if((lk(k)<x(i))& (x(i)<lkplus1(k)))
number_samples=number_samples+1;
else
number_samples=number_samples+eps;
end
end

nk=number_samples;

y1=y1+number_samples;
%----------------------------------------Entropy caculation------------

if(nk~=0)
nk=nk;
else
nk=nk+eps;

end
p(k) = -((nk/N(j))*log2(nk/N(j)));
e(z)= e(z)+p(k) ; %Entropy estimate




%********************************************computing pk(a)********************************************************************************
a1=snr_db(z);

a0=0;

pk1=0;pk0=0; M=2; u(1)=1;u(2)=-1;
for m=1:M
h1(m)=0;h2(m)=0;h3(m)=0;h4(m)=0;

h1(m)=(lk(k)-u(m)*sqrt(a1/(1+a1)))*(1+a1);
h2(m)=(lkplus1(k)-u(m)*sqrt(a1/(1+a1)))*(1+a1);
h3(m)=(lk(k)-u(m)*sqrt(a0/(1+a0)))*(1+a0);
h4(m)= (lkplus1(k)-u(m)*sqrt(a0/(1+a0)))*(1+a0);



pk1=pk1+[[qfunc(h1(m))]-[qfunc(h2(m))]];
pk0=pk0+[[qfunc(h3(m))]-[qfunc(h4(m))]];

end

pka1= (1/M)*pk1+eps;
pka0= (1/M)*pk0+eps;

%*********************************************computing log-likelihood ratio***************************************************************

pa11=pa11+(nk/N(j))*[log2(pka1)-log2(pka0)];


end

le(z)=pa11;%Log-likelihood ratio of entropy
end

e1((j+(j-1)*20):j*21)=e;
le1((j+(j-1)*20):j*21)=le;
end



plot(snr_db,e1(1:21),'-b*',snr_db,e1(22:42),'-ro',snr_db,e1(43:63),'-g.');
xlabel('SNR in db');
ylabel('Entropy');
title('Normal entropy');
h2=legend('N=16 BPSK','N=32 BPSK','N=64 BPSK',1);

figure
plot(snr_db,le1(1:21),'-b*',snr_db,le1(22:42),'-ro',snr_db,le1(43:63),'-g.');
xlabel('SNR in db');
ylabel('Log-likelihood Entropy');
title('log-likelihood entropy')
h2=legend('N=16 BPSK','N=32 BPSK','N=64 BPSK',1);





Date Subject Author
8/8/08
Read cognitive radio
nancy
8/19/08
Read Re: cognitive radio
Guido Gioberto
8/21/08
Read Re: cognitive radio
nancy
9/5/08
Read Re: cognitive radio
nancy
10/15/08
Read Re: cognitive radio
rizwan
10/27/09
Read Re: cognitive radio
Johnas
12/7/09
Read Re: cognitive radio
Luca
1/16/10
Read Re: cognitive radio
Md. Rakib
3/7/10
Read Re: cognitive radio
khalil ajmi
2/10/11
Read cognitive radio
amber
5/8/10
Read Re: cognitive radio
sesham srinu
10/20/08
Read Re: cognitive radio
chen ximei
10/20/08
Read Re: cognitive radio
chen ximei
1/11/09
Read Re: cognitive radio
gmt mathew
9/8/09
Read Re: cognitive radio
Brice
1/22/12
Read Re: cognitive radio
vengat
3/12/12
Read Re: cognitive radio
gopinath R
3/8/10
Read Re: cognitive radio
Jorian
2/12/09
Read Re: cognitive radio
Mirage Bhatti
5/8/10
Read Re: cognitive radio
sesham srinu
2/13/09
Read cognitive radio
sapna sharad
6/2/10
Read Re: cognitive radio
samee Rehman
2/23/09
Read Re: cognitive radio
Soyoung LEe
2/23/09
Read Re: cognitive radio
talhazahir@gmail.com
4/6/09
Read Re: cognitive radio
mary
7/15/09
Read Re: cognitive radio
kk muthu
7/15/09
Read Re: cognitive radio
Alicia Cheng
10/22/09
Read Re: cognitive radio
ehab elshaer
5/3/10
Read Re: cognitive radio
Vivi Sera
5/3/10
Read Re: cognitive radio
Vivi Sera
5/8/10
Read Re: cognitive radio
sesham srinu
1/7/12
Read Re: cognitive radio
vengat
1/7/12
Read Re: cognitive radio
vengat
1/8/12
Read Re: cognitive radio
mobien
11/24/12
Read Re: cognitive radio
jenkinwinston.j2011@vit.ac.in
7/16/10
Read Re: cognitive radio
her linda
7/16/10
Read Re: cognitive radio
Steven Lord
10/8/10
Read Re: cognitive radio
mike mekkanen
11/14/10
Read Re: cognitive radio
shamser
11/14/10
Read Re: cognitive radio
shamser
11/14/10
Read Re: cognitive radio
shamser
11/14/10
Read Re: cognitive radio
shamser
11/25/10
Read Re: cognitive radio
ravi sharan
11/25/10
Read Re: cognitive radio
Walter Roberson
5/25/11
Read Re: cognitive radio
Sindiso Nleya
9/8/12
Read Re: cognitive radio
jaya pavi
11/21/12
Read Re: cognitive radio
amit
12/5/12
Read Re: cognitive radio
ABDUL

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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.