SHARE
TWEET

Untitled

a guest Jun 26th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Ts=10^4;
  2. SNR_dB=[-3 0 3 6 9];
  3. Ne=zeros(1,length(SNR_dB));
  4.  
  5. for i=1:length(SNR_dB)
  6.     SNR=10^(SNR_dB(i)/10);
  7.     for t=1:Ts
  8.         s=((sign(rand()-0.5))+1)/2; %create the "on"signal or "off" signal ."on"signal=1,"off" signal=0
  9.         r=randn(2,1)./sqrt(2.*SNR); %it seems that it is noise
  10.         if (s+r)>0.5
  11.             s_hat=1;
  12.         else
  13.             s_hat=0;
  14.         end
  15.         if abs(s_hat-s)>0
  16.             Ne(i)=Ne(i)+1;
  17.         end
  18.         y=Ne./Ts;
  19.     end
  20. end
  21. Pe=zeros(1,5);
  22. for i=1:5
  23.     SNR=10^(SNR_dB(i)/10);
  24.     Pe(i)=erfc(sqrt(SNR/2)/(2^0.5))/2;
  25. end
  26. semilogy(SNR_dB,y,'-r',SNR_dB,Pe,'-k')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top