Search All of the Math Forum:

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

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

Replies: 49   Last Post: Mar 4, 2016 2:43 AM

 Messages: [ Previous | Next ]
 mobien Posts: 2 Registered: 12/13/04
Posted: Jan 8, 2012 7:49 AM

Hi All,

The best way to start a project is to divide it into small milestones.

I think in this case first you all must simulate a simple bpsk system with noise. See if you can transmit and receive bits and if your ber curve matches the text book.
The next step should be to add a matched filter.
The final stage will be to implement a sensing algorithm based on whatever technique.

You must also try to understand what does probability of false alarm mean and what is the probability of detection.

Using this approach you all can gain alot. Even if the project does not finish on time atleast you've something to show.

"krithi vengat" wrote in message <jeauik\$ndq\$1@newscl01ah.mathworks.com>...
> HI
> I get ur MATLAB coding for my project but it shows error in signal generation of BPSK. Since I'm new to MATLAB I'm unable to recover, can u suggest me some idea. And also I need MATLAB coding for Co-operative spectrum sensing for probability of false alarm detection.
> I've some code pl go thro' it and tel wat correction i need to do.
>
> clear all;
> close all;
> clc
>
>
> u=1000;%time bandwidth factor
> N=2*u;%samples
> a=2;%path loss exponent
> C=2;%constant losses
> Crs=10; %Number of cognitive radio users
> PdAnd=0;
> %----------Pfa------------%
> Pf=0.01:0.01:1;
> Pfa=Pf.^2;
> %---------signal-----%
> t=1:N;
> s1 = cos(pi*t);
> % s1power=var(s1);
>
>
> %-------- SNR ----------%
> % Snrdb=-15:1:15;
> Snrdb=15;
> Snreal=power(10,Snrdb/10);%Linear Snr
>
> % while Snrdb<15
> for i=1:length(Pfa)
> lamda(i)=gammaincinv(1-Pfa(i),u)*2; %theshold
>
>
> %---------Local spectrum sensing---------%
>
> for j=1:Crs %for each node
> detect=0;
> % d(j)=7+1.1*rand(); %random distanse
> d=7:0.1:8;
> PL=C*(d(j)^-a); %path loss
>
> for sim=1:10%Monte Carlo Simulation for 100 noise realisation
>
> %-------------AWGN channel--------------------%
> noise = randn(1,N); %Noise production with zero mean and s^2 var
> noise_power = mean(noise.^2); %noise average power
> amp = sqrt(noise.^2*Snreal);
> s1=amp.*s1./abs(s1);
> % SNRdB_Sample=10*log10(s1.^2./(noise.^2));
> localSNR(j)=mean(abs(s1).^2)*PL/noise_power;%local snr
> Pdth(j,i)=marcumq(sqrt(2*localSNR(j)),sqrt(lamda(i )),u);%Pd for j node
>
> %Computation of Test statistic for energy detection
> Sum=abs(Rec_signal).^2*PL;
> Test(j,sim)=sum(Sum);
> if (Test(j,sim)>lamda(i))
> detect=detect+1;
> end
>
> end %END Monte Carlo
>
> Pdsim(j)=detect/sim; %Pd of simulation for the j-th CRuser
>
>
> end
> PdAND(i)=prod(Pdsim);
> PdOR(i)=1-prod(1-Pdsim);
>
> end
>
>
> PdAND5=(Pdth(5,:)).^5;
> Pmd5=1-PdAND5;
> PdANDth=(Pdth(Crs,:)).^Crs;
> PmdANDth=1-PdANDth; %Probability of miss detection
> Pmdsim=1-PdAND;
> figure(1);
> plot(Pfa,Pmdsim,'r-*',Pfa,PmdANDth,'k-o',Pfa,Pmd5,'g-*');
> title('Complementary ROC of Cooperative sensing with AND rule under AWGN');
> grid on
> axis([0.0001,1,0.0001,1]);
> xlabel('Probability of False alarm (Pfa)');
> ylabel('Probability of Missed Detection (Pmd)');
> legend('Simulation','Theory n=10','Theory n=5');
>
>
> "sesham srinu" <seshamsrinu83@gmail.com> wrote in message <hs44pp\$dou\$1@fred.mathworks.com>...

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